Compare commits
13 Commits
refactor/s
...
e63a03601a
| Author | SHA1 | Date | |
|---|---|---|---|
| e63a03601a | |||
| 389373ad8c | |||
| ace02a3133 | |||
| d69a6210f6 | |||
| 3c0b43fea3 | |||
| 9b0008626b | |||
| 61861e331a | |||
| 2cc9d7dd97 | |||
| f982bcead1 | |||
| 7a85e1731d | |||
| 6db99e775a | |||
| e5f7ba3615 | |||
| 24bfef431b |
@@ -5,6 +5,9 @@ APP_DEBUG=false
|
|||||||
APP_URL=http://localhost
|
APP_URL=http://localhost
|
||||||
|
|
||||||
PURCHASE_CHECKOUT_EXPIRATION_MINUTES=30
|
PURCHASE_CHECKOUT_EXPIRATION_MINUTES=30
|
||||||
|
PURCHASE_QR_EXPIRATION_MINUTES=15
|
||||||
|
PURCHASE_TELEPAGOS_EXPIRATION_MINUTES=30
|
||||||
|
PURCHASE_TRANSFER_EXPIRATION_MINUTES=1440
|
||||||
STOCK_RESERVATION_EXPIRATION_MINUTES=30
|
STOCK_RESERVATION_EXPIRATION_MINUTES=30
|
||||||
FRONTEND_URLS=http://localhost:4200
|
FRONTEND_URLS=http://localhost:4200
|
||||||
|
|
||||||
@@ -28,7 +31,6 @@ AUTH_LOGIN_ATTEMPT_WINDOW_MINUTES=30
|
|||||||
AUTH_LOGIN_LOCK_MINUTES=15
|
AUTH_LOGIN_LOCK_MINUTES=15
|
||||||
AUTH_LOGIN_RATE_LIMIT_PER_MINUTE=10
|
AUTH_LOGIN_RATE_LIMIT_PER_MINUTE=10
|
||||||
AUTH_LOGIN_IP_RATE_LIMIT_PER_MINUTE=30
|
AUTH_LOGIN_IP_RATE_LIMIT_PER_MINUTE=30
|
||||||
AUTH_PASSWORD_RESET_EXPIRATION_MINUTES=60
|
|
||||||
|
|
||||||
LOG_CHANNEL=daily
|
LOG_CHANNEL=daily
|
||||||
LOG_STACK=single
|
LOG_STACK=single
|
||||||
@@ -39,8 +41,6 @@ TELEPAGOS_LOG_LEVEL=info
|
|||||||
TELEPAGOS_LOG_DAYS=30
|
TELEPAGOS_LOG_DAYS=30
|
||||||
COMMANDS_LOG_LEVEL=info
|
COMMANDS_LOG_LEVEL=info
|
||||||
COMMANDS_LOG_DAYS=30
|
COMMANDS_LOG_DAYS=30
|
||||||
EMAILS_LOG_LEVEL=info
|
|
||||||
EMAILS_LOG_DAYS=30
|
|
||||||
|
|
||||||
DB_CONNECTION=mysql
|
DB_CONNECTION=mysql
|
||||||
DB_HOST=127.0.0.1
|
DB_HOST=127.0.0.1
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -22,18 +22,10 @@ class ValidateResetPasswordAttemptController extends Controller
|
|||||||
{
|
{
|
||||||
$data = $request->validated();
|
$data = $request->validated();
|
||||||
|
|
||||||
$result = $this->resetPasswordAttemptService->validateCode(
|
if (! $this->resetPasswordAttemptService->validateCode(
|
||||||
$data['email'],
|
$data['email'],
|
||||||
$data['codigo'],
|
$data['codigo'],
|
||||||
);
|
)) {
|
||||||
|
|
||||||
if ($result === ResetPasswordAttemptService::CODE_EXPIRED) {
|
|
||||||
throw ValidationException::withMessages([
|
|
||||||
'codigo' => __('api.auth.reset_code_expired'),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($result !== ResetPasswordAttemptService::CODE_VALID) {
|
|
||||||
throw ValidationException::withMessages([
|
throw ValidationException::withMessages([
|
||||||
'codigo' => __('api.auth.reset_code_invalid'),
|
'codigo' => __('api.auth.reset_code_invalid'),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Attributes\Hidden;
|
|||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
#[Fillable(['user_id', 'codigo', 'reason', 'status', 'expires_at'])]
|
#[Fillable(['user_id', 'codigo', 'reason', 'status'])]
|
||||||
#[Hidden(['codigo'])]
|
#[Hidden(['codigo'])]
|
||||||
class ResetPasswordAttempt extends Model
|
class ResetPasswordAttempt extends Model
|
||||||
{
|
{
|
||||||
@@ -31,7 +31,6 @@ class ResetPasswordAttempt extends Model
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'user_id' => 'integer',
|
'user_id' => 'integer',
|
||||||
'expires_at' => 'datetime',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,12 +12,6 @@ use Throwable;
|
|||||||
|
|
||||||
class ResetPasswordAttemptService
|
class ResetPasswordAttemptService
|
||||||
{
|
{
|
||||||
public const CODE_VALID = 'valid';
|
|
||||||
|
|
||||||
public const CODE_INVALID = 'invalid';
|
|
||||||
|
|
||||||
public const CODE_EXPIRED = 'expired';
|
|
||||||
|
|
||||||
public function createForEmail(
|
public function createForEmail(
|
||||||
string $email,
|
string $email,
|
||||||
string $tenantCode,
|
string $tenantCode,
|
||||||
@@ -152,12 +146,12 @@ class ResetPasswordAttemptService
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateCode(string $email, string $code): string
|
public function validateCode(string $email, string $code): bool
|
||||||
{
|
{
|
||||||
$emailFingerprint = $this->emailFingerprint($email);
|
$emailFingerprint = $this->emailFingerprint($email);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return DB::transaction(function () use ($email, $code, $emailFingerprint): string {
|
return DB::transaction(function () use ($email, $code, $emailFingerprint): bool {
|
||||||
$user = User::query()
|
$user = User::query()
|
||||||
->where('email', $email)
|
->where('email', $email)
|
||||||
->lockForUpdate()
|
->lockForUpdate()
|
||||||
@@ -175,27 +169,14 @@ class ResetPasswordAttemptService
|
|||||||
'email_fingerprint' => $emailFingerprint,
|
'email_fingerprint' => $emailFingerprint,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return self::CODE_INVALID;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if ($attempt->expires_at?->isPast()) {
|
|
||||||
$attempt->update([
|
|
||||||
'status' => ResetPasswordAttempt::STATUS_EXPIRED,
|
|
||||||
]);
|
|
||||||
|
|
||||||
Log::info('Password reset code validation failed: attempt expired.', [
|
|
||||||
'email_fingerprint' => $emailFingerprint,
|
|
||||||
'attempt_id' => $attempt->getKey(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return self::CODE_EXPIRED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$attempt->update([
|
$attempt->update([
|
||||||
'status' => ResetPasswordAttempt::STATUS_VALIDATED,
|
'status' => ResetPasswordAttempt::STATUS_VALIDATED,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return self::CODE_VALID;
|
return true;
|
||||||
});
|
});
|
||||||
} catch (Throwable $exception) {
|
} catch (Throwable $exception) {
|
||||||
Log::error('Failed to validate password reset code.', [
|
Log::error('Failed to validate password reset code.', [
|
||||||
@@ -233,19 +214,6 @@ class ResetPasswordAttemptService
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($attempt->expires_at?->isPast()) {
|
|
||||||
$attempt->update([
|
|
||||||
'status' => ResetPasswordAttempt::STATUS_EXPIRED,
|
|
||||||
]);
|
|
||||||
|
|
||||||
Log::info('Password reset failed: attempt expired.', [
|
|
||||||
'email_fingerprint' => $emailFingerprint,
|
|
||||||
'attempt_id' => $attempt->getKey(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$user->password = $password;
|
$user->password = $password;
|
||||||
$user->failed_login_attempts = 0;
|
$user->failed_login_attempts = 0;
|
||||||
$user->last_failed_login_at = null;
|
$user->last_failed_login_at = null;
|
||||||
@@ -302,7 +270,6 @@ class ResetPasswordAttemptService
|
|||||||
'codigo' => $this->generateCode(),
|
'codigo' => $this->generateCode(),
|
||||||
'reason' => $reason,
|
'reason' => $reason,
|
||||||
'status' => ResetPasswordAttempt::STATUS_PENDING,
|
'status' => ResetPasswordAttempt::STATUS_PENDING,
|
||||||
'expires_at' => now()->addMinutes((int) config('auth.passwords.users.expire')),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $attempt->getKey();
|
return $attempt->getKey();
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ class AdminAppBootstrapResource extends JsonResource
|
|||||||
'login_header_footer_color' => $websiteType->login_header_footer_color,
|
'login_header_footer_color' => $websiteType->login_header_footer_color,
|
||||||
'site_logo' => $websiteType->siteLogo?->getTemporaryUrl(1440),
|
'site_logo' => $websiteType->siteLogo?->getTemporaryUrl(1440),
|
||||||
'footer_logo' => $websiteType->footerLogo?->getTemporaryUrl(1440),
|
'footer_logo' => $websiteType->footerLogo?->getTemporaryUrl(1440),
|
||||||
'favicon' => $websiteType->favicon?->getTemporaryUrl(1440),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class AdminAppBootstrapService
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'website_type' => WebsiteType::query()
|
'website_type' => WebsiteType::query()
|
||||||
->with(['siteLogo', 'footerLogo', 'favicon'])
|
->with(['siteLogo', 'footerLogo'])
|
||||||
->where('dominio', $domain)
|
->where('dominio', $domain)
|
||||||
->firstOrFail(),
|
->firstOrFail(),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class ScannerBootstrapService
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'website_type' => WebsiteType::query()
|
'website_type' => WebsiteType::query()
|
||||||
->with(['siteLogo', 'footerLogo', 'favicon'])
|
->with(['siteLogo', 'footerLogo'])
|
||||||
->where('scanner_domain', $domain)
|
->where('scanner_domain', $domain)
|
||||||
->firstOrFail(),
|
->firstOrFail(),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Catalog\Controllers\AdminApp;
|
||||||
|
|
||||||
|
use App\Domains\Catalog\Models\FeaturedGroup;
|
||||||
|
use App\Domains\Catalog\Requests\AdminApp\UpsertOnTicketFeaturedGroupRequest;
|
||||||
|
use App\Domains\Catalog\Resources\AdminApp\OnTicketFeaturedGroupResource;
|
||||||
|
use App\Domains\Catalog\Services\OnTicketFeaturedGroupService;
|
||||||
|
use App\Domains\Tenant\Models\Tenant;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||||
|
|
||||||
|
class OnTicketFeaturedGroupController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly OnTicketFeaturedGroupService $featuredGroupService,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function index(Request $request): AnonymousResourceCollection
|
||||||
|
{
|
||||||
|
return OnTicketFeaturedGroupResource::collection(
|
||||||
|
$this->featuredGroupService->forTenant($this->onTicketTenant($request))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(UpsertOnTicketFeaturedGroupRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$featuredGroup = $this->featuredGroupService->create(
|
||||||
|
$this->onTicketTenant($request),
|
||||||
|
$request->validated(),
|
||||||
|
);
|
||||||
|
|
||||||
|
return OnTicketFeaturedGroupResource::make($featuredGroup)
|
||||||
|
->response()
|
||||||
|
->setStatusCode(201);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(
|
||||||
|
UpsertOnTicketFeaturedGroupRequest $request,
|
||||||
|
FeaturedGroup $featuredGroup,
|
||||||
|
): OnTicketFeaturedGroupResource {
|
||||||
|
$tenant = $this->onTicketTenant($request);
|
||||||
|
|
||||||
|
abort_unless($featuredGroup->tenant_code === $tenant->codigo, 404);
|
||||||
|
|
||||||
|
return OnTicketFeaturedGroupResource::make(
|
||||||
|
$this->featuredGroupService->update(
|
||||||
|
$tenant,
|
||||||
|
$featuredGroup,
|
||||||
|
$request->validated(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onTicketTenant(Request $request): Tenant
|
||||||
|
{
|
||||||
|
$tenant = $request->user()->tenant()->firstOrFail();
|
||||||
|
|
||||||
|
abort_unless($tenant->website_type_code === 'onticket', 404);
|
||||||
|
|
||||||
|
return $tenant;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Catalog\Requests\AdminApp;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class UpsertOnTicketFeaturedGroupRequest extends FormRequest
|
||||||
|
{
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return array<string, mixed> */
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'category_name' => ['required', 'string', 'max:255'],
|
||||||
|
'is_featured' => ['required', 'boolean'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Catalog\Resources\AdminApp;
|
||||||
|
|
||||||
|
use App\Domains\Catalog\Enums\ProductLayout;
|
||||||
|
use App\Domains\Catalog\Models\FeaturedGroup;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
/** @mixin FeaturedGroup */
|
||||||
|
class OnTicketFeaturedGroupResource extends JsonResource
|
||||||
|
{
|
||||||
|
/** @return array<string, mixed> */
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'code' => $this->code,
|
||||||
|
'category_id' => $this->category_id,
|
||||||
|
'category_name' => $this->category->nombre,
|
||||||
|
'group_name' => $this->group_name,
|
||||||
|
'is_featured' => $this->product_layout === ProductLayout::Row,
|
||||||
|
'type' => $this->source_type->value,
|
||||||
|
'product_layout' => $this->product_layout->value,
|
||||||
|
'group_layout' => $this->group_layout->value,
|
||||||
|
'order' => $this->group_order,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Catalog\Services;
|
||||||
|
|
||||||
|
use App\Domains\Catalog\Enums\FeaturedGroupSource;
|
||||||
|
use App\Domains\Catalog\Enums\GroupLayout;
|
||||||
|
use App\Domains\Catalog\Enums\ProductLayout;
|
||||||
|
use App\Domains\Catalog\Models\Category;
|
||||||
|
use App\Domains\Catalog\Models\FeaturedGroup;
|
||||||
|
use App\Domains\Tenant\Models\Tenant;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class OnTicketFeaturedGroupService
|
||||||
|
{
|
||||||
|
/** @return Collection<int, FeaturedGroup> */
|
||||||
|
public function forTenant(Tenant $tenant): Collection
|
||||||
|
{
|
||||||
|
return FeaturedGroup::query()
|
||||||
|
->where('tenant_code', $tenant->codigo)
|
||||||
|
->where('source_type', FeaturedGroupSource::Category)
|
||||||
|
->whereHas('category', fn ($query) => $query->where('tenant_code', $tenant->codigo))
|
||||||
|
->with('category')
|
||||||
|
->orderBy('group_order')
|
||||||
|
->orderBy('id')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param array{category_name: string, is_featured: bool} $data */
|
||||||
|
public function create(Tenant $tenant, array $data): FeaturedGroup
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($tenant, $data): FeaturedGroup {
|
||||||
|
$category = $tenant->categories()->create([
|
||||||
|
'nombre' => $data['category_name'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$featuredGroup = FeaturedGroup::query()->create([
|
||||||
|
'tenant_code' => $tenant->codigo,
|
||||||
|
'source_type' => FeaturedGroupSource::Category,
|
||||||
|
'category_id' => $category->id,
|
||||||
|
'product_layout' => $this->productLayout($data['is_featured']),
|
||||||
|
'group_layout' => GroupLayout::Paginated,
|
||||||
|
'group_name' => $data['category_name'],
|
||||||
|
'group_order' => $this->nextOrder($tenant),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $featuredGroup->setRelation('category', $category);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param array{category_name: string, is_featured: bool} $data */
|
||||||
|
public function update(
|
||||||
|
Tenant $tenant,
|
||||||
|
FeaturedGroup $featuredGroup,
|
||||||
|
array $data,
|
||||||
|
): FeaturedGroup {
|
||||||
|
return DB::transaction(function () use ($tenant, $featuredGroup, $data): FeaturedGroup {
|
||||||
|
$featuredGroup = FeaturedGroup::query()
|
||||||
|
->whereKey($featuredGroup->getKey())
|
||||||
|
->where('tenant_code', $tenant->codigo)
|
||||||
|
->where('source_type', FeaturedGroupSource::Category)
|
||||||
|
->lockForUpdate()
|
||||||
|
->firstOrFail();
|
||||||
|
|
||||||
|
$category = Category::query()
|
||||||
|
->whereKey($featuredGroup->category_id)
|
||||||
|
->where('tenant_code', $tenant->codigo)
|
||||||
|
->lockForUpdate()
|
||||||
|
->firstOrFail();
|
||||||
|
|
||||||
|
$category->update(['nombre' => $data['category_name']]);
|
||||||
|
$featuredGroup->update([
|
||||||
|
'group_name' => $data['category_name'],
|
||||||
|
'product_layout' => $this->productLayout($data['is_featured']),
|
||||||
|
'group_layout' => GroupLayout::Paginated,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $featuredGroup->setRelation('category', $category);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function productLayout(bool $isFeatured): ProductLayout
|
||||||
|
{
|
||||||
|
return $isFeatured ? ProductLayout::Row : ProductLayout::ColumnWithCart;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function nextOrder(Tenant $tenant): int
|
||||||
|
{
|
||||||
|
$maximumOrder = FeaturedGroup::query()
|
||||||
|
->where('tenant_code', $tenant->codigo)
|
||||||
|
->max('group_order');
|
||||||
|
|
||||||
|
return $maximumOrder === null ? 0 : ((int) $maximumOrder) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -343,9 +343,9 @@ class StockReservationService
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clearExpirationForReview(Purchase $purchase): void
|
public function refreshForPurchase(Purchase $purchase, ?Carbon $expiresAt): void
|
||||||
{
|
{
|
||||||
DB::transaction(function () use ($purchase): void {
|
DB::transaction(function () use ($purchase, $expiresAt): void {
|
||||||
/** @var Purchase $purchase */
|
/** @var Purchase $purchase */
|
||||||
$purchase = Purchase::query()->lockForUpdate()->findOrFail($purchase->getKey());
|
$purchase = Purchase::query()->lockForUpdate()->findOrFail($purchase->getKey());
|
||||||
if ($purchase->stock_reservation_id === null) {
|
if ($purchase->stock_reservation_id === null) {
|
||||||
@@ -363,7 +363,7 @@ class StockReservationService
|
|||||||
throw new StockReservationExpiredException;
|
throw new StockReservationExpiredException;
|
||||||
}
|
}
|
||||||
|
|
||||||
$reservation->update(['expires_at' => null]);
|
$reservation->update(['expires_at' => $expiresAt]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,11 +21,16 @@ Modela y publica la oferta comercial del tenant: productos, variantes, categorí
|
|||||||
- `StockReservationService`: sincroniza el carrito como conjunto, bloquea todos sus inventarios en orden estable y mantiene el ledger agregado consistente con `Inventory.reserved_stock`.
|
- `StockReservationService`: sincroniza el carrito como conjunto, bloquea todos sus inventarios en orden estable y mantiene el ledger agregado consistente con `Inventory.reserved_stock`.
|
||||||
- `ExpireStockReservationsService`: detecta en un único recorrido reservas vencidas de compras, carritos y huérfanas, y delega los efectos comerciales sin mezclar esas reglas con la liberación física del inventario.
|
- `ExpireStockReservationsService`: detecta en un único recorrido reservas vencidas de compras, carritos y huérfanas, y delega los efectos comerciales sin mezclar esas reglas con la liberación física del inventario.
|
||||||
- `FeaturedGroupService`: pagina los ítems destacados para la tienda.
|
- `FeaturedGroupService`: pagina los ítems destacados para la tienda.
|
||||||
|
- `OnTicketFeaturedGroupService`: administra grupos destacados del panel para sitios de tickets.
|
||||||
|
|
||||||
## Endpoints de tienda
|
## Endpoints de tienda
|
||||||
|
|
||||||
Bajo `/tenants/{tenant:codigo}` se publican catálogo, búsqueda, categoría, detalle, alta de ítems y paginación de grupos destacados.
|
Bajo `/tenants/{tenant:codigo}` se publican catálogo, búsqueda, categoría, detalle, alta de ítems y paginación de grupos destacados.
|
||||||
|
|
||||||
|
## Endpoints administrativos
|
||||||
|
|
||||||
|
Bajo `/v1/adminapp/tenant/featured-groups`, con `auth:sanctum` y `adminapp.tenant`, se listan, crean y actualizan grupos destacados.
|
||||||
|
|
||||||
## Dependencias y reglas
|
## Dependencias y reglas
|
||||||
|
|
||||||
Usa `Attachable` para imágenes/archivos, `Tenant` para aislamiento y `Ticket`/`Event` para vigencia y fechas. `Cart` y `Purchase` consumen sus precios, variantes e inventario. Los cambios de stock deben pasar por `CatalogInventoryService` para conservar reservas y disponibilidad.
|
Usa `Attachable` para imágenes/archivos, `Tenant` para aislamiento y `Ticket`/`Event` para vigencia y fechas. `Cart` y `Purchase` consumen sus precios, variantes e inventario. Los cambios de stock deben pasar por `CatalogInventoryService` para conservar reservas y disponibilidad.
|
||||||
|
|||||||
15
app/Domains/Catalog/routes/adminapp.php
Normal file
15
app/Domains/Catalog/routes/adminapp.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Domains\Catalog\Controllers\AdminApp\OnTicketFeaturedGroupController;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
Route::prefix('v1/adminapp/tenant')
|
||||||
|
->middleware(['auth:sanctum', 'adminapp.tenant'])
|
||||||
|
->group(function (): void {
|
||||||
|
Route::get('featured-groups', [OnTicketFeaturedGroupController::class, 'index'])
|
||||||
|
->name('adminapp.featured-groups.index');
|
||||||
|
Route::post('featured-groups', [OnTicketFeaturedGroupController::class, 'store'])
|
||||||
|
->name('adminapp.featured-groups.store');
|
||||||
|
Route::put('featured-groups/{featuredGroup}', [OnTicketFeaturedGroupController::class, 'update'])
|
||||||
|
->name('adminapp.featured-groups.update');
|
||||||
|
});
|
||||||
@@ -15,3 +15,5 @@ Route::prefix('tenants/{tenant:codigo}')->group(function (): void {
|
|||||||
Route::post('catalog-items/{catalogItem}/variant-options', [CatalogController::class, 'variantOptions']);
|
Route::post('catalog-items/{catalogItem}/variant-options', [CatalogController::class, 'variantOptions']);
|
||||||
Route::post('catalog-items', [CatalogController::class, 'store']);
|
Route::post('catalog-items', [CatalogController::class, 'store']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
require __DIR__.'/adminapp.php';
|
||||||
|
|||||||
47
app/Domains/Client/Controllers/ClientController.php
Normal file
47
app/Domains/Client/Controllers/ClientController.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Client\Controllers;
|
||||||
|
|
||||||
|
use App\Domains\Client\Models\Client;
|
||||||
|
use App\Domains\Client\Requests\StoreClientRequest;
|
||||||
|
use App\Domains\Client\Requests\UpdateClientRequest;
|
||||||
|
use App\Domains\Client\Resources\ClientResource;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
|
||||||
|
class ClientController extends Controller
|
||||||
|
{
|
||||||
|
public function index(): JsonResponse
|
||||||
|
{
|
||||||
|
return ClientResource::collection(
|
||||||
|
Client::query()->with('tenants')->latest()->paginateFromRequest()
|
||||||
|
)->response();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(StoreClientRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
return ClientResource::make(
|
||||||
|
Client::query()->create($request->validated())->load('tenants')
|
||||||
|
)->response()->setStatusCode(201);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(Client $client): ClientResource
|
||||||
|
{
|
||||||
|
return ClientResource::make($client->load('tenants'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(UpdateClientRequest $request, Client $client): ClientResource
|
||||||
|
{
|
||||||
|
$client->update($request->validated());
|
||||||
|
|
||||||
|
return ClientResource::make($client->fresh()->load('tenants'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Client $client): Response
|
||||||
|
{
|
||||||
|
$client->delete();
|
||||||
|
|
||||||
|
return response()->noContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
22
app/Domains/Client/Requests/StoreClientRequest.php
Normal file
22
app/Domains/Client/Requests/StoreClientRequest.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Client\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class StoreClientRequest extends FormRequest
|
||||||
|
{
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'code' => ['required', 'string', 'max:255', Rule::unique('clients', 'code')],
|
||||||
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
26
app/Domains/Client/Requests/UpdateClientRequest.php
Normal file
26
app/Domains/Client/Requests/UpdateClientRequest.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Client\Requests;
|
||||||
|
|
||||||
|
use App\Domains\Client\Models\Client;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class UpdateClientRequest extends FormRequest
|
||||||
|
{
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
/** @var Client|null $client */
|
||||||
|
$client = $this->route('client');
|
||||||
|
|
||||||
|
return [
|
||||||
|
'code' => ['sometimes', 'string', 'max:255', Rule::unique('clients', 'code')->ignore($client?->id)],
|
||||||
|
'name' => ['sometimes', 'string', 'max:255'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
26
app/Domains/Client/Resources/ClientResource.php
Normal file
26
app/Domains/Client/Resources/ClientResource.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Client\Resources;
|
||||||
|
|
||||||
|
use App\Domains\Client\Models\Client;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
/** @mixin Client */
|
||||||
|
class ClientResource extends JsonResource
|
||||||
|
{
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'code' => $this->code,
|
||||||
|
'name' => $this->name,
|
||||||
|
'tenants' => $this->whenLoaded('tenants', fn () => $this->tenants->map(fn ($tenant): array => [
|
||||||
|
'id' => $tenant->id,
|
||||||
|
'codigo' => $tenant->codigo,
|
||||||
|
'nombre' => $tenant->nombre,
|
||||||
|
'dominio' => $tenant->dominio,
|
||||||
|
])),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
6
app/Domains/Client/routes/api.php
Normal file
6
app/Domains/Client/routes/api.php
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Domains\Client\Controllers\ClientController;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
Route::apiResource('clients', ClientController::class);
|
||||||
@@ -10,6 +10,7 @@ use App\Domains\Desfile\Services\EntryService;
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
|
||||||
class EntryController extends Controller
|
class EntryController extends Controller
|
||||||
{
|
{
|
||||||
@@ -47,4 +48,10 @@ class EntryController extends Controller
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function destroyImage(Request $request): Response
|
||||||
|
{
|
||||||
|
$this->entryService->deleteImage($request->user()->tenant()->firstOrFail());
|
||||||
|
|
||||||
|
return response()->noContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,6 +166,19 @@ class EntryService
|
|||||||
return $this->current($tenant);
|
return $this->current($tenant);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deleteImage(Tenant $tenant): void
|
||||||
|
{
|
||||||
|
$attachment = DB::transaction(function () use ($tenant): Attachment {
|
||||||
|
$entry = $this->entryQuery($tenant)->lockForUpdate()->firstOrFail();
|
||||||
|
$attachment = $entry->allAttachments()->lockForUpdate()->firstOrFail();
|
||||||
|
$entry->allAttachments()->detach($attachment->id);
|
||||||
|
|
||||||
|
return $attachment;
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->deleteIfUnused($attachment);
|
||||||
|
}
|
||||||
|
|
||||||
/** @return Collection<string, ItemAttribute> */
|
/** @return Collection<string, ItemAttribute> */
|
||||||
private function itemAttributes(CatalogItem $entry): Collection
|
private function itemAttributes(CatalogItem $entry): Collection
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,4 +14,6 @@ Route::prefix('v1/adminapp/tenant/desfile')
|
|||||||
->name('adminapp.desfile.entries.image.replace');
|
->name('adminapp.desfile.entries.image.replace');
|
||||||
Route::patch('entries/image', [EntryController::class, 'updateImage'])
|
Route::patch('entries/image', [EntryController::class, 'updateImage'])
|
||||||
->name('adminapp.desfile.entries.image.update');
|
->name('adminapp.desfile.entries.image.update');
|
||||||
|
Route::delete('entries/image', [EntryController::class, 'destroyImage'])
|
||||||
|
->name('adminapp.desfile.entries.image.destroy');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Integration\Controllers;
|
||||||
|
|
||||||
|
use App\Domains\Integration\Models\Integration;
|
||||||
|
use App\Domains\Integration\Requests\StoreIntegrationRequest;
|
||||||
|
use App\Domains\Integration\Requests\UpdateIntegrationRequest;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
|
||||||
|
class IntegrationController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return response()->json(Integration::all());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(StoreIntegrationRequest $request)
|
||||||
|
{
|
||||||
|
$integration = Integration::create($request->validated());
|
||||||
|
|
||||||
|
return response()->json($integration, 201);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(Integration $integration)
|
||||||
|
{
|
||||||
|
return response()->json($integration);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(UpdateIntegrationRequest $request, Integration $integration)
|
||||||
|
{
|
||||||
|
$integration->update($request->validated());
|
||||||
|
|
||||||
|
return response()->json($integration->fresh());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Integration $integration)
|
||||||
|
{
|
||||||
|
$integration->delete();
|
||||||
|
|
||||||
|
return response()->noContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Integration\Controllers;
|
||||||
|
|
||||||
|
use App\Domains\Client\Models\Client;
|
||||||
|
use App\Domains\Integration\Requests\TelepagosWebhookRequest;
|
||||||
|
use App\Domains\Integration\Services\TelepagosWebhookService;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
class TelepagosWebhookController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle the incoming Telepagos webhook.
|
||||||
|
*/
|
||||||
|
public function handle(TelepagosWebhookRequest $request, Client $client, TelepagosWebhookService $service): JsonResponse
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$cashinId = $request->validated('id');
|
||||||
|
|
||||||
|
$service->handleWebhook($client, $cashinId);
|
||||||
|
|
||||||
|
return response()->json(['status' => 'success']);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'error',
|
||||||
|
'code' => 'integration.webhook_failed',
|
||||||
|
'message' => __('api.integration.webhook_failed'),
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
app/Domains/Integration/Requests/StoreIntegrationRequest.php
Normal file
24
app/Domains/Integration/Requests/StoreIntegrationRequest.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Integration\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class StoreIntegrationRequest extends FormRequest
|
||||||
|
{
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'integration_code' => ['required', 'string', 'unique:integrations,integration_code'],
|
||||||
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'url' => ['nullable', 'url', 'max:255'],
|
||||||
|
'integration_data_schema' => ['nullable', 'array'],
|
||||||
|
'requires_client_configuration' => ['sometimes', 'boolean'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
28
app/Domains/Integration/Requests/TelepagosWebhookRequest.php
Normal file
28
app/Domains/Integration/Requests/TelepagosWebhookRequest.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Integration\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class TelepagosWebhookRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => ['required', 'string'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Integration\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class UpdateIntegrationRequest extends FormRequest
|
||||||
|
{
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
$integration = $this->route('integration');
|
||||||
|
|
||||||
|
return [
|
||||||
|
'name' => ['sometimes', 'required', 'string', 'max:255'],
|
||||||
|
'url' => ['nullable', 'url', 'max:255'],
|
||||||
|
'integration_data_schema' => ['nullable', 'array'],
|
||||||
|
'requires_client_configuration' => ['sometimes', 'boolean'],
|
||||||
|
// the code shouldn't ideally be updatable, but if it is:
|
||||||
|
'integration_code' => ['sometimes', 'required', 'string', 'unique:integrations,integration_code,'.($integration->id ?? '')],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
namespace App\Domains\Integration\Services;
|
namespace App\Domains\Integration\Services;
|
||||||
|
|
||||||
use App\Domains\Client\Models\Client;
|
use App\Domains\Client\Models\Client;
|
||||||
use App\Domains\Tenant\Models\Tenant;
|
|
||||||
use App\Domains\Tenant\Models\WebsiteType;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Contracts\Mail\Factory as MailFactory;
|
use Illuminate\Contracts\Mail\Factory as MailFactory;
|
||||||
use Illuminate\Contracts\Mail\Mailer;
|
use Illuminate\Contracts\Mail\Mailer;
|
||||||
@@ -72,35 +70,24 @@ class MailService extends BaseIntegrationService
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function send(string|array $recipient, string $subject, string $content): void
|
||||||
* @param array<int, array{data: string, name: string, mime: string}> $attachments
|
{
|
||||||
*/
|
|
||||||
public function send(
|
|
||||||
string|array $recipient,
|
|
||||||
string $subject,
|
|
||||||
string $content,
|
|
||||||
Tenant|WebsiteType|null $brand = null,
|
|
||||||
array $attachments = [],
|
|
||||||
): void {
|
|
||||||
if (! $this->mailer || ! $this->tenant) {
|
if (! $this->mailer || ! $this->tenant) {
|
||||||
throw new Exception('MailService no está configurado. Llamá a forTenant() o forClient() primero.');
|
throw new Exception('MailService no está configurado. Llamá a forTenant() o forClient() primero.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$brand ??= $this->tenant;
|
$this->tenant->loadMissing(['headerLogo', 'footerLogo']);
|
||||||
$branding = $this->brandingFor($brand);
|
|
||||||
|
|
||||||
$html = Blade::render(
|
$html = Blade::render(
|
||||||
<<<'BLADE'
|
<<<'BLADE'
|
||||||
<x-mail.branded-layout :branding="$branding" :header-logo-url="$headerLogoUrl" :footer-logo-url="$footerLogoUrl">
|
<x-mail.branded-layout :tenant="$tenant" :header-logo-url="$headerLogoUrl" :footer-logo-url="$footerLogoUrl">
|
||||||
{!! $content !!}
|
{!! $content !!}
|
||||||
</x-mail.branded-layout>
|
</x-mail.branded-layout>
|
||||||
BLADE,
|
BLADE,
|
||||||
[
|
[
|
||||||
'branding' => $branding,
|
'tenant' => $this->tenant,
|
||||||
'headerLogoUrl' => $brand instanceof WebsiteType
|
'headerLogoUrl' => $this->tenant->headerLogo?->getTemporaryUrl(1440),
|
||||||
? $brand->siteLogo?->getTemporaryUrl(1440)
|
'footerLogoUrl' => $this->tenant->footerLogo?->getTemporaryUrl(1440),
|
||||||
: $brand->headerLogo?->getTemporaryUrl(1440),
|
|
||||||
'footerLogoUrl' => $brand->footerLogo?->getTemporaryUrl(1440),
|
|
||||||
'content' => $content,
|
'content' => $content,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -109,14 +96,6 @@ class MailService extends BaseIntegrationService
|
|||||||
->subject($subject)
|
->subject($subject)
|
||||||
->html($html);
|
->html($html);
|
||||||
|
|
||||||
foreach ($attachments as $attachment) {
|
|
||||||
$mail->attachData(
|
|
||||||
$attachment['data'],
|
|
||||||
$attachment['name'],
|
|
||||||
['mime' => $attachment['mime']],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->mailer->to($recipient)->send($mail);
|
$this->mailer->to($recipient)->send($mail);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,36 +106,6 @@ class MailService extends BaseIntegrationService
|
|||||||
: (string) config('mail.default');
|
: (string) config('mail.default');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return array{name: string, primary_color: string, body_color: string, background_color: string, surface_color: string, header_bg_color: string, footer_bg_color: string} */
|
|
||||||
private function brandingFor(Tenant|WebsiteType $brand): array
|
|
||||||
{
|
|
||||||
if ($brand instanceof WebsiteType) {
|
|
||||||
$brand->loadMissing(['siteLogo', 'footerLogo']);
|
|
||||||
|
|
||||||
return [
|
|
||||||
'name' => $brand->nombre,
|
|
||||||
'primary_color' => $brand->primary_color ?? '#FF7006',
|
|
||||||
'body_color' => $brand->body_color ?? '#666666',
|
|
||||||
'background_color' => $brand->background_color ?? '#f8f8f8',
|
|
||||||
'surface_color' => $brand->surface_color ?? '#ffffff',
|
|
||||||
'header_bg_color' => $brand->surface_color ?? '#ffffff',
|
|
||||||
'footer_bg_color' => $brand->login_header_footer_color ?? '#838383',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$brand->loadMissing(['headerLogo', 'footerLogo']);
|
|
||||||
|
|
||||||
return [
|
|
||||||
'name' => $brand->nombre,
|
|
||||||
'primary_color' => $brand->primary_color ?? '#6376f3',
|
|
||||||
'body_color' => '#334155',
|
|
||||||
'background_color' => '#f1f5f9',
|
|
||||||
'surface_color' => '#ffffff',
|
|
||||||
'header_bg_color' => $brand->header_bg_color ?? '#ffffff',
|
|
||||||
'footer_bg_color' => $brand->footer_bg_color ?? '#334155',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onSetup(): void
|
public function onSetup(): void
|
||||||
{
|
{
|
||||||
if (! $this->mailer || ! $this->clientContext) {
|
if (! $this->mailer || ! $this->clientContext) {
|
||||||
|
|||||||
212
app/Domains/Integration/Services/TelepagosWebhookService.php
Normal file
212
app/Domains/Integration/Services/TelepagosWebhookService.php
Normal file
@@ -0,0 +1,212 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Integration\Services;
|
||||||
|
|
||||||
|
use App\Domains\Client\Models\Client;
|
||||||
|
use App\Domains\Purchase\Models\Purchase;
|
||||||
|
use App\Domains\Purchase\Models\TelepagosPayment;
|
||||||
|
use App\Domains\Purchase\Models\TelepagosQr;
|
||||||
|
use App\Domains\Purchase\Services\CheckoutService;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class TelepagosWebhookService
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly CheckoutService $checkoutService,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the Telepagos webhook notification.
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function handleWebhook(Client $client, string $cashinId): void
|
||||||
|
{
|
||||||
|
Log::channel('telepagos')->info('Telepagos webhook received.', [
|
||||||
|
'client_code' => $client->code,
|
||||||
|
'cashin_id' => $cashinId,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$telepagosService = new TelepagosIntegrationService;
|
||||||
|
$telepagosService->forClient($client);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$details = $telepagosService->getCashinDetails($cashinId);
|
||||||
|
|
||||||
|
$qrOrderId = $details['data']['qr_order_id'] ?? $details['qr_order_id'] ?? null;
|
||||||
|
$amount = $this->normalizeAmount($details['data']['amount'] ?? $details['amount'] ?? 0);
|
||||||
|
$operationId = $details['data']['operation_id'] ?? $details['operation_id'] ?? null;
|
||||||
|
|
||||||
|
$paymentData = [
|
||||||
|
'compra_id' => null,
|
||||||
|
'matched_purchase_ids' => null,
|
||||||
|
'cuit_buyer' => $details['data']['buyer']['cuit'] ?? $details['buyer']['cuit'] ?? null,
|
||||||
|
'cvu_buyer' => $details['data']['buyer']['cvu'] ?? $details['buyer']['cvu'] ?? null,
|
||||||
|
'amount' => $amount,
|
||||||
|
'concept' => $details['data']['concept'] ?? $details['concept'] ?? null,
|
||||||
|
'operation' => $details['data']['operation'] ?? $details['operation'] ?? null,
|
||||||
|
'operation_id' => $details['data']['operation_id'] ?? $details['operation_id'] ?? null,
|
||||||
|
'transaction_id' => $details['data']['transaction_id'] ?? $details['transaction_id'] ?? null,
|
||||||
|
'qr_order_id' => $qrOrderId,
|
||||||
|
'link_id' => $details['data']['link_id'] ?? $details['link_id'] ?? null,
|
||||||
|
];
|
||||||
|
|
||||||
|
$transferenciaOperationIds = [1, 3, 11];
|
||||||
|
$qrOperationIds = [31, 37, 47];
|
||||||
|
|
||||||
|
$compra = null;
|
||||||
|
|
||||||
|
if (in_array((int) $operationId, $transferenciaOperationIds, true)) {
|
||||||
|
$cuit = $details['data']['buyer']['cuit'] ?? $details['buyer']['cuit'] ?? null;
|
||||||
|
|
||||||
|
if (! $cuit) {
|
||||||
|
Log::channel('telepagos')->warning('Telepagos webhook: CUIT not found for transfer.', [
|
||||||
|
'client_code' => $client->code,
|
||||||
|
'cashin_id' => $cashinId,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$dni = substr($cuit, 2, -1);
|
||||||
|
|
||||||
|
$tenantCodes = $client->tenants()->pluck('codigo');
|
||||||
|
$purchases = Purchase::whereIn('tenant_codigo', $tenantCodes)
|
||||||
|
->where('transfer_payer_dni', $dni)
|
||||||
|
->whereIn('status', [
|
||||||
|
Purchase::STATUS_CREATED,
|
||||||
|
Purchase::STATUS_PENDING_PAYMENT,
|
||||||
|
Purchase::STATUS_IN_REVIEW,
|
||||||
|
])
|
||||||
|
->where('payment_method', 'transfer')
|
||||||
|
->where('total', $amount)
|
||||||
|
->latest()
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$paymentData['matched_purchase_ids'] = $purchases->pluck('id')->all();
|
||||||
|
$compra = $purchases->count() === 1 ? $purchases->first() : null;
|
||||||
|
|
||||||
|
if (! $compra) {
|
||||||
|
if ($purchases->count() > 1) {
|
||||||
|
TelepagosPayment::create($paymentData);
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::channel('telepagos')->warning('Telepagos webhook: Expected exactly one matching purchase.', [
|
||||||
|
'client_code' => $client->code,
|
||||||
|
'cashin_id' => $cashinId,
|
||||||
|
'amount' => $amount,
|
||||||
|
'matches' => $purchases->count(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} elseif (in_array((int) $operationId, $qrOperationIds, true)) {
|
||||||
|
if (! $qrOrderId) {
|
||||||
|
Log::channel('telepagos')->warning('Telepagos webhook: qr_order_id not present in provider response.', [
|
||||||
|
'client_code' => $client->code,
|
||||||
|
'cashin_id' => $cashinId,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$telepagosQr = TelepagosQr::where('qr_order_id', $qrOrderId)->first();
|
||||||
|
|
||||||
|
if (! $telepagosQr) {
|
||||||
|
Log::channel('telepagos')->warning('Telepagos webhook: QR not found in database.', [
|
||||||
|
'client_code' => $client->code,
|
||||||
|
'cashin_id' => $cashinId,
|
||||||
|
'qr_order_id' => $qrOrderId,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$compra = $telepagosQr->compra;
|
||||||
|
|
||||||
|
if (! $compra) {
|
||||||
|
Log::channel('telepagos')->warning('Telepagos webhook: Purchase not found for QR.', [
|
||||||
|
'client_code' => $client->code,
|
||||||
|
'cashin_id' => $cashinId,
|
||||||
|
'qr_order_id' => $qrOrderId,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $client->tenants()->where('codigo', $compra->tenant_codigo)->exists()) {
|
||||||
|
Log::channel('telepagos')->warning('Telepagos webhook: Purchase does not belong to client.', [
|
||||||
|
'client_code' => $client->code,
|
||||||
|
'cashin_id' => $cashinId,
|
||||||
|
'purchase_id' => $compra->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! in_array($compra->status, [
|
||||||
|
Purchase::STATUS_PENDING_PAYMENT,
|
||||||
|
], true)) {
|
||||||
|
Log::channel('telepagos')->warning('Telepagos webhook: Purchase is not awaiting payment confirmation.', [
|
||||||
|
'client_code' => $client->code,
|
||||||
|
'cashin_id' => $cashinId,
|
||||||
|
'purchase_id' => $compra->id,
|
||||||
|
'purchase_status' => $compra->status,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$totalAmount = $this->normalizeAmount($compra->getTotalAmount());
|
||||||
|
|
||||||
|
if ($amount !== $totalAmount) {
|
||||||
|
Log::channel('telepagos')->warning('Telepagos webhook: Amount mismatch.', [
|
||||||
|
'client_code' => $client->code,
|
||||||
|
'cashin_id' => $cashinId,
|
||||||
|
'purchase_id' => $compra->id,
|
||||||
|
'cashin_amount' => $amount,
|
||||||
|
'purchase_amount' => $totalAmount,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log::channel('telepagos')->warning('Telepagos webhook: Unknown operation_id.', [
|
||||||
|
'client_code' => $client->code,
|
||||||
|
'cashin_id' => $cashinId,
|
||||||
|
'operation_id' => $operationId,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$paymentData['compra_id'] = $compra->id;
|
||||||
|
|
||||||
|
DB::transaction(function () use ($compra, $paymentData) {
|
||||||
|
TelepagosPayment::create($paymentData);
|
||||||
|
$this->checkoutService->confirmPaidPurchase($compra);
|
||||||
|
});
|
||||||
|
|
||||||
|
Log::channel('telepagos')->info('Telepagos webhook processed successfully.', [
|
||||||
|
'client_code' => $client->code,
|
||||||
|
'cashin_id' => $cashinId,
|
||||||
|
'purchase_id' => $compra->id,
|
||||||
|
'transaction_id' => $paymentData['transaction_id'],
|
||||||
|
]);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Log::channel('telepagos')->error('Telepagos webhook processing failed.', [
|
||||||
|
'client_code' => $client->code,
|
||||||
|
'cashin_id' => $cashinId,
|
||||||
|
'error' => $e->getMessage(),
|
||||||
|
]);
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function normalizeAmount(mixed $amount): string
|
||||||
|
{
|
||||||
|
return number_format((float) $amount, 2, '.', '');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,15 +16,18 @@ Gestiona integraciones externas disponibles y su configuración por cliente. Un
|
|||||||
- `BaseIntegrationService`: resuelve el cliente desde el tenant operativo y carga exclusivamente la configuración del cliente.
|
- `BaseIntegrationService`: resuelve el cliente desde el tenant operativo y carga exclusivamente la configuración del cliente.
|
||||||
- `MailService`: envío de correo usando la integración configurada.
|
- `MailService`: envío de correo usando la integración configurada.
|
||||||
- `TelepagosIntegrationService`: autenticación, caché de token, generación de QR y consulta de cobros.
|
- `TelepagosIntegrationService`: autenticación, caché de token, generación de QR y consulta de cobros.
|
||||||
|
- `TelepagosWebhookService`: procesa notificaciones recibidas desde Telepagos.
|
||||||
|
|
||||||
## Endpoints
|
## Endpoints
|
||||||
|
|
||||||
|
- CRUD global bajo `/integrations`.
|
||||||
- Consulta y configuración por cliente bajo `/clients/{client}/integrations`.
|
- Consulta y configuración por cliente bajo `/clients/{client}/integrations`.
|
||||||
|
- `POST /webhooks/telepagos/{client}` para notificaciones del proveedor.
|
||||||
|
|
||||||
## Logging de Telepagos
|
## Logging de Telepagos
|
||||||
|
|
||||||
Los eventos de autenticación, QR y consultas de cuenta se escriben en el canal diario `telepagos`, separado del log general. Los archivos se generan en `storage/logs/telepagos/telepagos-YYYY-MM-DD.log`; el nivel y la retención se configuran con `TELEPAGOS_LOG_LEVEL` y `TELEPAGOS_LOG_DAYS`. Tokens y credenciales se eliminan del contexto antes de registrar respuestas del proveedor.
|
Los eventos de autenticación, QR, consultas de cuenta y procesamiento de webhooks se escriben en el canal diario `telepagos`, separado del log general. Los archivos se generan en `storage/logs/telepagos/telepagos-YYYY-MM-DD.log`; el nivel y la retención se configuran con `TELEPAGOS_LOG_LEVEL` y `TELEPAGOS_LOG_DAYS`. Tokens y credenciales se eliminan del contexto antes de registrar respuestas del proveedor.
|
||||||
|
|
||||||
## Dependencias y reglas
|
## Dependencias y reglas
|
||||||
|
|
||||||
Se integra con `Client`, `Tenant` y con el checkout de `Purchase`. `Notification` utiliza `MailService`. El tenant conserva el contexto operativo y de branding, pero nunca es dueño de credenciales. Las credenciales no se exponen en respuestas ni logs.
|
Se integra con `Client`, `Tenant` y con el checkout de `Purchase`. `Notification` utiliza `MailService`. El tenant conserva el contexto operativo y de branding, pero nunca es dueño de credenciales. Las credenciales no se exponen en respuestas ni logs; los webhooks deben validar su contrato antes de alterar una compra.
|
||||||
|
|||||||
@@ -1,10 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Domains\Integration\Controllers\ClientIntegrationController;
|
use App\Domains\Integration\Controllers\ClientIntegrationController;
|
||||||
|
use App\Domains\Integration\Controllers\IntegrationController;
|
||||||
|
use App\Domains\Integration\Controllers\TelepagosWebhookController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
Route::group(['prefix' => 'integrations'], function () {
|
||||||
|
Route::get('/', [IntegrationController::class, 'index']);
|
||||||
|
Route::post('/', [IntegrationController::class, 'store']);
|
||||||
|
Route::get('/{integration}', [IntegrationController::class, 'show']);
|
||||||
|
Route::put('/{integration}', [IntegrationController::class, 'update']);
|
||||||
|
Route::delete('/{integration}', [IntegrationController::class, 'destroy']);
|
||||||
|
});
|
||||||
|
|
||||||
Route::group(['prefix' => 'clients/{client}/integrations'], function () {
|
Route::group(['prefix' => 'clients/{client}/integrations'], function () {
|
||||||
Route::get('/', [ClientIntegrationController::class, 'index']);
|
Route::get('/', [ClientIntegrationController::class, 'index']);
|
||||||
Route::get('/{integration_code}', [ClientIntegrationController::class, 'show']);
|
Route::get('/{integration_code}', [ClientIntegrationController::class, 'show']);
|
||||||
Route::put('/{integration_code}', [ClientIntegrationController::class, 'store']);
|
Route::put('/{integration_code}', [ClientIntegrationController::class, 'store']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::post('webhooks/telepagos/{client}', [TelepagosWebhookController::class, 'handle']);
|
||||||
|
|||||||
32
app/Domains/MailTest/Controllers/MailTestController.php
Normal file
32
app/Domains/MailTest/Controllers/MailTestController.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\MailTest\Controllers;
|
||||||
|
|
||||||
|
use App\Domains\MailTest\Requests\SendTestMailRequest;
|
||||||
|
use App\Domains\MailTest\Services\MailTestService;
|
||||||
|
use App\Domains\Tenant\Models\Tenant;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
class MailTestController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
protected MailTestService $mailTestService,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function __invoke(SendTestMailRequest $request, string $tenantCode): JsonResponse
|
||||||
|
{
|
||||||
|
$tenant = Tenant::query()
|
||||||
|
->where('codigo', $tenantCode)
|
||||||
|
->firstOrFail();
|
||||||
|
|
||||||
|
return response()->json(
|
||||||
|
$this->mailTestService->send(
|
||||||
|
$tenant,
|
||||||
|
$request->validated('to'),
|
||||||
|
$request->validated('subject'),
|
||||||
|
$request->validated('message'),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
40
app/Domains/MailTest/Mailables/TestMail.php
Normal file
40
app/Domains/MailTest/Mailables/TestMail.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\MailTest\Mailables;
|
||||||
|
|
||||||
|
use App\Domains\Tenant\Models\Tenant;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Mail\Mailable;
|
||||||
|
use Illuminate\Mail\Mailables\Content;
|
||||||
|
use Illuminate\Mail\Mailables\Envelope;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class TestMail extends Mailable
|
||||||
|
{
|
||||||
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
public readonly string $mailSubject,
|
||||||
|
public readonly string $mailMessage,
|
||||||
|
public readonly Tenant $tenant,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function envelope(): Envelope
|
||||||
|
{
|
||||||
|
return new Envelope(subject: $this->mailSubject);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function content(): Content
|
||||||
|
{
|
||||||
|
$this->tenant->loadMissing(['headerLogo', 'footerLogo']);
|
||||||
|
|
||||||
|
return new Content(
|
||||||
|
view: 'mail.test',
|
||||||
|
with: [
|
||||||
|
'tenant' => $this->tenant,
|
||||||
|
'headerLogoUrl' => $this->tenant->headerLogo?->getTemporaryUrl(1440),
|
||||||
|
'footerLogoUrl' => $this->tenant->footerLogo?->getTemporaryUrl(1440),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
25
app/Domains/MailTest/Requests/SendTestMailRequest.php
Normal file
25
app/Domains/MailTest/Requests/SendTestMailRequest.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\MailTest\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class SendTestMailRequest extends FormRequest
|
||||||
|
{
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, array<int, string>>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'to' => ['required', 'string', 'email', 'max:255'],
|
||||||
|
'subject' => ['nullable', 'string', 'max:255'],
|
||||||
|
'message' => ['nullable', 'string', 'max:5000'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
35
app/Domains/MailTest/Services/MailTestService.php
Normal file
35
app/Domains/MailTest/Services/MailTestService.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\MailTest\Services;
|
||||||
|
|
||||||
|
use App\Domains\Integration\Services\MailService;
|
||||||
|
use App\Domains\Tenant\Models\Tenant;
|
||||||
|
|
||||||
|
class MailTestService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function send(Tenant $tenant, string $recipient, ?string $subject = null, ?string $message = null): array
|
||||||
|
{
|
||||||
|
$subject ??= 'Prueba de correo de Shopit';
|
||||||
|
$message ??= 'Este es un correo de prueba enviado desde Shopit.';
|
||||||
|
|
||||||
|
$mailService = (new MailService)->forTenant($tenant->codigo);
|
||||||
|
$mailService->send(
|
||||||
|
$recipient,
|
||||||
|
$subject,
|
||||||
|
'<h1 style="margin: 0 0 20px;">'.e($subject).'</h1>'
|
||||||
|
.'<p>'.nl2br(e($message)).'</p>',
|
||||||
|
);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'code' => 'mail.test_sent',
|
||||||
|
'message' => __('api.mail.test_sent'),
|
||||||
|
'recipient' => $recipient,
|
||||||
|
'tenant_code' => $tenant->codigo,
|
||||||
|
'mailer' => $mailService->mailerName(),
|
||||||
|
'sent_at' => now()->toIso8601String(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
24
app/Domains/MailTest/documentacion/README.md
Normal file
24
app/Domains/MailTest/documentacion/README.md
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Dominio MailTest
|
||||||
|
|
||||||
|
## Propósito
|
||||||
|
|
||||||
|
Ofrece una operación técnica para verificar la configuración de correo de un tenant sin ejecutar un flujo funcional real.
|
||||||
|
|
||||||
|
## Componentes
|
||||||
|
|
||||||
|
- `MailTestController`: endpoint invocable de envío.
|
||||||
|
- `SendTestMailRequest`: valida destinatario y contenido requerido.
|
||||||
|
- `MailTestService`: coordina el envío de prueba.
|
||||||
|
- `TestMail`: mailable utilizado para construir el mensaje.
|
||||||
|
|
||||||
|
## Endpoint
|
||||||
|
|
||||||
|
- `POST /{tenant_code}/mail-test/send`.
|
||||||
|
|
||||||
|
## Dependencias
|
||||||
|
|
||||||
|
Usa la configuración de correo del dominio `Integration` y resuelve el tenant indicado.
|
||||||
|
|
||||||
|
## Consideraciones
|
||||||
|
|
||||||
|
Es una herramienta de diagnóstico. Debe restringirse o deshabilitarse en entornos donde no corresponda exponer envíos de prueba, y nunca debe registrar credenciales.
|
||||||
6
app/Domains/MailTest/routes/api.php
Normal file
6
app/Domains/MailTest/routes/api.php
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Domains\MailTest\Controllers\MailTestController;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
Route::post('{tenant_code}/mail-test/send', MailTestController::class);
|
||||||
79
app/Domains/Menu/Controllers/MenuController.php
Normal file
79
app/Domains/Menu/Controllers/MenuController.php
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Menu\Controllers;
|
||||||
|
|
||||||
|
use App\Domains\Menu\Models\Menu;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class MenuController extends Controller
|
||||||
|
{
|
||||||
|
public function index(): JsonResponse
|
||||||
|
{
|
||||||
|
$menues = Menu::all();
|
||||||
|
|
||||||
|
return response()->json($menues);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'code' => 'required|string|unique:menues,code',
|
||||||
|
'label' => 'required|string|max:255',
|
||||||
|
'parent_menu_code' => [
|
||||||
|
'nullable',
|
||||||
|
'string',
|
||||||
|
Rule::exists('menues', 'code'),
|
||||||
|
'different:code',
|
||||||
|
],
|
||||||
|
'content_type' => [
|
||||||
|
'sometimes',
|
||||||
|
Rule::in([Menu::CONTENT_TYPE_STATIC, Menu::CONTENT_TYPE_DYNAMIC]),
|
||||||
|
],
|
||||||
|
'static_content_schema' => 'required_if:content_type,static|nullable|array',
|
||||||
|
'route' => 'required|string',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$menu = Menu::create($validated);
|
||||||
|
|
||||||
|
return response()->json($menu, 201);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(Menu $menu): JsonResponse
|
||||||
|
{
|
||||||
|
return response()->json($menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, Menu $menu): JsonResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'code' => 'sometimes|required|string|unique:menues,code,'.$menu->id,
|
||||||
|
'label' => 'sometimes|required|string|max:255',
|
||||||
|
'parent_menu_code' => [
|
||||||
|
'nullable',
|
||||||
|
'string',
|
||||||
|
Rule::exists('menues', 'code'),
|
||||||
|
Rule::notIn([$menu->code]),
|
||||||
|
],
|
||||||
|
'content_type' => [
|
||||||
|
'sometimes',
|
||||||
|
Rule::in([Menu::CONTENT_TYPE_STATIC, Menu::CONTENT_TYPE_DYNAMIC]),
|
||||||
|
],
|
||||||
|
'static_content_schema' => 'required_if:content_type,static|nullable|array',
|
||||||
|
'route' => 'sometimes|required|string',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$menu->update($validated);
|
||||||
|
|
||||||
|
return response()->json($menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Menu $menu): JsonResponse
|
||||||
|
{
|
||||||
|
$menu->delete();
|
||||||
|
|
||||||
|
return response()->json(null, 204);
|
||||||
|
}
|
||||||
|
}
|
||||||
32
app/Domains/Menu/Controllers/TenantMenuController.php
Normal file
32
app/Domains/Menu/Controllers/TenantMenuController.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Menu\Controllers;
|
||||||
|
|
||||||
|
use App\Domains\Menu\Models\Menu;
|
||||||
|
use App\Domains\Menu\Requests\StoreTenantMenuRequest;
|
||||||
|
use App\Domains\Menu\Services\TenantMenuService;
|
||||||
|
use App\Domains\Tenant\Models\Tenant;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
class TenantMenuController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct(private readonly TenantMenuService $tenantMenuService) {}
|
||||||
|
|
||||||
|
public function store(
|
||||||
|
StoreTenantMenuRequest $request,
|
||||||
|
string $tenantCode,
|
||||||
|
string $menuCode,
|
||||||
|
): JsonResponse {
|
||||||
|
$tenant = Tenant::query()->where('codigo', $tenantCode)->firstOrFail();
|
||||||
|
$menu = Menu::query()->where('code', $menuCode)->firstOrFail();
|
||||||
|
|
||||||
|
$tenantMenu = $this->tenantMenuService->configure(
|
||||||
|
$tenant,
|
||||||
|
$menu,
|
||||||
|
$request->validated('static_content'),
|
||||||
|
);
|
||||||
|
|
||||||
|
return response()->json($tenantMenu);
|
||||||
|
}
|
||||||
|
}
|
||||||
49
app/Domains/Menu/Requests/StoreTenantMenuRequest.php
Normal file
49
app/Domains/Menu/Requests/StoreTenantMenuRequest.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Menu\Requests;
|
||||||
|
|
||||||
|
use App\Domains\Menu\Models\Menu;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
|
class StoreTenantMenuRequest extends FormRequest
|
||||||
|
{
|
||||||
|
private ?Menu $menuModel = null;
|
||||||
|
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function prepareForValidation(): void
|
||||||
|
{
|
||||||
|
$this->menuModel = Menu::query()
|
||||||
|
->where('code', $this->route('menu_code'))
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (! $this->menuModel) {
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'menu_code' => __('api.menu.not_found'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
if ($this->menuModel?->content_type !== Menu::CONTENT_TYPE_STATIC) {
|
||||||
|
return [
|
||||||
|
'static_content' => ['nullable', 'array'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$rules = [
|
||||||
|
'static_content' => ['required', 'array'],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($this->menuModel->static_content_schema as $field => $rule) {
|
||||||
|
$rules["static_content.{$field}"] = $rule;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
26
app/Domains/Menu/Services/TenantMenuService.php
Normal file
26
app/Domains/Menu/Services/TenantMenuService.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Menu\Services;
|
||||||
|
|
||||||
|
use App\Domains\Menu\Models\Menu;
|
||||||
|
use App\Domains\Menu\Models\TenantMenu;
|
||||||
|
use App\Domains\Tenant\Models\Tenant;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class TenantMenuService
|
||||||
|
{
|
||||||
|
public function configure(Tenant $tenant, Menu $menu, ?array $staticContent): TenantMenu
|
||||||
|
{
|
||||||
|
return DB::transaction(fn () => TenantMenu::query()->updateOrCreate(
|
||||||
|
[
|
||||||
|
'tenant_code' => $tenant->codigo,
|
||||||
|
'menu_code' => $menu->code,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'static_content' => $menu->content_type === Menu::CONTENT_TYPE_STATIC
|
||||||
|
? $staticContent
|
||||||
|
: null,
|
||||||
|
],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,15 @@ Define menús disponibles y permite configurar su contenido para cada tenant y r
|
|||||||
- `TenantMenu`: configuración específica por tenant, incluyendo contenido estático cuando corresponde.
|
- `TenantMenu`: configuración específica por tenant, incluyendo contenido estático cuando corresponde.
|
||||||
- `MenuRole`: asociación entre menú y rol autorizado.
|
- `MenuRole`: asociación entre menú y rol autorizado.
|
||||||
|
|
||||||
|
## Servicios
|
||||||
|
|
||||||
|
`TenantMenuService::configure()` crea o actualiza atómicamente la configuración de un menú para un tenant. Solo conserva `static_content` cuando el menú fue definido como contenido estático.
|
||||||
|
|
||||||
|
## Endpoints
|
||||||
|
|
||||||
|
- Recurso REST `/menues` mediante `MenuController`.
|
||||||
|
- `POST /{tenant_code}/menues/{menu_code}` para configurar un menú del tenant.
|
||||||
|
|
||||||
## Dependencias y reglas
|
## Dependencias y reglas
|
||||||
|
|
||||||
Depende de `Tenant` y `Authorization`. Los menús se configuran mediante seeders y relaciones internas; no se exponen endpoints públicos de administración.
|
Depende de `Tenant` y `Authorization`. Los códigos de menú y tenant forman la identidad lógica de la configuración; el contenido enviado debe respetar el tipo definido por `Menu`.
|
||||||
|
|||||||
12
app/Domains/Menu/routes/api.php
Normal file
12
app/Domains/Menu/routes/api.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Domains\Menu\Controllers\MenuController;
|
||||||
|
use App\Domains\Menu\Controllers\TenantMenuController;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
Route::apiResource('menues', MenuController::class);
|
||||||
|
|
||||||
|
Route::post(
|
||||||
|
'{tenant_code}/menues/{menu_code}',
|
||||||
|
[TenantMenuController::class, 'store']
|
||||||
|
);
|
||||||
20
app/Domains/Notification/Events/TicketsAvailable.php
Normal file
20
app/Domains/Notification/Events/TicketsAvailable.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Notification\Events;
|
||||||
|
|
||||||
|
use App\Domains\Purchase\Models\Purchase;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class TicketsAvailable
|
||||||
|
{
|
||||||
|
use Dispatchable, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<int, int> $ticketIds
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
public readonly Purchase $purchase,
|
||||||
|
public readonly array $ticketIds,
|
||||||
|
) {}
|
||||||
|
}
|
||||||
@@ -6,6 +6,8 @@ use App\Domains\Notification\Events\PasswordResetRequested;
|
|||||||
use App\Domains\Notification\Services\NotificationMailService;
|
use App\Domains\Notification\Services\NotificationMailService;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueueAfterCommit;
|
use Illuminate\Contracts\Queue\ShouldQueueAfterCommit;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
class SendPasswordResetEmail implements ShouldQueueAfterCommit
|
class SendPasswordResetEmail implements ShouldQueueAfterCommit
|
||||||
{
|
{
|
||||||
@@ -20,10 +22,21 @@ class SendPasswordResetEmail implements ShouldQueueAfterCommit
|
|||||||
|
|
||||||
public function handle(PasswordResetRequested $event): void
|
public function handle(PasswordResetRequested $event): void
|
||||||
{
|
{
|
||||||
app(NotificationMailService::class)->sendPasswordResetCode(
|
try {
|
||||||
$event->attemptId,
|
app(NotificationMailService::class)->sendPasswordResetCode(
|
||||||
$event->tenantCode,
|
$event->attemptId,
|
||||||
$event->channel,
|
$event->tenantCode,
|
||||||
);
|
$event->channel,
|
||||||
|
);
|
||||||
|
} catch (Throwable $exception) {
|
||||||
|
Log::error('Failed to send password reset email.', [
|
||||||
|
'attempt_id' => $event->attemptId,
|
||||||
|
'tenant_code' => $event->tenantCode,
|
||||||
|
'channel' => $event->channel,
|
||||||
|
'exception' => $exception,
|
||||||
|
]);
|
||||||
|
|
||||||
|
throw $exception;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use App\Domains\Purchase\Events\PurchasePaid;
|
|||||||
use Illuminate\Contracts\Queue\ShouldQueueAfterCommit;
|
use Illuminate\Contracts\Queue\ShouldQueueAfterCommit;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
|
||||||
class SendPurchaseConfirmedEmail implements ShouldQueueAfterCommit
|
class SendPurchasePaidEmail implements ShouldQueueAfterCommit
|
||||||
{
|
{
|
||||||
use InteractsWithQueue;
|
use InteractsWithQueue;
|
||||||
|
|
||||||
@@ -20,6 +20,6 @@ class SendPurchaseConfirmedEmail implements ShouldQueueAfterCommit
|
|||||||
|
|
||||||
public function handle(PurchasePaid $event): void
|
public function handle(PurchasePaid $event): void
|
||||||
{
|
{
|
||||||
app(NotificationMailService::class)->sendPurchaseConfirmed($event->purchaseId);
|
app(NotificationMailService::class)->sendPurchasePaid($event->purchase->getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Notification\Listeners;
|
||||||
|
|
||||||
|
use App\Domains\Notification\Events\TicketsAvailable;
|
||||||
|
use App\Domains\Notification\Services\NotificationMailService;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueueAfterCommit;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
|
||||||
|
class SendTicketsAvailableEmail implements ShouldQueueAfterCommit
|
||||||
|
{
|
||||||
|
use InteractsWithQueue;
|
||||||
|
|
||||||
|
public string $queue = 'emails';
|
||||||
|
|
||||||
|
public int $tries = 3;
|
||||||
|
|
||||||
|
/** @var array<int, int> */
|
||||||
|
public array $backoff = [30, 120, 300];
|
||||||
|
|
||||||
|
public function handle(TicketsAvailable $event): void
|
||||||
|
{
|
||||||
|
app(NotificationMailService::class)->sendTicketsAvailable($event->purchase->getKey(), $event->ticketIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,43 +9,28 @@ use App\Domains\Notification\Events\PasswordResetRequested;
|
|||||||
use App\Domains\Purchase\Models\Purchase;
|
use App\Domains\Purchase\Models\Purchase;
|
||||||
use App\Domains\Tenant\Models\Tenant;
|
use App\Domains\Tenant\Models\Tenant;
|
||||||
use App\Domains\Ticket\Models\Ticket;
|
use App\Domains\Ticket\Models\Ticket;
|
||||||
use App\Domains\Ticket\Services\TicketPdfService;
|
|
||||||
use App\Domains\Ticket\Services\TicketPresentationResolver;
|
use App\Domains\Ticket\Services\TicketPresentationResolver;
|
||||||
use Closure;
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
class NotificationMailService
|
class NotificationMailService
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly MailService $mailService,
|
private readonly MailService $mailService,
|
||||||
private readonly TicketPdfService $ticketPdfService,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function sendWelcome(int $userId, string $tenantCode): void
|
public function sendWelcome(int $userId, string $tenantCode): void
|
||||||
{
|
{
|
||||||
$this->sendLogged('welcome', [
|
$tenant = Tenant::query()->where('codigo', $tenantCode)->firstOrFail();
|
||||||
'user_id' => $userId,
|
$user = User::query()->findOrFail($userId);
|
||||||
'tenant_code' => $tenantCode,
|
|
||||||
], function () use ($userId, $tenantCode): array {
|
|
||||||
$tenant = Tenant::query()->with('websiteType')->where('codigo', $tenantCode)->firstOrFail();
|
|
||||||
$user = User::query()->findOrFail($userId);
|
|
||||||
$brand = $tenant->websiteType ?? $tenant;
|
|
||||||
|
|
||||||
$this->mailService
|
$this->mailService
|
||||||
->forTenant($tenantCode)
|
->forTenant($tenantCode)
|
||||||
->send(
|
->send(
|
||||||
$user->email,
|
$user->email,
|
||||||
"Bienvenido a {$brand->nombre}",
|
"Bienvenido a {$tenant->nombre}",
|
||||||
view('mail.notifications.welcome', compact('brand', 'user'))->render(),
|
view('mail.notifications.welcome', compact('tenant', 'user'))->render(),
|
||||||
$brand,
|
);
|
||||||
);
|
|
||||||
|
|
||||||
return [
|
|
||||||
'brand_type' => $tenant->websiteType === null ? 'tenant' : 'website_type',
|
|
||||||
];
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendPasswordResetCode(
|
public function sendPasswordResetCode(
|
||||||
@@ -53,161 +38,95 @@ class NotificationMailService
|
|||||||
string $tenantCode,
|
string $tenantCode,
|
||||||
string $channel = PasswordResetRequested::CHANNEL_STOREFRONT,
|
string $channel = PasswordResetRequested::CHANNEL_STOREFRONT,
|
||||||
): void {
|
): void {
|
||||||
$context = [
|
$tenant = Tenant::query()
|
||||||
'attempt_id' => $attemptId,
|
->with('websiteType')
|
||||||
'tenant_code' => $tenantCode,
|
->where('codigo', $tenantCode)
|
||||||
'channel' => $channel,
|
->firstOrFail();
|
||||||
];
|
$attempt = ResetPasswordAttempt::query()
|
||||||
|
->with('user')
|
||||||
|
->findOrFail($attemptId);
|
||||||
|
|
||||||
$this->sendLogged('password_reset', $context, function () use ($attemptId, $tenantCode, $channel, $context): ?array {
|
if ($attempt->status !== ResetPasswordAttempt::STATUS_PENDING) {
|
||||||
$tenant = Tenant::query()
|
Log::warning('Password reset email was skipped because the attempt is no longer pending.', [
|
||||||
->with('websiteType')
|
'attempt_id' => $attemptId,
|
||||||
->where('codigo', $tenantCode)
|
'tenant_code' => $tenantCode,
|
||||||
->firstOrFail();
|
'attempt_status' => $attempt->status,
|
||||||
$attempt = ResetPasswordAttempt::query()
|
]);
|
||||||
->with('user')
|
|
||||||
->findOrFail($attemptId);
|
|
||||||
|
|
||||||
if ($attempt->status !== ResetPasswordAttempt::STATUS_PENDING) {
|
return;
|
||||||
$this->logSkipped('password_reset', array_merge($context, [
|
}
|
||||||
'reason' => 'attempt_not_pending',
|
|
||||||
'attempt_status' => $attempt->status,
|
|
||||||
'user_id' => $attempt->user_id,
|
|
||||||
]));
|
|
||||||
|
|
||||||
return null;
|
$recoveryDomain = match ($channel) {
|
||||||
}
|
PasswordResetRequested::CHANNEL_ADMINAPP => $tenant->websiteType?->dominio,
|
||||||
|
PasswordResetRequested::CHANNEL_SCANNER => $tenant->websiteType?->scanner_domain,
|
||||||
|
default => $tenant->dominio,
|
||||||
|
};
|
||||||
|
$recoveryBasePath = $channel === PasswordResetRequested::CHANNEL_STOREFRONT
|
||||||
|
&& $tenant->base_path !== '/'
|
||||||
|
? $tenant->base_path
|
||||||
|
: '';
|
||||||
|
$recoveryQuery = ['email' => $attempt->user->email];
|
||||||
|
if (
|
||||||
|
$channel === PasswordResetRequested::CHANNEL_SCANNER
|
||||||
|
&& $attempt->reason === ResetPasswordAttempt::REASON_STAFF_CREATED
|
||||||
|
) {
|
||||||
|
$recoveryQuery['code'] = $attempt->codigo;
|
||||||
|
}
|
||||||
|
$recoveryUrl = $recoveryDomain === null
|
||||||
|
? null
|
||||||
|
: 'https://'.$recoveryDomain.$recoveryBasePath.'/recuperar-contrasena/codigo?'.http_build_query($recoveryQuery);
|
||||||
|
|
||||||
$recoveryDomain = match ($channel) {
|
$this->mailService
|
||||||
PasswordResetRequested::CHANNEL_ADMINAPP => $tenant->websiteType?->dominio,
|
->forTenant($tenantCode)
|
||||||
PasswordResetRequested::CHANNEL_SCANNER => $tenant->websiteType?->scanner_domain,
|
->send(
|
||||||
default => $tenant->dominio,
|
$attempt->user->email,
|
||||||
};
|
"Código para recuperar tu contraseña - {$tenant->nombre}",
|
||||||
$recoveryBasePath = $channel === PasswordResetRequested::CHANNEL_STOREFRONT
|
view('mail.notifications.password-reset', compact('tenant', 'attempt', 'recoveryUrl'))->render(),
|
||||||
&& $tenant->base_path !== '/'
|
);
|
||||||
? $tenant->base_path
|
|
||||||
: '';
|
|
||||||
$recoveryQuery = ['email' => $attempt->user->email];
|
|
||||||
if (
|
|
||||||
$channel === PasswordResetRequested::CHANNEL_SCANNER
|
|
||||||
&& $attempt->reason === ResetPasswordAttempt::REASON_STAFF_CREATED
|
|
||||||
) {
|
|
||||||
$recoveryQuery['code'] = $attempt->codigo;
|
|
||||||
}
|
|
||||||
$recoveryUrl = $recoveryDomain === null
|
|
||||||
? null
|
|
||||||
: 'https://'.$recoveryDomain.$recoveryBasePath.'/recuperar-contrasena/codigo?'.http_build_query($recoveryQuery);
|
|
||||||
$brand = $tenant->websiteType ?? $tenant;
|
|
||||||
|
|
||||||
$this->mailService
|
|
||||||
->forTenant($tenantCode)
|
|
||||||
->send(
|
|
||||||
$attempt->user->email,
|
|
||||||
"Código para recuperar tu contraseña - {$brand->nombre}",
|
|
||||||
view('mail.notifications.password-reset', [
|
|
||||||
'attempt' => $attempt,
|
|
||||||
'recoveryUrl' => $recoveryUrl,
|
|
||||||
'brand' => $brand,
|
|
||||||
])->render(),
|
|
||||||
$brand,
|
|
||||||
);
|
|
||||||
|
|
||||||
return [
|
|
||||||
'user_id' => $attempt->user_id,
|
|
||||||
'recovery_domain_available' => $recoveryDomain !== null,
|
|
||||||
];
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendPurchaseConfirmed(int $purchaseId): void
|
public function sendPurchasePaid(int $purchaseId): void
|
||||||
{
|
{
|
||||||
$context = ['purchase_id' => $purchaseId];
|
$purchase = Purchase::query()
|
||||||
|
->with(['tenant', 'user', 'items'])
|
||||||
|
->findOrFail($purchaseId);
|
||||||
|
|
||||||
$this->sendLogged('purchase_confirmed', $context, function () use ($purchaseId, $context): ?array {
|
$this->mailService
|
||||||
$purchase = Purchase::query()
|
->forTenant($purchase->tenant_codigo)
|
||||||
->with(['tenant', 'user', 'items'])
|
->send(
|
||||||
->find($purchaseId);
|
$this->recipientFor($purchase),
|
||||||
|
"Pago confirmado - Compra #{$purchase->getKey()}",
|
||||||
|
view('mail.notifications.purchase-paid', compact('purchase'))->render(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if ($purchase === null) {
|
/** @param array<int, int> $ticketIds */
|
||||||
$this->logSkipped('purchase_confirmed', array_merge($context, [
|
public function sendTicketsAvailable(int $purchaseId, array $ticketIds): void
|
||||||
'reason' => 'purchase_not_found',
|
{
|
||||||
'missing_model' => Purchase::class,
|
$purchase = Purchase::query()->with(['tenant', 'user'])->findOrFail($purchaseId);
|
||||||
]));
|
/** @var Collection<int, Ticket> $tickets */
|
||||||
|
$tickets = Ticket::query()
|
||||||
|
->where('tenant_code', $purchase->tenant_codigo)
|
||||||
|
->where('user_id', $purchase->user_id)
|
||||||
|
->whereKey($ticketIds)
|
||||||
|
->with(TicketPresentationResolver::RELATIONS)
|
||||||
|
->get();
|
||||||
|
|
||||||
return null;
|
if ($tickets->isEmpty()) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/** @var Collection<int, Ticket> $tickets */
|
$this->mailService
|
||||||
$tickets = Ticket::query()
|
->forTenant($purchase->tenant_codigo)
|
||||||
->where('source_purchase_id', $purchase->getKey())
|
->send(
|
||||||
->where('tenant_code', $purchase->tenant_codigo)
|
$this->recipientFor($purchase),
|
||||||
->with(TicketPresentationResolver::RELATIONS)
|
'Tus tickets ya están disponibles',
|
||||||
->get();
|
view('mail.notifications.tickets-available', compact('purchase', 'tickets'))->render(),
|
||||||
$attachments = $tickets->isEmpty()
|
);
|
||||||
? []
|
|
||||||
: [[
|
|
||||||
'data' => $this->ticketPdfService->contents($purchase->tenant, $tickets),
|
|
||||||
'name' => $this->ticketPdfService->filename($tickets),
|
|
||||||
'mime' => 'application/pdf',
|
|
||||||
]];
|
|
||||||
|
|
||||||
$this->mailService
|
|
||||||
->forTenant($purchase->tenant_codigo)
|
|
||||||
->send(
|
|
||||||
$this->recipientFor($purchase),
|
|
||||||
"Compra confirmada - Compra #{$purchase->getKey()}",
|
|
||||||
view('mail.notifications.purchase-confirmed', compact('purchase', 'tickets'))->render(),
|
|
||||||
attachments: $attachments,
|
|
||||||
);
|
|
||||||
|
|
||||||
return [
|
|
||||||
'tenant_code' => $purchase->tenant_codigo,
|
|
||||||
'user_id' => $purchase->user_id,
|
|
||||||
'purchase_status' => $purchase->status,
|
|
||||||
'purchase_item_count' => $purchase->items->count(),
|
|
||||||
'ticket_count' => $tickets->count(),
|
|
||||||
'ticket_ids' => $tickets->modelKeys(),
|
|
||||||
];
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function recipientFor(Purchase $purchase): string
|
private function recipientFor(Purchase $purchase): string
|
||||||
{
|
{
|
||||||
return (string) ($purchase->email ?: $purchase->user?->email);
|
return (string) ($purchase->email ?: $purchase->user?->email);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<string, mixed> $context
|
|
||||||
* @param Closure(): (array<string, mixed>|null) $send
|
|
||||||
*/
|
|
||||||
private function sendLogged(string $emailType, array $context, Closure $send): void
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$resultContext = $send();
|
|
||||||
|
|
||||||
if ($resultContext === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::channel('emails')->info('Notification email sent.', array_merge($context, $resultContext, [
|
|
||||||
'email_type' => $emailType,
|
|
||||||
'mailer' => $this->mailService->mailerName(),
|
|
||||||
]));
|
|
||||||
} catch (Throwable $exception) {
|
|
||||||
Log::channel('emails')->error('Notification email delivery failed.', array_merge($context, [
|
|
||||||
'email_type' => $emailType,
|
|
||||||
'exception' => $exception,
|
|
||||||
]));
|
|
||||||
|
|
||||||
throw $exception;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @param array<string, mixed> $context */
|
|
||||||
private function logSkipped(string $emailType, array $context): void
|
|
||||||
{
|
|
||||||
Log::channel('emails')->warning('Notification email skipped.', array_merge($context, [
|
|
||||||
'email_type' => $emailType,
|
|
||||||
]));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,12 @@ Orquesta notificaciones de negocio por correo a partir de eventos de otros domin
|
|||||||
|
|
||||||
- `UserRegistered`: dispara el correo de bienvenida.
|
- `UserRegistered`: dispara el correo de bienvenida.
|
||||||
- `PasswordResetRequested`: envía el código de recuperación si el intento sigue pendiente.
|
- `PasswordResetRequested`: envía el código de recuperación si el intento sigue pendiente.
|
||||||
- `PurchasePaid`: envía la confirmación de compra y adjunta los tickets generados, cuando corresponde.
|
- `PurchasePaid`: envía la confirmación de pago.
|
||||||
|
- `TicketsAvailable`: informa y entrega la disponibilidad de tickets.
|
||||||
|
|
||||||
## Componentes
|
## Componentes
|
||||||
|
|
||||||
Los listeners `SendWelcomeEmail`, `SendPasswordResetEmail` y `SendPurchaseConfirmedEmail` delegan en `NotificationMailService`. Este servicio carga el contexto necesario, renderiza las vistas y envía mediante `Integration/MailService`.
|
Los listeners `SendWelcomeEmail`, `SendPasswordResetEmail`, `SendPurchasePaidEmail` y `SendTicketsAvailableEmail` delegan en `NotificationMailService`. Este servicio carga el contexto necesario, renderiza las vistas y envía mediante `Integration/MailService`.
|
||||||
|
|
||||||
## API y dependencias
|
## API y dependencias
|
||||||
|
|
||||||
@@ -22,6 +23,4 @@ No expone rutas HTTP. Consume datos de `Auth`, `Tenant`, `Purchase` y `Ticket`,
|
|||||||
|
|
||||||
- Los listeners reciben identificadores y vuelven a cargar los modelos, evitando transportar entidades obsoletas.
|
- Los listeners reciben identificadores y vuelven a cargar los modelos, evitando transportar entidades obsoletas.
|
||||||
- La recuperación no se envía si el intento dejó de estar pendiente.
|
- La recuperación no se envía si el intento dejó de estar pendiente.
|
||||||
- Los correos de cuenta (bienvenida y recuperación de contraseña) usan la identidad visual del `WebsiteType` asociado al tenant, con fallback al tenant si no tiene uno configurado.
|
|
||||||
- El correo transaccional de compra confirmada usa la identidad visual del tenant y adjunta un único PDF cuando la compra generó tickets.
|
|
||||||
- Los handlers deben permanecer idempotentes o tolerantes a reintentos de cola.
|
- Los handlers deben permanecer idempotentes o tolerantes a reintentos de cola.
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ class PurchaseController extends Controller
|
|||||||
PaymentIntentRequest $request,
|
PaymentIntentRequest $request,
|
||||||
Tenant $tenant,
|
Tenant $tenant,
|
||||||
Purchase $compra,
|
Purchase $compra,
|
||||||
|
CheckoutService $checkoutService,
|
||||||
PurchaseStateGuard $purchaseState,
|
PurchaseStateGuard $purchaseState,
|
||||||
): JsonResponse {
|
): JsonResponse {
|
||||||
$compra = $this->resolveScopedPurchase($tenant, $request->user()->id, $compra);
|
$compra = $this->resolveScopedPurchase($tenant, $request->user()->id, $compra);
|
||||||
@@ -102,6 +103,7 @@ class PurchaseController extends Controller
|
|||||||
: null;
|
: null;
|
||||||
|
|
||||||
$updated = DB::transaction(function () use (
|
$updated = DB::transaction(function () use (
|
||||||
|
$checkoutService,
|
||||||
$compra,
|
$compra,
|
||||||
$method,
|
$method,
|
||||||
$purchaseState,
|
$purchaseState,
|
||||||
@@ -140,6 +142,12 @@ class PurchaseController extends Controller
|
|||||||
$purchaseUpdate['transfer_payer_dni'] = $transferPayerDni;
|
$purchaseUpdate['transfer_payer_dni'] = $transferPayerDni;
|
||||||
}
|
}
|
||||||
$purchase->update($purchaseUpdate);
|
$purchase->update($purchaseUpdate);
|
||||||
|
$checkoutService->refreshReservationExpiration(
|
||||||
|
$purchase,
|
||||||
|
now()->addMinutes(
|
||||||
|
max(1, (int) config("purchase.payment_expiration_minutes.{$method}", 30)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@@ -243,6 +251,15 @@ class PurchaseController extends Controller
|
|||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function complete(Request $request, Tenant $tenant, Purchase $compra, CheckoutService $checkoutService): PurchaseResource
|
||||||
|
{
|
||||||
|
$compra = $this->resolveScopedPurchase($tenant, $request->user()->id, $compra);
|
||||||
|
|
||||||
|
return PurchaseResource::make(
|
||||||
|
$checkoutService->completePurchase($compra)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function submitForReview(
|
public function submitForReview(
|
||||||
Request $request,
|
Request $request,
|
||||||
Tenant $tenant,
|
Tenant $tenant,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Domains\Purchase\Events;
|
namespace App\Domains\Purchase\Events;
|
||||||
|
|
||||||
|
use App\Domains\Purchase\Models\Purchase;
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
@@ -9,5 +10,5 @@ class PurchasePaid
|
|||||||
{
|
{
|
||||||
use Dispatchable, SerializesModels;
|
use Dispatchable, SerializesModels;
|
||||||
|
|
||||||
public function __construct(public readonly int $purchaseId) {}
|
public function __construct(public readonly Purchase $purchase) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ class Purchase extends Model
|
|||||||
'status' => self::STATUS_PAID,
|
'status' => self::STATUS_PAID,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
PurchasePaid::dispatch($this->getKey());
|
PurchasePaid::dispatch($this);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ class PurchaseResource extends JsonResource
|
|||||||
*/
|
*/
|
||||||
public function toArray(Request $request): array
|
public function toArray(Request $request): array
|
||||||
{
|
{
|
||||||
$serverTime = now();
|
|
||||||
$expiresAt = $this->stockReservation?->expires_at;
|
|
||||||
$items = $this->resource->relationLoaded('items')
|
$items = $this->resource->relationLoaded('items')
|
||||||
? $this->resource->getRelation('items')
|
? $this->resource->getRelation('items')
|
||||||
: collect();
|
: collect();
|
||||||
@@ -50,11 +48,7 @@ class PurchaseResource extends JsonResource
|
|||||||
'created_at' => $this->created_at,
|
'created_at' => $this->created_at,
|
||||||
'status' => $this->status,
|
'status' => $this->status,
|
||||||
'payment_method' => $this->payment_method,
|
'payment_method' => $this->payment_method,
|
||||||
'expires_at' => $expiresAt,
|
'expires_at' => $this->stockReservation?->expires_at,
|
||||||
'expires_in_seconds' => $expiresAt === null
|
|
||||||
? null
|
|
||||||
: max(0, $expiresAt->getTimestamp() - $serverTime->getTimestamp()),
|
|
||||||
'server_time' => $serverTime,
|
|
||||||
'dni' => $this->dni,
|
'dni' => $this->dni,
|
||||||
'transfer_payer_dni' => $this->transfer_payer_dni,
|
'transfer_payer_dni' => $this->transfer_payer_dni,
|
||||||
'telefono' => $this->telefono,
|
'telefono' => $this->telefono,
|
||||||
|
|||||||
@@ -18,6 +18,33 @@ class CompleteCheckoutService
|
|||||||
private readonly PurchaseStateGuard $purchaseState,
|
private readonly PurchaseStateGuard $purchaseState,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
public function complete(Purchase $purchase): Purchase
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($purchase): Purchase {
|
||||||
|
$purchase = $this->lockPurchase($purchase);
|
||||||
|
$this->purchaseState->assertNotExpired($purchase);
|
||||||
|
|
||||||
|
if ($purchase->payment_method === null) {
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'payment_method' => __('api.purchase.payment_method_required'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->isTerminal($purchase)) {
|
||||||
|
return $this->loadPurchase($purchase);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->purchaseState->lockCurrentCart($purchase);
|
||||||
|
|
||||||
|
$purchase->update([
|
||||||
|
'status' => Purchase::STATUS_PENDING_PAYMENT,
|
||||||
|
'total' => $purchase->calculateCurrentTotalAmount(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->loadPurchase($purchase);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function submitForReview(Purchase $purchase): Purchase
|
public function submitForReview(Purchase $purchase): Purchase
|
||||||
{
|
{
|
||||||
return DB::transaction(function () use ($purchase): Purchase {
|
return DB::transaction(function () use ($purchase): Purchase {
|
||||||
@@ -43,7 +70,7 @@ class CompleteCheckoutService
|
|||||||
$purchase->update([
|
$purchase->update([
|
||||||
'status' => Purchase::STATUS_IN_REVIEW,
|
'status' => Purchase::STATUS_IN_REVIEW,
|
||||||
]);
|
]);
|
||||||
$this->reservations->clearExpirationForReview($purchase);
|
$this->reservations->refreshForPurchase($purchase, null);
|
||||||
|
|
||||||
return $this->loadPurchase($purchase);
|
return $this->loadPurchase($purchase);
|
||||||
});
|
});
|
||||||
@@ -144,6 +171,18 @@ class CompleteCheckoutService
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function isTerminal(Purchase $purchase): bool
|
||||||
|
{
|
||||||
|
return in_array($purchase->status, [
|
||||||
|
Purchase::STATUS_PAID,
|
||||||
|
Purchase::STATUS_IN_REVIEW,
|
||||||
|
Purchase::STATUS_CANCELLED,
|
||||||
|
Purchase::STATUS_REJECTED,
|
||||||
|
Purchase::STATUS_EXPIRED,
|
||||||
|
Purchase::STATUS_SUPERSEDED,
|
||||||
|
], true);
|
||||||
|
}
|
||||||
|
|
||||||
private function lockPurchase(Purchase $purchase): Purchase
|
private function lockPurchase(Purchase $purchase): Purchase
|
||||||
{
|
{
|
||||||
/** @var Purchase */
|
/** @var Purchase */
|
||||||
|
|||||||
@@ -2,12 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Domains\Purchase\Services;
|
namespace App\Domains\Purchase\Services;
|
||||||
|
|
||||||
|
use App\Domains\Catalog\Services\StockReservationService;
|
||||||
use App\Domains\Purchase\Models\Purchase;
|
use App\Domains\Purchase\Models\Purchase;
|
||||||
use App\Domains\Purchase\Services\Checkout\CompleteCheckoutService;
|
use App\Domains\Purchase\Services\Checkout\CompleteCheckoutService;
|
||||||
use App\Domains\Purchase\Services\Checkout\EditCheckoutService;
|
use App\Domains\Purchase\Services\Checkout\EditCheckoutService;
|
||||||
use App\Domains\Purchase\Services\Checkout\ReleaseCheckoutService;
|
use App\Domains\Purchase\Services\Checkout\ReleaseCheckoutService;
|
||||||
use App\Domains\Purchase\Services\Checkout\StartCheckoutService;
|
use App\Domains\Purchase\Services\Checkout\StartCheckoutService;
|
||||||
use App\Domains\Tenant\Models\Tenant;
|
use App\Domains\Tenant\Models\Tenant;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,6 +24,7 @@ class CheckoutService
|
|||||||
private readonly EditCheckoutService $editor,
|
private readonly EditCheckoutService $editor,
|
||||||
private readonly CompleteCheckoutService $completer,
|
private readonly CompleteCheckoutService $completer,
|
||||||
private readonly ReleaseCheckoutService $releaser,
|
private readonly ReleaseCheckoutService $releaser,
|
||||||
|
private readonly StockReservationService $reservations,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/** @param array<string, mixed> $purchaseData */
|
/** @param array<string, mixed> $purchaseData */
|
||||||
@@ -30,6 +33,11 @@ class CheckoutService
|
|||||||
return $this->starter->start($tenant, $userId, $purchaseData);
|
return $this->starter->start($tenant, $userId, $purchaseData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function completePurchase(Purchase $purchase): Purchase
|
||||||
|
{
|
||||||
|
return $this->completer->complete($purchase);
|
||||||
|
}
|
||||||
|
|
||||||
public function submitForReview(Purchase $purchase): Purchase
|
public function submitForReview(Purchase $purchase): Purchase
|
||||||
{
|
{
|
||||||
return $this->completer->submitForReview($purchase);
|
return $this->completer->submitForReview($purchase);
|
||||||
@@ -70,4 +78,9 @@ class CheckoutService
|
|||||||
{
|
{
|
||||||
return $this->releaser->expire($purchase);
|
return $this->releaser->expire($purchase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function refreshReservationExpiration(Purchase $purchase, ?Carbon $expiresAt): void
|
||||||
|
{
|
||||||
|
$this->reservations->refreshForPurchase($purchase, $expiresAt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ Route::prefix('tenants/{tenant:codigo}')->middleware('auth:sanctum')->group(func
|
|||||||
Route::get('compras/{compra}', [PurchaseController::class, 'show']);
|
Route::get('compras/{compra}', [PurchaseController::class, 'show']);
|
||||||
Route::patch('compras/{compra}/customer-data', [PurchaseController::class, 'updateCustomerData']);
|
Route::patch('compras/{compra}/customer-data', [PurchaseController::class, 'updateCustomerData']);
|
||||||
Route::post('compras/{compra}/payment-intent', [PurchaseController::class, 'paymentIntent']);
|
Route::post('compras/{compra}/payment-intent', [PurchaseController::class, 'paymentIntent']);
|
||||||
|
Route::post('compras/{compra}/complete', [PurchaseController::class, 'complete']);
|
||||||
Route::post('compras/{compra}/review', [PurchaseController::class, 'submitForReview']);
|
Route::post('compras/{compra}/review', [PurchaseController::class, 'submitForReview']);
|
||||||
Route::post('compras/{compra}/cancel', [PurchaseController::class, 'cancel']);
|
Route::post('compras/{compra}/cancel', [PurchaseController::class, 'cancel']);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,21 +9,18 @@ use App\Domains\Sale\Resources\AdminApp\SaleDetailResource;
|
|||||||
use App\Domains\Sale\Resources\AdminApp\SaleModificationResource;
|
use App\Domains\Sale\Resources\AdminApp\SaleModificationResource;
|
||||||
use App\Domains\Sale\Resources\AdminApp\SaleResource;
|
use App\Domains\Sale\Resources\AdminApp\SaleResource;
|
||||||
use App\Domains\Sale\Resources\AdminApp\SaleTicketResource;
|
use App\Domains\Sale\Resources\AdminApp\SaleTicketResource;
|
||||||
use App\Domains\Sale\Services\AdminAppSaleExcelService;
|
|
||||||
use App\Domains\Sale\Services\AdminAppSalePdfService;
|
use App\Domains\Sale\Services\AdminAppSalePdfService;
|
||||||
use App\Domains\Sale\Services\AdminAppSaleService;
|
use App\Domains\Sale\Services\AdminAppSaleService;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
|
||||||
|
|
||||||
class SaleController extends Controller
|
class SaleController extends Controller
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected AdminAppSaleService $saleService,
|
protected AdminAppSaleService $saleService,
|
||||||
protected AdminAppSalePdfService $salePdfService,
|
protected AdminAppSalePdfService $salePdfService,
|
||||||
protected AdminAppSaleExcelService $saleExcelService,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function index(AdminAppSaleIndexRequest $request): AnonymousResourceCollection
|
public function index(AdminAppSaleIndexRequest $request): AnonymousResourceCollection
|
||||||
@@ -97,27 +94,4 @@ class SaleController extends Controller
|
|||||||
$request->validated('timezone'),
|
$request->validated('timezone'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function downloadExcel(AdminAppSalePdfRequest $request): StreamedResponse
|
|
||||||
{
|
|
||||||
$tenant = $request->user()->tenant()->firstOrFail();
|
|
||||||
|
|
||||||
return $this->saleExcelService->downloadSales(
|
|
||||||
$tenant,
|
|
||||||
$this->saleService->salesForExport($tenant, $request->validated()),
|
|
||||||
$request->validated('timezone'),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function downloadModificationsExcel(
|
|
||||||
AdminAppSaleModificationPdfRequest $request,
|
|
||||||
): StreamedResponse {
|
|
||||||
$tenant = $request->user()->tenant()->firstOrFail();
|
|
||||||
|
|
||||||
return $this->saleExcelService->downloadModifications(
|
|
||||||
$tenant,
|
|
||||||
$this->saleService->modificationsForExport($tenant),
|
|
||||||
$request->validated('timezone'),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,211 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\Sale\Services;
|
|
||||||
|
|
||||||
use App\Domains\Logging\Models\ValueChange;
|
|
||||||
use App\Domains\Purchase\Models\Purchase;
|
|
||||||
use App\Domains\Tenant\Models\Tenant;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
|
||||||
use PhpOffice\PhpSpreadsheet\Shared\Date;
|
|
||||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
||||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
|
||||||
use PhpOffice\PhpSpreadsheet\Style\Fill;
|
|
||||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
|
||||||
|
|
||||||
class AdminAppSaleExcelService
|
|
||||||
{
|
|
||||||
/** @param Collection<int, Purchase> $sales */
|
|
||||||
public function downloadSales(Tenant $tenant, Collection $sales, string $timeZone): StreamedResponse
|
|
||||||
{
|
|
||||||
$generatedAt = now();
|
|
||||||
$spreadsheet = $this->spreadsheet($tenant, 'Historial de ventas');
|
|
||||||
$sheet = $spreadsheet->getActiveSheet();
|
|
||||||
$sheet->setTitle('Ventas');
|
|
||||||
$sheet->fromArray([
|
|
||||||
'ID',
|
|
||||||
'Fecha',
|
|
||||||
'Cliente',
|
|
||||||
'Cantidad',
|
|
||||||
'Estado',
|
|
||||||
'Importe',
|
|
||||||
'Tickets',
|
|
||||||
], null, 'A1');
|
|
||||||
|
|
||||||
foreach ($sales->values() as $index => $sale) {
|
|
||||||
$row = $index + 2;
|
|
||||||
$sheet->setCellValueExplicit("A{$row}", '#'.$sale->id, DataType::TYPE_STRING);
|
|
||||||
if ($sale->created_at) {
|
|
||||||
$sheet->setCellValue(
|
|
||||||
"B{$row}",
|
|
||||||
Date::dateTimeToExcel($sale->created_at->copy()->timezone($timeZone)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$sheet->setCellValueExplicit(
|
|
||||||
"C{$row}",
|
|
||||||
$sale->nombre_apellido ?: 'Sin nombre',
|
|
||||||
DataType::TYPE_STRING,
|
|
||||||
);
|
|
||||||
$sheet->setCellValue("D{$row}", (int) ($sale->quantity ?? 0));
|
|
||||||
$sheet->setCellValue("E{$row}", $this->saleStatus($sale->status));
|
|
||||||
$sheet->setCellValue("F{$row}", (float) $sale->total);
|
|
||||||
$sheet->setCellValue("G{$row}", (int) ($sale->tickets_count ?? 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
$lastRow = max(2, $sales->count() + 1);
|
|
||||||
$sheet->getStyle("B2:B{$lastRow}")->getNumberFormat()->setFormatCode('dd/mm/yyyy hh:mm');
|
|
||||||
$sheet->getStyle("F2:F{$lastRow}")->getNumberFormat()->setFormatCode('$ #,##0.00');
|
|
||||||
$this->formatSheet($spreadsheet, 'A1:G1', "A1:G{$lastRow}", [
|
|
||||||
'A' => 13,
|
|
||||||
'B' => 20,
|
|
||||||
'C' => 32,
|
|
||||||
'D' => 12,
|
|
||||||
'E' => 22,
|
|
||||||
'F' => 16,
|
|
||||||
'G' => 12,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $this->download(
|
|
||||||
$spreadsheet,
|
|
||||||
'ventas_'.$tenant->codigo.'_'
|
|
||||||
.$generatedAt->copy()->timezone($timeZone)->format('Ymd_His').'.xlsx',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @param Collection<int, ValueChange> $modifications */
|
|
||||||
public function downloadModifications(
|
|
||||||
Tenant $tenant,
|
|
||||||
Collection $modifications,
|
|
||||||
string $timeZone,
|
|
||||||
): StreamedResponse {
|
|
||||||
$generatedAt = now();
|
|
||||||
$spreadsheet = $this->spreadsheet($tenant, 'Historial de modificaciones de ventas');
|
|
||||||
$sheet = $spreadsheet->getActiveSheet();
|
|
||||||
$sheet->setTitle('Modificaciones');
|
|
||||||
$sheet->fromArray([
|
|
||||||
'Fecha',
|
|
||||||
'Hora',
|
|
||||||
'Venta',
|
|
||||||
'Cliente',
|
|
||||||
'Campo',
|
|
||||||
'Valor anterior',
|
|
||||||
'Valor nuevo',
|
|
||||||
'Modificado por',
|
|
||||||
], null, 'A1');
|
|
||||||
|
|
||||||
foreach ($modifications->values() as $index => $modification) {
|
|
||||||
$row = $index + 2;
|
|
||||||
$changedAt = $modification->changed_at->copy()->timezone($timeZone);
|
|
||||||
$sale = $modification->trackable;
|
|
||||||
$sheet->setCellValue("A{$row}", Date::dateTimeToExcel($changedAt));
|
|
||||||
$sheet->setCellValue("B{$row}", Date::dateTimeToExcel($changedAt));
|
|
||||||
$sheet->setCellValueExplicit(
|
|
||||||
"C{$row}",
|
|
||||||
'#'.$modification->trackable_id,
|
|
||||||
DataType::TYPE_STRING,
|
|
||||||
);
|
|
||||||
$sheet->setCellValueExplicit(
|
|
||||||
"D{$row}",
|
|
||||||
$sale?->nombre_apellido ?: 'Sin nombre',
|
|
||||||
DataType::TYPE_STRING,
|
|
||||||
);
|
|
||||||
$sheet->setCellValueExplicit(
|
|
||||||
"E{$row}",
|
|
||||||
$modification->attribute,
|
|
||||||
DataType::TYPE_STRING,
|
|
||||||
);
|
|
||||||
$sheet->setCellValueExplicit(
|
|
||||||
"F{$row}",
|
|
||||||
$modification->old_value ?? '-',
|
|
||||||
DataType::TYPE_STRING,
|
|
||||||
);
|
|
||||||
$sheet->setCellValueExplicit(
|
|
||||||
"G{$row}",
|
|
||||||
$modification->new_value ?? '-',
|
|
||||||
DataType::TYPE_STRING,
|
|
||||||
);
|
|
||||||
$sheet->setCellValueExplicit(
|
|
||||||
"H{$row}",
|
|
||||||
$modification->user?->nombre_apellido ?? 'Sistema',
|
|
||||||
DataType::TYPE_STRING,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$lastRow = max(2, $modifications->count() + 1);
|
|
||||||
$sheet->getStyle("A2:A{$lastRow}")->getNumberFormat()->setFormatCode('dd/mm/yyyy');
|
|
||||||
$sheet->getStyle("B2:B{$lastRow}")->getNumberFormat()->setFormatCode('hh:mm:ss');
|
|
||||||
$this->formatSheet($spreadsheet, 'A1:H1', "A1:H{$lastRow}", [
|
|
||||||
'A' => 14,
|
|
||||||
'B' => 12,
|
|
||||||
'C' => 13,
|
|
||||||
'D' => 32,
|
|
||||||
'E' => 20,
|
|
||||||
'F' => 24,
|
|
||||||
'G' => 24,
|
|
||||||
'H' => 28,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $this->download(
|
|
||||||
$spreadsheet,
|
|
||||||
'historial_modificaciones_'.$tenant->codigo.'_'
|
|
||||||
.$generatedAt->copy()->timezone($timeZone)->format('Ymd_His').'.xlsx',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function spreadsheet(Tenant $tenant, string $title): Spreadsheet
|
|
||||||
{
|
|
||||||
$spreadsheet = new Spreadsheet;
|
|
||||||
$spreadsheet->getProperties()
|
|
||||||
->setCreator('Shopit')
|
|
||||||
->setTitle($title)
|
|
||||||
->setSubject($tenant->nombre);
|
|
||||||
|
|
||||||
return $spreadsheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @param array<string, int> $widths */
|
|
||||||
private function formatSheet(
|
|
||||||
Spreadsheet $spreadsheet,
|
|
||||||
string $headerRange,
|
|
||||||
string $filterRange,
|
|
||||||
array $widths,
|
|
||||||
): void {
|
|
||||||
$sheet = $spreadsheet->getActiveSheet();
|
|
||||||
$sheet->getStyle($headerRange)->applyFromArray([
|
|
||||||
'font' => ['bold' => true, 'color' => ['rgb' => 'FFFFFF']],
|
|
||||||
'fill' => [
|
|
||||||
'fillType' => Fill::FILL_SOLID,
|
|
||||||
'startColor' => ['rgb' => '26382E'],
|
|
||||||
],
|
|
||||||
'alignment' => ['vertical' => Alignment::VERTICAL_CENTER],
|
|
||||||
]);
|
|
||||||
$sheet->getRowDimension(1)->setRowHeight(24);
|
|
||||||
$sheet->freezePane('A2');
|
|
||||||
$sheet->setAutoFilter($filterRange);
|
|
||||||
|
|
||||||
foreach ($widths as $column => $width) {
|
|
||||||
$sheet->getColumnDimension($column)->setWidth($width);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function download(Spreadsheet $spreadsheet, string $filename): StreamedResponse
|
|
||||||
{
|
|
||||||
return response()->streamDownload(function () use ($spreadsheet): void {
|
|
||||||
(new Xlsx($spreadsheet))->save('php://output');
|
|
||||||
$spreadsheet->disconnectWorksheets();
|
|
||||||
}, $filename, [
|
|
||||||
'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function saleStatus(string $status): string
|
|
||||||
{
|
|
||||||
return match ($status) {
|
|
||||||
Purchase::STATUS_PAID => 'Confirmado',
|
|
||||||
Purchase::STATUS_CREATED => 'Por completar datos',
|
|
||||||
Purchase::STATUS_PENDING_PAYMENT, Purchase::STATUS_IN_REVIEW => 'Esperando pago',
|
|
||||||
default => 'Anulado',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,6 @@ Provee consultas administrativas y exportaciones de ventas confirmadas, además
|
|||||||
|
|
||||||
- `AdminAppSaleService`: pagina ventas, calcula totales y obtiene colecciones para exportación; también consulta modificaciones.
|
- `AdminAppSaleService`: pagina ventas, calcula totales y obtiene colecciones para exportación; también consulta modificaciones.
|
||||||
- `AdminAppSalePdfService`: genera descargas PDF de ventas y de cambios.
|
- `AdminAppSalePdfService`: genera descargas PDF de ventas y de cambios.
|
||||||
- `AdminAppSaleExcelService`: genera descargas Excel de ventas y de cambios.
|
|
||||||
- `AdminAppSaleIndexRequest`: valida filtros del listado y la exportación.
|
- `AdminAppSaleIndexRequest`: valida filtros del listado y la exportación.
|
||||||
- `SaleResource` y `SaleModificationResource`: representan ventas e historial para AdminApp.
|
- `SaleResource` y `SaleModificationResource`: representan ventas e historial para AdminApp.
|
||||||
- `SaleController`: entrada HTTP del panel.
|
- `SaleController`: entrada HTTP del panel.
|
||||||
@@ -17,8 +16,8 @@ Provee consultas administrativas y exportaciones de ventas confirmadas, además
|
|||||||
|
|
||||||
Bajo `/v1/adminapp/tenant`, protegidos por `auth:sanctum` y `adminapp.tenant`:
|
Bajo `/v1/adminapp/tenant`, protegidos por `auth:sanctum` y `adminapp.tenant`:
|
||||||
|
|
||||||
- `GET /sales`, `GET /sales/pdf` y `GET /sales/excel`.
|
- `GET /sales` y `GET /sales/pdf`.
|
||||||
- `GET /sales/modifications`, `GET /sales/modifications/pdf` y `GET /sales/modifications/excel`.
|
- `GET /sales/modifications` y `GET /sales/modifications/pdf`.
|
||||||
|
|
||||||
## Dependencias
|
## Dependencias
|
||||||
|
|
||||||
@@ -26,4 +25,4 @@ Consume compras de `Purchase`, datos del tenant y entradas de `Logging`. No es d
|
|||||||
|
|
||||||
## Consideraciones
|
## Consideraciones
|
||||||
|
|
||||||
La consulta paginada y la colección de exportación deben aplicar los mismos filtros para evitar diferencias entre pantalla, PDF y Excel.
|
La consulta paginada y la colección de exportación deben aplicar los mismos filtros para evitar diferencias entre pantalla y PDF.
|
||||||
|
|||||||
@@ -8,10 +8,8 @@ Route::prefix('v1/adminapp/tenant')
|
|||||||
->group(function (): void {
|
->group(function (): void {
|
||||||
Route::get('sales', [SaleController::class, 'index']);
|
Route::get('sales', [SaleController::class, 'index']);
|
||||||
Route::get('sales/pdf', [SaleController::class, 'downloadPdf']);
|
Route::get('sales/pdf', [SaleController::class, 'downloadPdf']);
|
||||||
Route::get('sales/excel', [SaleController::class, 'downloadExcel']);
|
|
||||||
Route::get('sales/modifications', [SaleController::class, 'modifications']);
|
Route::get('sales/modifications', [SaleController::class, 'modifications']);
|
||||||
Route::get('sales/modifications/pdf', [SaleController::class, 'downloadModificationsPdf']);
|
Route::get('sales/modifications/pdf', [SaleController::class, 'downloadModificationsPdf']);
|
||||||
Route::get('sales/modifications/excel', [SaleController::class, 'downloadModificationsExcel']);
|
|
||||||
Route::post('sales/{sale}/confirm', [SaleController::class, 'confirm'])->whereNumber('sale');
|
Route::post('sales/{sale}/confirm', [SaleController::class, 'confirm'])->whereNumber('sale');
|
||||||
Route::post('sales/{sale}/cancel', [SaleController::class, 'cancel'])->whereNumber('sale');
|
Route::post('sales/{sale}/cancel', [SaleController::class, 'cancel'])->whereNumber('sale');
|
||||||
Route::get('sales/{sale}/tickets', [SaleController::class, 'tickets'])->whereNumber('sale');
|
Route::get('sales/{sale}/tickets', [SaleController::class, 'tickets'])->whereNumber('sale');
|
||||||
|
|||||||
@@ -6,8 +6,5 @@ use Illuminate\Support\Facades\Route;
|
|||||||
Route::prefix('v1/adminapp/tenant')
|
Route::prefix('v1/adminapp/tenant')
|
||||||
->middleware(['auth:sanctum', 'adminapp.tenant'])
|
->middleware(['auth:sanctum', 'adminapp.tenant'])
|
||||||
->group(function (): void {
|
->group(function (): void {
|
||||||
Route::get('staff', [AdminAppStaffController::class, 'index']);
|
Route::apiResource('staff', AdminAppStaffController::class)->except('show');
|
||||||
Route::post('staff', [AdminAppStaffController::class, 'store']);
|
|
||||||
Route::put('staff/{staff}', [AdminAppStaffController::class, 'update']);
|
|
||||||
Route::delete('staff/{staff}', [AdminAppStaffController::class, 'destroy']);
|
|
||||||
});
|
});
|
||||||
|
|||||||
58
app/Domains/StorageTest/Controllers/S3TestController.php
Normal file
58
app/Domains/StorageTest/Controllers/S3TestController.php
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\StorageTest\Controllers;
|
||||||
|
|
||||||
|
use App\Domains\Attachable\Services\AttachmentService;
|
||||||
|
use App\Domains\StorageTest\Requests\GenerateS3TemporaryUrlRequest;
|
||||||
|
use App\Domains\StorageTest\Requests\StoreS3TestFileRequest;
|
||||||
|
use App\Domains\StorageTest\Services\S3TestService;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
class S3TestController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
protected AttachmentService $attachmentService,
|
||||||
|
protected S3TestService $s3TestService,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(StoreS3TestFileRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$attachment = $this->attachmentService->store(
|
||||||
|
$request->file('file') ?? (string) $request->validated('file_base64'),
|
||||||
|
$request->validated('path'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$temporaryUrl = $this->s3TestService->generateTemporaryUrl(
|
||||||
|
$attachment->path,
|
||||||
|
(int) $request->validated('expires_in_minutes', 10),
|
||||||
|
);
|
||||||
|
|
||||||
|
return response()->json(
|
||||||
|
[
|
||||||
|
'id' => $attachment->id,
|
||||||
|
'key' => $attachment->key,
|
||||||
|
'path' => $attachment->path,
|
||||||
|
'filename' => $attachment->filename,
|
||||||
|
'type' => $attachment->type->value,
|
||||||
|
'mime_type' => $attachment->mime_type,
|
||||||
|
'extension' => $attachment->extension,
|
||||||
|
'size' => $attachment->size,
|
||||||
|
'temporary_url' => $temporaryUrl['temporary_url'],
|
||||||
|
'temporary_url_expires_at' => $temporaryUrl['temporary_url_expires_at'],
|
||||||
|
],
|
||||||
|
201,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function temporaryUrl(GenerateS3TemporaryUrlRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
return response()->json(
|
||||||
|
$this->s3TestService->generateTemporaryUrl(
|
||||||
|
$request->validated('path'),
|
||||||
|
(int) $request->validated('expires_in_minutes', 10),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\StorageTest\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class GenerateS3TemporaryUrlRequest extends FormRequest
|
||||||
|
{
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, array<int, string>>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'path' => ['required', 'string', 'max:2048'],
|
||||||
|
'expires_in_minutes' => ['nullable', 'integer', 'min:1', 'max:1440'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
26
app/Domains/StorageTest/Requests/StoreS3TestFileRequest.php
Normal file
26
app/Domains/StorageTest/Requests/StoreS3TestFileRequest.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\StorageTest\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class StoreS3TestFileRequest extends FormRequest
|
||||||
|
{
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, array<int, string>>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'file' => ['nullable', 'file', 'max:10240', 'required_without:file_base64'],
|
||||||
|
'file_base64' => ['nullable', 'string', 'required_without:file'],
|
||||||
|
'path' => ['required', 'string', 'max:2048'],
|
||||||
|
'expires_in_minutes' => ['nullable', 'integer', 'min:1', 'max:1440'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
81
app/Domains/StorageTest/Services/S3TestService.php
Normal file
81
app/Domains/StorageTest/Services/S3TestService.php
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\StorageTest\Services;
|
||||||
|
|
||||||
|
use Illuminate\Http\UploadedFile;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
|
class S3TestService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return array<string, int|string|null>
|
||||||
|
*/
|
||||||
|
public function storeTestFile(
|
||||||
|
UploadedFile $file,
|
||||||
|
?string $directory = null,
|
||||||
|
int $expiresInMinutes = 10,
|
||||||
|
): array {
|
||||||
|
$directory = $this->normalizeDirectory($directory);
|
||||||
|
$disk = Storage::disk('s3');
|
||||||
|
$path = $disk->putFile($directory, $file);
|
||||||
|
|
||||||
|
if (! is_string($path) || $path === '') {
|
||||||
|
Log::error('S3 upload returned an empty path.', [
|
||||||
|
'disk' => 's3',
|
||||||
|
'directory' => $directory,
|
||||||
|
'original_name' => $file->getClientOriginalName(),
|
||||||
|
'mime_type' => $file->getClientMimeType(),
|
||||||
|
'size' => $file->getSize(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
throw new RuntimeException('No se pudo subir el archivo al disco s3.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'disk' => 's3',
|
||||||
|
'directory' => $directory,
|
||||||
|
'key' => $path,
|
||||||
|
'path' => $path,
|
||||||
|
'filename' => basename($path),
|
||||||
|
'original_name' => $file->getClientOriginalName(),
|
||||||
|
'mime_type' => $file->getClientMimeType(),
|
||||||
|
'extension' => $file->extension(),
|
||||||
|
'size' => $file->getSize(),
|
||||||
|
'temporary_url' => $disk->temporaryUrl($path, now()->addMinutes($expiresInMinutes)),
|
||||||
|
'temporary_url_expires_at' => now()->addMinutes($expiresInMinutes)->toIso8601String(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function generateTemporaryUrl(string $path, int $expiresInMinutes = 10): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'disk' => 's3',
|
||||||
|
'key' => $path,
|
||||||
|
'path' => $path,
|
||||||
|
'temporary_url' => $this->temporaryUrlForPath($path, $expiresInMinutes),
|
||||||
|
'temporary_url_expires_at' => now()->addMinutes($expiresInMinutes)->toIso8601String(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function temporaryUrlForPath(string $path, int $expiresInMinutes): string
|
||||||
|
{
|
||||||
|
return Storage::disk('s3')->temporaryUrl($path, now()->addMinutes($expiresInMinutes));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function normalizeDirectory(?string $directory): string
|
||||||
|
{
|
||||||
|
$directory = trim((string) $directory, '/');
|
||||||
|
|
||||||
|
if ($directory !== '') {
|
||||||
|
return $directory;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'testing/attachments/'.now()->format('Y/m/d').'/'.Str::uuid();
|
||||||
|
}
|
||||||
|
}
|
||||||
23
app/Domains/StorageTest/documentacion/README.md
Normal file
23
app/Domains/StorageTest/documentacion/README.md
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Dominio StorageTest
|
||||||
|
|
||||||
|
## Propósito
|
||||||
|
|
||||||
|
Expone operaciones técnicas para comprobar la escritura en S3 y la generación de URL temporales.
|
||||||
|
|
||||||
|
## Componentes
|
||||||
|
|
||||||
|
- `S3TestController`: recibe solicitudes de carga y URL temporal.
|
||||||
|
- `S3TestService`: almacena un archivo de prueba y genera el enlace firmado.
|
||||||
|
- `StoreS3TestFileRequest`: valida la carga.
|
||||||
|
- `GenerateS3TemporaryUrlRequest`: valida ruta y tiempo de expiración.
|
||||||
|
|
||||||
|
## Endpoints
|
||||||
|
|
||||||
|
Bajo `/storage-test/s3`:
|
||||||
|
|
||||||
|
- `POST /upload`.
|
||||||
|
- `GET /temporary-url`.
|
||||||
|
|
||||||
|
## Consideraciones
|
||||||
|
|
||||||
|
Es infraestructura de diagnóstico, no una API funcional de archivos. Debe restringirse por entorno o autorización. Para adjuntos de negocio se debe usar el dominio `Attachable`.
|
||||||
9
app/Domains/StorageTest/routes/api.php
Normal file
9
app/Domains/StorageTest/routes/api.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Domains\StorageTest\Controllers\S3TestController;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
Route::prefix('storage-test/s3')->group(function (): void {
|
||||||
|
Route::post('upload', [S3TestController::class, 'store']);
|
||||||
|
Route::get('temporary-url', [S3TestController::class, 'temporaryUrl']);
|
||||||
|
});
|
||||||
@@ -5,6 +5,7 @@ namespace App\Domains\Tenant\Controllers\AdminApp;
|
|||||||
use App\Domains\Auth\Models\User;
|
use App\Domains\Auth\Models\User;
|
||||||
use App\Domains\Tenant\Models\Tenant;
|
use App\Domains\Tenant\Models\Tenant;
|
||||||
use App\Domains\Tenant\Requests\AdminApp\UpdateWebsiteExtraRequest;
|
use App\Domains\Tenant\Requests\AdminApp\UpdateWebsiteExtraRequest;
|
||||||
|
use App\Domains\Tenant\Resources\AdminApp\WebsiteExtraResource;
|
||||||
use App\Domains\Tenant\Resources\AdminApp\WebsiteExtrasResource;
|
use App\Domains\Tenant\Resources\AdminApp\WebsiteExtrasResource;
|
||||||
use App\Domains\Tenant\Services\TenantInformationService;
|
use App\Domains\Tenant\Services\TenantInformationService;
|
||||||
use App\Domains\Tenant\Services\WebsiteExtraService;
|
use App\Domains\Tenant\Services\WebsiteExtraService;
|
||||||
@@ -25,6 +26,20 @@ class WebsiteExtraController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function showExtra(Request $request, string $websiteExtraCode): WebsiteExtraResource
|
||||||
|
{
|
||||||
|
$tenant = $this->loadTenant($request->user());
|
||||||
|
$definition = $this->websiteExtraService->definitionForTenant($tenant, $websiteExtraCode);
|
||||||
|
$websiteExtra = $tenant->websiteExtras
|
||||||
|
->firstWhere('website_type_extra_id', $definition->id);
|
||||||
|
|
||||||
|
if (! $websiteExtra) {
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
return WebsiteExtraResource::make($websiteExtra);
|
||||||
|
}
|
||||||
|
|
||||||
public function update(
|
public function update(
|
||||||
UpdateWebsiteExtraRequest $request,
|
UpdateWebsiteExtraRequest $request,
|
||||||
string $websiteExtraCode
|
string $websiteExtraCode
|
||||||
|
|||||||
64
app/Domains/Tenant/Controllers/TenantController.php
Normal file
64
app/Domains/Tenant/Controllers/TenantController.php
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Tenant\Controllers;
|
||||||
|
|
||||||
|
use App\Domains\Tenant\Models\Tenant;
|
||||||
|
use App\Domains\Tenant\Requests\StoreTenantRequest;
|
||||||
|
use App\Domains\Tenant\Requests\UpdateTenantRequest;
|
||||||
|
use App\Domains\Tenant\Resources\TenantResource;
|
||||||
|
use App\Domains\Tenant\Services\TenantInformationService;
|
||||||
|
use App\Domains\Tenant\Services\TenantService;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
|
||||||
|
class TenantController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
protected TenantService $tenantService,
|
||||||
|
protected TenantInformationService $tenantInformationService,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function index(): JsonResponse
|
||||||
|
{
|
||||||
|
$tenants = Tenant::query()
|
||||||
|
->latest()
|
||||||
|
->paginateFromRequest();
|
||||||
|
|
||||||
|
$this->tenantInformationService->loadMany($tenants->getCollection());
|
||||||
|
|
||||||
|
return TenantResource::collection($tenants)->response();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(StoreTenantRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$tenant = $this->tenantService->create($request->validated());
|
||||||
|
|
||||||
|
return TenantResource::make(
|
||||||
|
$this->tenantInformationService->load($tenant)
|
||||||
|
)->response()->setStatusCode(201);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(Tenant $tenant): TenantResource
|
||||||
|
{
|
||||||
|
return TenantResource::make(
|
||||||
|
$this->tenantInformationService->load($tenant)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(UpdateTenantRequest $request, Tenant $tenant): TenantResource
|
||||||
|
{
|
||||||
|
$tenant = $this->tenantService->update($tenant, $request->validated());
|
||||||
|
|
||||||
|
return TenantResource::make(
|
||||||
|
$this->tenantInformationService->load($tenant)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Tenant $tenant): Response
|
||||||
|
{
|
||||||
|
$tenant->delete();
|
||||||
|
|
||||||
|
return response()->noContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
128
app/Domains/Tenant/Requests/StoreTenantRequest.php
Normal file
128
app/Domains/Tenant/Requests/StoreTenantRequest.php
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Tenant\Requests;
|
||||||
|
|
||||||
|
use App\Domains\Catalog\Enums\GroupLayout;
|
||||||
|
use App\Domains\Catalog\Enums\ProductLayout;
|
||||||
|
use App\Domains\Shared\Rules\ImageOrBase64Rule;
|
||||||
|
use App\Domains\Tenant\Enums\CartEditingPolicy;
|
||||||
|
use App\Domains\Tenant\Services\WebsiteExtraService;
|
||||||
|
use App\Domains\Tenant\Support\TenantDomainNormalizer;
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class StoreTenantRequest extends FormRequest
|
||||||
|
{
|
||||||
|
protected bool $hasInvalidDomain = false;
|
||||||
|
|
||||||
|
protected bool $hasInvalidBasePath = false;
|
||||||
|
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function prepareForValidation(): void
|
||||||
|
{
|
||||||
|
$rawDomain = $this->input('dominio');
|
||||||
|
$hasExplicitBasePath = $this->has('base_path');
|
||||||
|
$rawBasePath = $hasExplicitBasePath
|
||||||
|
? $this->input('base_path')
|
||||||
|
: TenantDomainNormalizer::pathFromDomain($rawDomain);
|
||||||
|
$normalizedDomain = TenantDomainNormalizer::normalize($rawDomain);
|
||||||
|
$normalizedBasePath = TenantDomainNormalizer::normalizePath($rawBasePath);
|
||||||
|
|
||||||
|
$this->hasInvalidDomain = TenantDomainNormalizer::hasValue($rawDomain)
|
||||||
|
&& $normalizedDomain === null;
|
||||||
|
$this->hasInvalidBasePath = ($hasExplicitBasePath && ! is_string($rawBasePath))
|
||||||
|
|| $normalizedBasePath === null;
|
||||||
|
|
||||||
|
$this->merge([
|
||||||
|
'dominio' => $normalizedDomain,
|
||||||
|
'base_path' => $normalizedBasePath,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
$logoRule = ['required', new ImageOrBase64Rule];
|
||||||
|
|
||||||
|
return array_merge([
|
||||||
|
'client_id' => ['sometimes', 'integer', Rule::exists('clients', 'id')],
|
||||||
|
'codigo' => ['required', 'string', 'max:255', Rule::unique('tenants', 'codigo')],
|
||||||
|
'nombre' => ['required', 'string', 'max:255'],
|
||||||
|
'dominio' => [
|
||||||
|
'bail',
|
||||||
|
function (string $attribute, mixed $value, Closure $fail): void {
|
||||||
|
if ($this->hasInvalidDomain) {
|
||||||
|
$fail("The {$attribute} field must contain a valid domain or URL.");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'max:255',
|
||||||
|
Rule::unique('tenants', 'dominio')
|
||||||
|
->where('base_path', $this->input('base_path')),
|
||||||
|
],
|
||||||
|
'base_path' => [
|
||||||
|
'bail',
|
||||||
|
function (string $attribute, mixed $value, Closure $fail): void {
|
||||||
|
if ($this->hasInvalidBasePath) {
|
||||||
|
$fail("The {$attribute} field must contain a valid URL path.");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'max:255',
|
||||||
|
Rule::unique('tenants', 'base_path')
|
||||||
|
->where('dominio', $this->input('dominio')),
|
||||||
|
],
|
||||||
|
'site_title' => ['sometimes', 'nullable', 'string', 'max:255'],
|
||||||
|
'address' => ['sometimes', 'nullable', 'string', 'max:255'],
|
||||||
|
'phone' => ['sometimes', 'nullable', 'string', 'max:255'],
|
||||||
|
'primary_color' => ['required', 'string', 'regex:/^#([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/'],
|
||||||
|
'secondary_color' => ['required', 'string', 'regex:/^#([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/'],
|
||||||
|
'danger_color' => ['required', 'string', 'regex:/^#([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/'],
|
||||||
|
'success_color' => ['required', 'string', 'regex:/^#([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/'],
|
||||||
|
'header_bg_color' => ['required', 'string', 'regex:/^#([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/'],
|
||||||
|
'footer_bg_color' => ['required', 'string', 'regex:/^#([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/'],
|
||||||
|
'header_logo' => $logoRule,
|
||||||
|
'footer_logo' => $logoRule,
|
||||||
|
'favicon' => ['sometimes', 'nullable', new ImageOrBase64Rule],
|
||||||
|
'header_bg_image' => ['sometimes', 'nullable', new ImageOrBase64Rule],
|
||||||
|
'footer_bg_image' => ['sometimes', 'nullable', new ImageOrBase64Rule],
|
||||||
|
'social_media' => ['sometimes', 'array'],
|
||||||
|
'social_media.*.code' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'distinct',
|
||||||
|
Rule::exists('social_media', 'code'),
|
||||||
|
],
|
||||||
|
'social_media.*.url' => ['required', 'url', 'max:2048'],
|
||||||
|
'social_media.*.orden' => ['sometimes', 'integer', 'min:0', 'distinct'],
|
||||||
|
'search_product_layout' => ['sometimes', Rule::enum(ProductLayout::class)],
|
||||||
|
'search_group_layout' => ['sometimes', Rule::enum(GroupLayout::class)],
|
||||||
|
'search_items_per_page' => ['sometimes', 'integer', 'min:4', 'max:48'],
|
||||||
|
'display_categories' => ['sometimes', 'boolean'],
|
||||||
|
'display_seach_bar' => ['sometimes', 'boolean'],
|
||||||
|
'display_cart' => ['sometimes', 'boolean'],
|
||||||
|
'cart_editing_policy' => ['sometimes', Rule::enum(CartEditingPolicy::class)],
|
||||||
|
'checkout_editing_policy' => [
|
||||||
|
'sometimes',
|
||||||
|
Rule::in([CartEditingPolicy::Disabled->value]),
|
||||||
|
],
|
||||||
|
'display_cart_item_images' => ['sometimes', 'boolean'],
|
||||||
|
'scanner_category_validation_enabled' => ['sometimes', 'boolean'],
|
||||||
|
'website_type_code' => [
|
||||||
|
'required_with:extras',
|
||||||
|
'sometimes',
|
||||||
|
'string',
|
||||||
|
Rule::exists('website_type', 'codigo'),
|
||||||
|
],
|
||||||
|
], app(WebsiteExtraService::class)->requestRules($this->input('website_type_code')));
|
||||||
|
}
|
||||||
|
}
|
||||||
143
app/Domains/Tenant/Requests/UpdateTenantRequest.php
Normal file
143
app/Domains/Tenant/Requests/UpdateTenantRequest.php
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Tenant\Requests;
|
||||||
|
|
||||||
|
use App\Domains\Catalog\Enums\GroupLayout;
|
||||||
|
use App\Domains\Catalog\Enums\ProductLayout;
|
||||||
|
use App\Domains\Shared\Rules\ImageOrBase64Rule;
|
||||||
|
use App\Domains\Tenant\Enums\CartEditingPolicy;
|
||||||
|
use App\Domains\Tenant\Models\Tenant;
|
||||||
|
use App\Domains\Tenant\Support\TenantDomainNormalizer;
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class UpdateTenantRequest extends FormRequest
|
||||||
|
{
|
||||||
|
protected bool $hasInvalidDomain = false;
|
||||||
|
|
||||||
|
protected bool $hasInvalidBasePath = false;
|
||||||
|
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function prepareForValidation(): void
|
||||||
|
{
|
||||||
|
if ($this->has('dominio')) {
|
||||||
|
$rawDomain = $this->input('dominio');
|
||||||
|
$normalizedDomain = TenantDomainNormalizer::normalize($rawDomain);
|
||||||
|
$embeddedBasePath = TenantDomainNormalizer::pathFromDomain($rawDomain);
|
||||||
|
|
||||||
|
$this->hasInvalidDomain = TenantDomainNormalizer::hasValue($rawDomain)
|
||||||
|
&& ($normalizedDomain === null || $embeddedBasePath === null);
|
||||||
|
|
||||||
|
$this->merge([
|
||||||
|
'dominio' => $normalizedDomain,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (! $this->has('base_path') && $embeddedBasePath !== null && $embeddedBasePath !== '/') {
|
||||||
|
$this->merge(['base_path' => $embeddedBasePath]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->has('base_path')) {
|
||||||
|
$rawBasePath = $this->input('base_path');
|
||||||
|
$normalizedBasePath = TenantDomainNormalizer::normalizePath($rawBasePath);
|
||||||
|
|
||||||
|
$this->hasInvalidBasePath = ! is_string($rawBasePath)
|
||||||
|
|| $normalizedBasePath === null;
|
||||||
|
|
||||||
|
$this->merge(['base_path' => $normalizedBasePath]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
/** @var Tenant|null $tenant */
|
||||||
|
$tenant = $this->route('tenant');
|
||||||
|
$domain = $this->input('dominio', $tenant?->dominio);
|
||||||
|
$basePath = $this->input('base_path', $tenant?->base_path ?? '/');
|
||||||
|
|
||||||
|
$logoRule = ['nullable', new ImageOrBase64Rule];
|
||||||
|
|
||||||
|
return [
|
||||||
|
'client_id' => ['sometimes', 'integer', Rule::exists('clients', 'id')],
|
||||||
|
'codigo' => [
|
||||||
|
'nullable',
|
||||||
|
'string',
|
||||||
|
'max:255',
|
||||||
|
Rule::unique('tenants', 'codigo')->ignore($tenant?->id),
|
||||||
|
],
|
||||||
|
'nombre' => ['nullable', 'string', 'max:255'],
|
||||||
|
'dominio' => [
|
||||||
|
'bail',
|
||||||
|
function (string $attribute, mixed $value, Closure $fail): void {
|
||||||
|
if ($this->hasInvalidDomain) {
|
||||||
|
$fail("The {$attribute} field must contain a valid domain or URL.");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'nullable',
|
||||||
|
'string',
|
||||||
|
'max:255',
|
||||||
|
Rule::unique('tenants', 'dominio')
|
||||||
|
->where('base_path', $basePath)
|
||||||
|
->ignore($tenant?->id),
|
||||||
|
],
|
||||||
|
'base_path' => [
|
||||||
|
'bail',
|
||||||
|
function (string $attribute, mixed $value, Closure $fail): void {
|
||||||
|
if ($this->hasInvalidBasePath) {
|
||||||
|
$fail("The {$attribute} field must contain a valid URL path.");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'nullable',
|
||||||
|
'string',
|
||||||
|
'max:255',
|
||||||
|
Rule::unique('tenants', 'base_path')
|
||||||
|
->where('dominio', $domain)
|
||||||
|
->ignore($tenant?->id),
|
||||||
|
],
|
||||||
|
'site_title' => ['sometimes', 'nullable', 'string', 'max:255'],
|
||||||
|
'address' => ['sometimes', 'nullable', 'string', 'max:255'],
|
||||||
|
'phone' => ['sometimes', 'nullable', 'string', 'max:255'],
|
||||||
|
'primary_color' => ['nullable', 'string', 'regex:/^#([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/'],
|
||||||
|
'secondary_color' => ['nullable', 'string', 'regex:/^#([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/'],
|
||||||
|
'danger_color' => ['nullable', 'string', 'regex:/^#([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/'],
|
||||||
|
'success_color' => ['nullable', 'string', 'regex:/^#([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/'],
|
||||||
|
'header_bg_color' => ['nullable', 'string', 'regex:/^#([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/'],
|
||||||
|
'footer_bg_color' => ['nullable', 'string', 'regex:/^#([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/'],
|
||||||
|
'header_logo' => $logoRule,
|
||||||
|
'footer_logo' => $logoRule,
|
||||||
|
'favicon' => ['sometimes', 'nullable', new ImageOrBase64Rule],
|
||||||
|
'header_bg_image' => ['sometimes', 'nullable', new ImageOrBase64Rule],
|
||||||
|
'footer_bg_image' => ['sometimes', 'nullable', new ImageOrBase64Rule],
|
||||||
|
'social_media' => ['sometimes', 'array'],
|
||||||
|
'social_media.*.code' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'distinct',
|
||||||
|
Rule::exists('social_media', 'code'),
|
||||||
|
],
|
||||||
|
'social_media.*.url' => ['required', 'url', 'max:2048'],
|
||||||
|
'social_media.*.orden' => ['sometimes', 'integer', 'min:0', 'distinct'],
|
||||||
|
'search_product_layout' => ['sometimes', Rule::enum(ProductLayout::class)],
|
||||||
|
'search_group_layout' => ['sometimes', Rule::enum(GroupLayout::class)],
|
||||||
|
'search_items_per_page' => ['sometimes', 'integer', 'min:4', 'max:48'],
|
||||||
|
'display_categories' => ['sometimes', 'boolean'],
|
||||||
|
'display_seach_bar' => ['sometimes', 'boolean'],
|
||||||
|
'display_cart' => ['sometimes', 'boolean'],
|
||||||
|
'cart_editing_policy' => ['sometimes', Rule::enum(CartEditingPolicy::class)],
|
||||||
|
'checkout_editing_policy' => [
|
||||||
|
'sometimes',
|
||||||
|
Rule::in([CartEditingPolicy::Disabled->value]),
|
||||||
|
],
|
||||||
|
'display_cart_item_images' => ['sometimes', 'boolean'],
|
||||||
|
'scanner_category_validation_enabled' => ['sometimes', 'boolean'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Tenant\Resources\AdminApp;
|
||||||
|
|
||||||
|
use App\Domains\Attachable\Models\Attachment;
|
||||||
|
use App\Domains\Attachable\Models\AttachmentCrop;
|
||||||
|
use App\Domains\Tenant\Models\WebsiteExtra;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mixin WebsiteExtra
|
||||||
|
*/
|
||||||
|
class WebsiteExtraResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'codigo' => $this->websiteTypeExtra->codigo,
|
||||||
|
'nombre' => $this->websiteTypeExtra->nombre,
|
||||||
|
'descripcion' => $this->websiteTypeExtra->descripcion,
|
||||||
|
'is_required' => $this->websiteTypeExtra->is_required,
|
||||||
|
'is_enabled' => $this->is_enabled,
|
||||||
|
'request_rules' => $this->websiteTypeExtra->config_schema['request_rules'] ?? [],
|
||||||
|
'config' => $this->formatConfig(
|
||||||
|
$this->resolvedConfig(),
|
||||||
|
fn (Attachment $attachment): string => $attachment->key
|
||||||
|
),
|
||||||
|
'resolved_config' => $this->formatConfig(
|
||||||
|
$this->resolvedAdminConfig(),
|
||||||
|
fn (Attachment $attachment): string => $attachment->getTemporaryUrl(1440)
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function resolvedAdminConfig(): mixed
|
||||||
|
{
|
||||||
|
$config = $this->resolvedConfig();
|
||||||
|
|
||||||
|
if (
|
||||||
|
$this->websiteTypeExtra->codigo !== 'heroConfig'
|
||||||
|
|| ! is_array($config)
|
||||||
|
|| ! ($config['background_image_id'] ?? null) instanceof Attachment
|
||||||
|
) {
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
|
||||||
|
$attachment = $config['background_image_id'];
|
||||||
|
$fullRange = ['start_percentage' => 0.0, 'end_percentage' => 100.0];
|
||||||
|
$crops = $attachment->cropVariants->keyBy('variant');
|
||||||
|
$config['background_image_id'] = [
|
||||||
|
'url' => $attachment->getTemporaryUrl(1440),
|
||||||
|
'crops' => collect(AttachmentCrop::VARIANTS)->mapWithKeys(
|
||||||
|
function (string $variant) use ($crops, $fullRange): array {
|
||||||
|
$crop = $crops->get($variant);
|
||||||
|
|
||||||
|
return [$variant => [
|
||||||
|
'crop_horizontal' => $crop?->crop_horizontal ?? $fullRange,
|
||||||
|
'crop_vertical' => $crop?->crop_vertical ?? $fullRange,
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
)->all(),
|
||||||
|
];
|
||||||
|
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function formatConfig(mixed $value, callable $formatAttachment): mixed
|
||||||
|
{
|
||||||
|
if ($value instanceof Attachment) {
|
||||||
|
return $formatAttachment($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! is_array($value)) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_map(
|
||||||
|
fn (mixed $item): mixed => $this->formatConfig($item, $formatAttachment),
|
||||||
|
$value
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -82,7 +82,6 @@ class WebsiteTypeService
|
|||||||
&& $previousLogo->id !== $websiteType->site_logo
|
&& $previousLogo->id !== $websiteType->site_logo
|
||||||
&& $previousLogo->id !== $websiteType->footer_logo
|
&& $previousLogo->id !== $websiteType->footer_logo
|
||||||
&& $previousLogo->id !== $websiteType->favicon_id
|
&& $previousLogo->id !== $websiteType->favicon_id
|
||||||
&& ! $this->isReferencedByWebsiteType($previousLogo)
|
|
||||||
) {
|
) {
|
||||||
$this->attachmentService->delete($previousLogo);
|
$this->attachmentService->delete($previousLogo);
|
||||||
}
|
}
|
||||||
@@ -91,16 +90,4 @@ class WebsiteTypeService
|
|||||||
return $websiteType;
|
return $websiteType;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isReferencedByWebsiteType(Attachment $attachment): bool
|
|
||||||
{
|
|
||||||
return WebsiteType::query()
|
|
||||||
->where(function ($query) use ($attachment): void {
|
|
||||||
$query
|
|
||||||
->where('site_logo', $attachment->id)
|
|
||||||
->orWhere('footer_logo', $attachment->id)
|
|
||||||
->orWhere('favicon_id', $attachment->id);
|
|
||||||
})
|
|
||||||
->exists();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ Route::prefix('v1/adminapp/tenant')
|
|||||||
->middleware(['auth:sanctum', 'adminapp.tenant'])
|
->middleware(['auth:sanctum', 'adminapp.tenant'])
|
||||||
->group(function (): void {
|
->group(function (): void {
|
||||||
Route::get('website-extras', [WebsiteExtraController::class, 'show']);
|
Route::get('website-extras', [WebsiteExtraController::class, 'show']);
|
||||||
|
Route::get('website-extras/{websiteExtraCode}', [WebsiteExtraController::class, 'showExtra']);
|
||||||
Route::put('website-extras/{websiteExtraCode}', [WebsiteExtraController::class, 'update']);
|
Route::put('website-extras/{websiteExtraCode}', [WebsiteExtraController::class, 'update']);
|
||||||
Route::patch('website-extras/{websiteExtraCode}/toggle', [WebsiteExtraController::class, 'toggle']);
|
Route::patch('website-extras/{websiteExtraCode}/toggle', [WebsiteExtraController::class, 'toggle']);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Domains\Tenant\Controllers\TenantController;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
Route::apiResource('tenants', TenantController::class);
|
||||||
|
|
||||||
require __DIR__.'/adminapp.php';
|
require __DIR__.'/adminapp.php';
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
namespace App\Domains\Ticket\Listeners;
|
namespace App\Domains\Ticket\Listeners;
|
||||||
|
|
||||||
use App\Domains\Catalog\Models\CatalogItem;
|
use App\Domains\Catalog\Models\CatalogItem;
|
||||||
|
use App\Domains\Notification\Events\TicketsAvailable;
|
||||||
use App\Domains\Purchase\Events\PurchasePaid;
|
use App\Domains\Purchase\Events\PurchasePaid;
|
||||||
use App\Domains\Purchase\Models\Purchase;
|
|
||||||
use App\Domains\Ticket\Exceptions\TicketGenerationException;
|
use App\Domains\Ticket\Exceptions\TicketGenerationException;
|
||||||
use App\Domains\Ticket\Services\TicketGeneratorService;
|
use App\Domains\Ticket\Services\TicketGeneratorService;
|
||||||
|
|
||||||
@@ -16,10 +16,13 @@ class GenerateTicketsForPaidPurchase
|
|||||||
|
|
||||||
public function handle(PurchasePaid $event): void
|
public function handle(PurchasePaid $event): void
|
||||||
{
|
{
|
||||||
$purchase = Purchase::query()
|
$purchase = $event->purchase
|
||||||
|
->newQuery()
|
||||||
->with(['user', 'items'])
|
->with(['user', 'items'])
|
||||||
->findOrFail($event->purchaseId);
|
->findOrFail($event->purchase->getKey());
|
||||||
$user = $purchase->user;
|
$user = $purchase->user;
|
||||||
|
$ticketIds = [];
|
||||||
|
|
||||||
foreach ($purchase->items as $purchaseItem) {
|
foreach ($purchase->items as $purchaseItem) {
|
||||||
$catalogItem = CatalogItem::query()
|
$catalogItem = CatalogItem::query()
|
||||||
->where('tenant_code', $purchase->tenant_codigo)
|
->where('tenant_code', $purchase->tenant_codigo)
|
||||||
@@ -37,13 +40,19 @@ class GenerateTicketsForPaidPurchase
|
|||||||
throw TicketGenerationException::purchaseWithoutUser($purchase);
|
throw TicketGenerationException::purchaseWithoutUser($purchase);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->ticketGenerator->generate(
|
$generatedTickets = $this->ticketGenerator->generate(
|
||||||
$catalogItem,
|
$catalogItem,
|
||||||
$user,
|
$user,
|
||||||
$purchaseItem->cantidad,
|
$purchaseItem->cantidad,
|
||||||
$purchaseItem->source_variant_id,
|
$purchaseItem->source_variant_id,
|
||||||
$purchase->getKey(),
|
$purchase->getKey(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
array_push($ticketIds, ...$generatedTickets->pluck('id')->all());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ticketIds !== []) {
|
||||||
|
TicketsAvailable::dispatch($purchase, $ticketIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ namespace App\Domains\Ticket\Services;
|
|||||||
use App\Domains\Tenant\Models\Tenant;
|
use App\Domains\Tenant\Models\Tenant;
|
||||||
use App\Domains\Ticket\Models\Ticket;
|
use App\Domains\Ticket\Models\Ticket;
|
||||||
use Barryvdh\DomPDF\Facade\Pdf;
|
use Barryvdh\DomPDF\Facade\Pdf;
|
||||||
use Barryvdh\DomPDF\PDF as DomPdf;
|
|
||||||
use Endroid\QrCode\ErrorCorrectionLevel;
|
use Endroid\QrCode\ErrorCorrectionLevel;
|
||||||
use Endroid\QrCode\QrCode;
|
use Endroid\QrCode\QrCode;
|
||||||
use Endroid\QrCode\Writer\PngWriter;
|
use Endroid\QrCode\Writer\PngWriter;
|
||||||
@@ -20,36 +19,12 @@ class TicketPdfService
|
|||||||
* @param Collection<int, Ticket> $tickets
|
* @param Collection<int, Ticket> $tickets
|
||||||
*/
|
*/
|
||||||
public function download(Tenant $tenant, Collection $tickets): Response
|
public function download(Tenant $tenant, Collection $tickets): Response
|
||||||
{
|
|
||||||
return $this->pdf($tenant, $tickets)->download($this->filename($tickets));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Collection<int, Ticket> $tickets
|
|
||||||
*/
|
|
||||||
public function contents(Tenant $tenant, Collection $tickets): string
|
|
||||||
{
|
|
||||||
return $this->pdf($tenant, $tickets)->output();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Collection<int, Ticket> $tickets
|
|
||||||
*/
|
|
||||||
public function filename(Collection $tickets): string
|
|
||||||
{
|
|
||||||
return 'tickets_'.$tickets->pluck('id')->implode('_').'.pdf';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Collection<int, Ticket> $tickets
|
|
||||||
*/
|
|
||||||
private function pdf(Tenant $tenant, Collection $tickets): DomPdf
|
|
||||||
{
|
{
|
||||||
$tenant->loadMissing('headerLogo');
|
$tenant->loadMissing('headerLogo');
|
||||||
$primaryColor = $this->color($tenant->primary_color, '#009933');
|
$primaryColor = $this->color($tenant->primary_color, '#009933');
|
||||||
$headerBackgroundColor = $this->color($tenant->header_bg_color, $primaryColor);
|
$headerBackgroundColor = $this->color($tenant->header_bg_color, $primaryColor);
|
||||||
|
|
||||||
return Pdf::loadView('pdf.tickets', [
|
$pdf = Pdf::loadView('pdf.tickets', [
|
||||||
'tenant' => $tenant,
|
'tenant' => $tenant,
|
||||||
'tickets' => $tickets,
|
'tickets' => $tickets,
|
||||||
'logoDataUri' => $this->logoDataUri($tenant),
|
'logoDataUri' => $this->logoDataUri($tenant),
|
||||||
@@ -60,6 +35,10 @@ class TicketPdfService
|
|||||||
fn (Ticket $ticket): array => [$ticket->id => $this->qrCodeDataUri($ticket->ticket)]
|
fn (Ticket $ticket): array => [$ticket->id => $this->qrCodeDataUri($ticket->ticket)]
|
||||||
),
|
),
|
||||||
])->setPaper('a4');
|
])->setPaper('a4');
|
||||||
|
|
||||||
|
$ticketIds = $tickets->pluck('id')->implode('_');
|
||||||
|
|
||||||
|
return $pdf->download("tickets_{$ticketIds}.pdf");
|
||||||
}
|
}
|
||||||
|
|
||||||
private function qrCodeDataUri(string $value): string
|
private function qrCodeDataUri(string $value): string
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ vigente, vencido o usado, y resuelve sus fechas efectivas de inicio y fin sin pe
|
|||||||
1. `Purchase` emite `PurchasePaid` al confirmarse el pago.
|
1. `Purchase` emite `PurchasePaid` al confirmarse el pago.
|
||||||
2. `GenerateTicketsForPaidPurchase` atiende el evento.
|
2. `GenerateTicketsForPaidPurchase` atiende el evento.
|
||||||
3. `TicketGeneratorService` crea los tickets requeridos según ítems, cantidades y vigencia.
|
3. `TicketGeneratorService` crea los tickets requeridos según ítems, cantidades y vigencia.
|
||||||
4. `Notification` envía la confirmación de compra después de la generación y adjunta los tickets cuando existen.
|
4. El flujo puede emitir disponibilidad para que `Notification` informe al comprador.
|
||||||
|
|
||||||
## Endpoints
|
## Endpoints
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,11 @@
|
|||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use App\Domains\Notification\Events\PasswordResetRequested;
|
use App\Domains\Notification\Events\PasswordResetRequested;
|
||||||
|
use App\Domains\Notification\Events\TicketsAvailable;
|
||||||
use App\Domains\Notification\Events\UserRegistered;
|
use App\Domains\Notification\Events\UserRegistered;
|
||||||
use App\Domains\Notification\Listeners\SendPasswordResetEmail;
|
use App\Domains\Notification\Listeners\SendPasswordResetEmail;
|
||||||
use App\Domains\Notification\Listeners\SendPurchaseConfirmedEmail;
|
use App\Domains\Notification\Listeners\SendPurchasePaidEmail;
|
||||||
|
use App\Domains\Notification\Listeners\SendTicketsAvailableEmail;
|
||||||
use App\Domains\Notification\Listeners\SendWelcomeEmail;
|
use App\Domains\Notification\Listeners\SendWelcomeEmail;
|
||||||
use App\Domains\Purchase\Events\PurchasePaid;
|
use App\Domains\Purchase\Events\PurchasePaid;
|
||||||
use App\Domains\Ticket\Listeners\GenerateTicketsForPaidPurchase;
|
use App\Domains\Ticket\Listeners\GenerateTicketsForPaidPurchase;
|
||||||
@@ -31,8 +33,9 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
|
Event::listen(PurchasePaid::class, SendPurchasePaidEmail::class);
|
||||||
Event::listen(PurchasePaid::class, GenerateTicketsForPaidPurchase::class);
|
Event::listen(PurchasePaid::class, GenerateTicketsForPaidPurchase::class);
|
||||||
Event::listen(PurchasePaid::class, SendPurchaseConfirmedEmail::class);
|
Event::listen(TicketsAvailable::class, SendTicketsAvailableEmail::class);
|
||||||
Event::listen(UserRegistered::class, SendWelcomeEmail::class);
|
Event::listen(UserRegistered::class, SendWelcomeEmail::class);
|
||||||
Event::listen(PasswordResetRequested::class, SendPasswordResetEmail::class);
|
Event::listen(PasswordResetRequested::class, SendPasswordResetEmail::class);
|
||||||
|
|
||||||
|
|||||||
@@ -6,16 +6,15 @@
|
|||||||
"keywords": ["laravel", "framework"],
|
"keywords": ["laravel", "framework"],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.3",
|
|
||||||
"ext-gd": "*",
|
"ext-gd": "*",
|
||||||
|
"php": "^8.3",
|
||||||
"barryvdh/laravel-dompdf": "^3.1",
|
"barryvdh/laravel-dompdf": "^3.1",
|
||||||
"endroid/qr-code": "^6.1",
|
"endroid/qr-code": "^6.1",
|
||||||
"laravel/framework": "^13.8",
|
"laravel/framework": "^13.8",
|
||||||
"laravel/sanctum": "^4.3",
|
"laravel/sanctum": "^4.3",
|
||||||
"laravel/socialite": "^5.29",
|
"laravel/socialite": "^5.29",
|
||||||
"laravel/tinker": "^3.0",
|
"laravel/tinker": "^3.0",
|
||||||
"league/flysystem-aws-s3-v3": "^3.0",
|
"league/flysystem-aws-s3-v3": "^3.0"
|
||||||
"phpoffice/phpspreadsheet": "^5.9"
|
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"fakerphp/faker": "^1.23",
|
"fakerphp/faker": "^1.23",
|
||||||
|
|||||||
376
composer.lock
generated
376
composer.lock
generated
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "a593ab47d99b233f75851dbb7ea50479",
|
"content-hash": "ce185c60c617846be30ae694f0cf6e9c",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "aws/aws-crt-php",
|
"name": "aws/aws-crt-php",
|
||||||
@@ -417,82 +417,6 @@
|
|||||||
],
|
],
|
||||||
"time": "2024-02-09T16:56:22+00:00"
|
"time": "2024-02-09T16:56:22+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "composer/pcre",
|
|
||||||
"version": "3.4.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/composer/pcre.git",
|
|
||||||
"reference": "d5a341b3fb61f3001970940afb1d332968a183ed"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/composer/pcre/zipball/d5a341b3fb61f3001970940afb1d332968a183ed",
|
|
||||||
"reference": "d5a341b3fb61f3001970940afb1d332968a183ed",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^7.4 || ^8.0"
|
|
||||||
},
|
|
||||||
"conflict": {
|
|
||||||
"phpstan/phpstan": "<2.2.2"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"phpstan/phpstan": "^2",
|
|
||||||
"phpstan/phpstan-deprecation-rules": "^2",
|
|
||||||
"phpstan/phpstan-strict-rules": "^2",
|
|
||||||
"phpunit/phpunit": "^9"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"phpstan": {
|
|
||||||
"includes": [
|
|
||||||
"extension.neon"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-main": "3.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Composer\\Pcre\\": "src"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Jordi Boggiano",
|
|
||||||
"email": "j.boggiano@seld.be",
|
|
||||||
"homepage": "http://seld.be"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "PCRE wrapping library that offers type-safe preg_* replacements.",
|
|
||||||
"keywords": [
|
|
||||||
"PCRE",
|
|
||||||
"preg",
|
|
||||||
"regex",
|
|
||||||
"regular expression"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/composer/pcre/issues",
|
|
||||||
"source": "https://github.com/composer/pcre/tree/3.4.0"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://packagist.com",
|
|
||||||
"type": "custom"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://github.com/composer",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"time": "2026-06-07T11:47:49+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "dasprid/enum",
|
"name": "dasprid/enum",
|
||||||
"version": "1.0.7",
|
"version": "1.0.7",
|
||||||
@@ -3000,191 +2924,6 @@
|
|||||||
],
|
],
|
||||||
"time": "2026-03-08T20:05:35+00:00"
|
"time": "2026-03-08T20:05:35+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "maennchen/zipstream-php",
|
|
||||||
"version": "3.2.2",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/maennchen/ZipStream-PHP.git",
|
|
||||||
"reference": "77bebeb4c6c340bb3c11c843b2cffd8bbfde4d5e"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/77bebeb4c6c340bb3c11c843b2cffd8bbfde4d5e",
|
|
||||||
"reference": "77bebeb4c6c340bb3c11c843b2cffd8bbfde4d5e",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"ext-mbstring": "*",
|
|
||||||
"ext-zlib": "*",
|
|
||||||
"php-64bit": "^8.3"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"brianium/paratest": "^7.7",
|
|
||||||
"ext-zip": "*",
|
|
||||||
"friendsofphp/php-cs-fixer": "^3.86",
|
|
||||||
"guzzlehttp/guzzle": "^7.5",
|
|
||||||
"mikey179/vfsstream": "^1.6",
|
|
||||||
"php-coveralls/php-coveralls": "^2.5",
|
|
||||||
"phpunit/phpunit": "^12.0",
|
|
||||||
"vimeo/psalm": "^6.0"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"guzzlehttp/psr7": "^2.4",
|
|
||||||
"psr/http-message": "^2.0"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"ZipStream\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Paul Duncan",
|
|
||||||
"email": "pabs@pablotron.org"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Jonatan Männchen",
|
|
||||||
"email": "jonatan@maennchen.ch"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Jesse Donat",
|
|
||||||
"email": "donatj@gmail.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "András Kolesár",
|
|
||||||
"email": "kolesar@kolesar.hu"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.",
|
|
||||||
"keywords": [
|
|
||||||
"stream",
|
|
||||||
"zip"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/maennchen/ZipStream-PHP/issues",
|
|
||||||
"source": "https://github.com/maennchen/ZipStream-PHP/tree/3.2.2"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://github.com/maennchen",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"time": "2026-04-11T18:38:28+00:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "markbaker/complex",
|
|
||||||
"version": "3.0.2",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/MarkBaker/PHPComplex.git",
|
|
||||||
"reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
|
|
||||||
"reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^7.2 || ^8.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
|
|
||||||
"phpcompatibility/php-compatibility": "^9.3",
|
|
||||||
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
|
|
||||||
"squizlabs/php_codesniffer": "^3.7"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Complex\\": "classes/src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Mark Baker",
|
|
||||||
"email": "mark@lange.demon.co.uk"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "PHP Class for working with complex numbers",
|
|
||||||
"homepage": "https://github.com/MarkBaker/PHPComplex",
|
|
||||||
"keywords": [
|
|
||||||
"complex",
|
|
||||||
"mathematics"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/MarkBaker/PHPComplex/issues",
|
|
||||||
"source": "https://github.com/MarkBaker/PHPComplex/tree/3.0.2"
|
|
||||||
},
|
|
||||||
"time": "2022-12-06T16:21:08+00:00"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "markbaker/matrix",
|
|
||||||
"version": "3.0.1",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/MarkBaker/PHPMatrix.git",
|
|
||||||
"reference": "728434227fe21be27ff6d86621a1b13107a2562c"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/728434227fe21be27ff6d86621a1b13107a2562c",
|
|
||||||
"reference": "728434227fe21be27ff6d86621a1b13107a2562c",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^7.1 || ^8.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
|
|
||||||
"phpcompatibility/php-compatibility": "^9.3",
|
|
||||||
"phpdocumentor/phpdocumentor": "2.*",
|
|
||||||
"phploc/phploc": "^4.0",
|
|
||||||
"phpmd/phpmd": "2.*",
|
|
||||||
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
|
|
||||||
"sebastian/phpcpd": "^4.0",
|
|
||||||
"squizlabs/php_codesniffer": "^3.7"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Matrix\\": "classes/src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Mark Baker",
|
|
||||||
"email": "mark@demon-angel.eu"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "PHP Class for working with matrices",
|
|
||||||
"homepage": "https://github.com/MarkBaker/PHPMatrix",
|
|
||||||
"keywords": [
|
|
||||||
"mathematics",
|
|
||||||
"matrix",
|
|
||||||
"vector"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/MarkBaker/PHPMatrix/issues",
|
|
||||||
"source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.1"
|
|
||||||
},
|
|
||||||
"time": "2022-12-02T22:17:43+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "masterminds/html5",
|
"name": "masterminds/html5",
|
||||||
"version": "2.10.1",
|
"version": "2.10.1",
|
||||||
@@ -3947,115 +3686,6 @@
|
|||||||
},
|
},
|
||||||
"time": "2020-10-15T08:29:30+00:00"
|
"time": "2020-10-15T08:29:30+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "phpoffice/phpspreadsheet",
|
|
||||||
"version": "5.9.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
|
|
||||||
"reference": "05e99ebf61238a70227b4d9cc02d0030d34f6339"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/05e99ebf61238a70227b4d9cc02d0030d34f6339",
|
|
||||||
"reference": "05e99ebf61238a70227b4d9cc02d0030d34f6339",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"composer/pcre": "^1||^2||^3",
|
|
||||||
"ext-ctype": "*",
|
|
||||||
"ext-dom": "*",
|
|
||||||
"ext-fileinfo": "*",
|
|
||||||
"ext-filter": "*",
|
|
||||||
"ext-gd": "*",
|
|
||||||
"ext-iconv": "*",
|
|
||||||
"ext-libxml": "*",
|
|
||||||
"ext-mbstring": "*",
|
|
||||||
"ext-simplexml": "*",
|
|
||||||
"ext-xml": "*",
|
|
||||||
"ext-xmlreader": "*",
|
|
||||||
"ext-xmlwriter": "*",
|
|
||||||
"ext-zip": "*",
|
|
||||||
"ext-zlib": "*",
|
|
||||||
"maennchen/zipstream-php": "^2.1 || ^3.0",
|
|
||||||
"markbaker/complex": "^3.0",
|
|
||||||
"markbaker/matrix": "^3.0",
|
|
||||||
"php": "^8.2",
|
|
||||||
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"dealerdirect/phpcodesniffer-composer-installer": "dev-main",
|
|
||||||
"dompdf/dompdf": "^2.0 || ^3.0",
|
|
||||||
"ext-intl": "*",
|
|
||||||
"friendsofphp/php-cs-fixer": "^3.2",
|
|
||||||
"mitoteam/jpgraph": "^10.5",
|
|
||||||
"mpdf/mpdf": "^8.1.1",
|
|
||||||
"phpcompatibility/php-compatibility": "^9.3",
|
|
||||||
"phpstan/phpstan": "^1.1 || ^2.0",
|
|
||||||
"phpstan/phpstan-deprecation-rules": "^1.0 || ^2.0",
|
|
||||||
"phpstan/phpstan-phpunit": "^1.0 || ^2.0",
|
|
||||||
"phpunit/phpunit": "^10.5 || ^11.0",
|
|
||||||
"squizlabs/php_codesniffer": "^3.7",
|
|
||||||
"tecnickcom/tcpdf": "^6.5"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"dompdf/dompdf": "Option for rendering PDF with PDF Writer",
|
|
||||||
"ext-intl": "PHP Internationalization Functions, required for NumberFormat Wizard and StringHelper::setLocale()",
|
|
||||||
"mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
|
|
||||||
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
|
|
||||||
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Maarten Balliauw",
|
|
||||||
"homepage": "https://blog.maartenballiauw.be"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Mark Baker",
|
|
||||||
"homepage": "https://markbakeruk.net"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Franck Lefevre",
|
|
||||||
"homepage": "https://rootslabs.net"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Erik Tilt"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Adrien Crivelli"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Owen Leibman"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
|
|
||||||
"homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
|
|
||||||
"keywords": [
|
|
||||||
"OpenXML",
|
|
||||||
"excel",
|
|
||||||
"gnumeric",
|
|
||||||
"ods",
|
|
||||||
"php",
|
|
||||||
"spreadsheet",
|
|
||||||
"xls",
|
|
||||||
"xlsx"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues",
|
|
||||||
"source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/5.9.0"
|
|
||||||
},
|
|
||||||
"time": "2026-07-12T19:17:39+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "phpoption/phpoption",
|
"name": "phpoption/phpoption",
|
||||||
"version": "1.9.5",
|
"version": "1.9.5",
|
||||||
@@ -10208,8 +9838,8 @@
|
|||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": {
|
"platform": {
|
||||||
"php": "^8.3",
|
"ext-gd": "*",
|
||||||
"ext-gd": "*"
|
"php": "^8.3"
|
||||||
},
|
},
|
||||||
"platform-dev": {},
|
"platform-dev": {},
|
||||||
"plugin-api-version": "2.9.0"
|
"plugin-api-version": "2.9.0"
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ return [
|
|||||||
'users' => [
|
'users' => [
|
||||||
'provider' => 'users',
|
'provider' => 'users',
|
||||||
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
|
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
|
||||||
'expire' => (int) env('AUTH_PASSWORD_RESET_EXPIRATION_MINUTES', 60),
|
'expire' => 60,
|
||||||
'throttle' => 60,
|
'throttle' => 60,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -89,14 +89,6 @@ return [
|
|||||||
'replace_placeholders' => true,
|
'replace_placeholders' => true,
|
||||||
],
|
],
|
||||||
|
|
||||||
'emails' => [
|
|
||||||
'driver' => 'daily',
|
|
||||||
'path' => storage_path('logs/emails/emails.log'),
|
|
||||||
'level' => env('EMAILS_LOG_LEVEL', 'info'),
|
|
||||||
'days' => env('EMAILS_LOG_DAYS', 30),
|
|
||||||
'replace_placeholders' => true,
|
|
||||||
],
|
|
||||||
|
|
||||||
'slack' => [
|
'slack' => [
|
||||||
'driver' => 'slack',
|
'driver' => 'slack',
|
||||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||||
|
|||||||
@@ -2,4 +2,10 @@
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'checkout_expiration_minutes' => (int) env('PURCHASE_CHECKOUT_EXPIRATION_MINUTES', 30),
|
'checkout_expiration_minutes' => (int) env('PURCHASE_CHECKOUT_EXPIRATION_MINUTES', 30),
|
||||||
|
|
||||||
|
'payment_expiration_minutes' => [
|
||||||
|
'qr' => (int) env('PURCHASE_QR_EXPIRATION_MINUTES', 15),
|
||||||
|
'telepagos' => (int) env('PURCHASE_TELEPAGOS_EXPIRATION_MINUTES', 30),
|
||||||
|
'transfer' => (int) env('PURCHASE_TRANSFER_EXPIRATION_MINUTES', 1440),
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use App\Domains\Auth\Models\ResetPasswordAttempt;
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
public function up(): void
|
|
||||||
{
|
|
||||||
Schema::table('reset_password_attempts', function (Blueprint $table): void {
|
|
||||||
$table->timestamp('expires_at')->nullable()->after('status');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Attempts created before this migration did not have an expiration instant.
|
|
||||||
DB::table('reset_password_attempts')
|
|
||||||
->whereIn('status', [
|
|
||||||
ResetPasswordAttempt::STATUS_PENDING,
|
|
||||||
ResetPasswordAttempt::STATUS_VALIDATED,
|
|
||||||
])
|
|
||||||
->update(['status' => ResetPasswordAttempt::STATUS_EXPIRED]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
Schema::table('reset_password_attempts', function (Blueprint $table): void {
|
|
||||||
$table->dropColumn('expires_at');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
private const FILENAME = 'onticket_favicon.svg';
|
|
||||||
|
|
||||||
/** @var list<string> */
|
|
||||||
private const WEBSITE_TYPE_CODES = ['shopit', 'onticket'];
|
|
||||||
|
|
||||||
public function up(): void
|
|
||||||
{
|
|
||||||
$websiteTypes = DB::table('website_type')
|
|
||||||
->whereIn('codigo', self::WEBSITE_TYPE_CODES)
|
|
||||||
->get(['codigo', 'favicon_id']);
|
|
||||||
|
|
||||||
if ($websiteTypes->isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$faviconIds = $websiteTypes
|
|
||||||
->pluck('favicon_id')
|
|
||||||
->filter()
|
|
||||||
->unique()
|
|
||||||
->values();
|
|
||||||
|
|
||||||
if (
|
|
||||||
$faviconIds->count() === 1
|
|
||||||
&& DB::table('attachments')
|
|
||||||
->where('id', $faviconIds->first())
|
|
||||||
->where('filename', self::FILENAME)
|
|
||||||
->exists()
|
|
||||||
&& $websiteTypes->every(
|
|
||||||
fn (object $websiteType): bool => $websiteType->favicon_id === $faviconIds->first()
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sourcePath = public_path('images/website_types/'.self::FILENAME);
|
|
||||||
|
|
||||||
if (! is_file($sourcePath)) {
|
|
||||||
throw new RuntimeException("Favicon not found at path: {$sourcePath}");
|
|
||||||
}
|
|
||||||
|
|
||||||
$contents = file_get_contents($sourcePath);
|
|
||||||
|
|
||||||
if ($contents === false) {
|
|
||||||
throw new RuntimeException("Could not read favicon at path: {$sourcePath}");
|
|
||||||
}
|
|
||||||
|
|
||||||
$key = (string) Str::uuid();
|
|
||||||
$storedPath = "website-types/{$key}.svg";
|
|
||||||
|
|
||||||
if (! Storage::disk('s3')->put($storedPath, $contents)) {
|
|
||||||
throw new RuntimeException("Could not store favicon at path: {$storedPath}");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
DB::transaction(function () use ($contents, $key, $storedPath): void {
|
|
||||||
$attachmentId = DB::table('attachments')->insertGetId([
|
|
||||||
'key' => $key,
|
|
||||||
'path' => $storedPath,
|
|
||||||
'filename' => self::FILENAME,
|
|
||||||
'type' => 'image',
|
|
||||||
'mime_type' => 'image/svg+xml',
|
|
||||||
'extension' => 'svg',
|
|
||||||
'size' => strlen($contents),
|
|
||||||
'created_at' => now(),
|
|
||||||
'updated_at' => now(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
DB::table('website_type')
|
|
||||||
->whereIn('codigo', self::WEBSITE_TYPE_CODES)
|
|
||||||
->update([
|
|
||||||
'favicon_id' => $attachmentId,
|
|
||||||
'updated_at' => now(),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
} catch (Throwable $throwable) {
|
|
||||||
Storage::disk('s3')->delete($storedPath);
|
|
||||||
|
|
||||||
throw $throwable;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
// The shared attachment may be in use outside these website types.
|
|
||||||
// Keep this data migration irreversible to avoid deleting an active asset.
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -191,7 +191,6 @@ class DesfilePuraTendenciaSeeder extends Seeder
|
|||||||
|
|
||||||
FeaturedGroup::query()->create([
|
FeaturedGroup::query()->create([
|
||||||
'tenant_code' => self::TENANT_CODE,
|
'tenant_code' => self::TENANT_CODE,
|
||||||
'code' => 'entradas',
|
|
||||||
'source_type' => FeaturedGroupSource::All,
|
'source_type' => FeaturedGroupSource::All,
|
||||||
'category_id' => null,
|
'category_id' => null,
|
||||||
'product_layout' => ProductLayout::TicketSelector,
|
'product_layout' => ProductLayout::TicketSelector,
|
||||||
|
|||||||
@@ -144,7 +144,6 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
|
|||||||
|
|
||||||
FeaturedGroup::query()->create([
|
FeaturedGroup::query()->create([
|
||||||
'tenant_code' => $tenant->codigo,
|
'tenant_code' => $tenant->codigo,
|
||||||
'code' => 'productos',
|
|
||||||
'source_type' => FeaturedGroupSource::All,
|
'source_type' => FeaturedGroupSource::All,
|
||||||
'category_id' => null,
|
'category_id' => null,
|
||||||
'product_layout' => ProductLayout::Row,
|
'product_layout' => ProductLayout::Row,
|
||||||
|
|||||||
@@ -171,7 +171,6 @@ class ProductCatalogFromImagesSeeder extends Seeder
|
|||||||
|
|
||||||
FeaturedGroup::query()->create([
|
FeaturedGroup::query()->create([
|
||||||
'tenant_code' => $tenant->codigo,
|
'tenant_code' => $tenant->codigo,
|
||||||
'code' => 'productos',
|
|
||||||
'source_type' => FeaturedGroupSource::All,
|
'source_type' => FeaturedGroupSource::All,
|
||||||
'product_layout' => ProductLayout::ColumnWithImage,
|
'product_layout' => ProductLayout::ColumnWithImage,
|
||||||
'group_layout' => GroupLayout::Paginated,
|
'group_layout' => GroupLayout::Paginated,
|
||||||
@@ -181,7 +180,6 @@ class ProductCatalogFromImagesSeeder extends Seeder
|
|||||||
|
|
||||||
$carouselGroup = FeaturedGroup::query()->create([
|
$carouselGroup = FeaturedGroup::query()->create([
|
||||||
'tenant_code' => $tenant->codigo,
|
'tenant_code' => $tenant->codigo,
|
||||||
'code' => 'productos-destacados',
|
|
||||||
'source_type' => FeaturedGroupSource::Manual,
|
'source_type' => FeaturedGroupSource::Manual,
|
||||||
'product_layout' => ProductLayout::ColumnWithImage,
|
'product_layout' => ProductLayout::ColumnWithImage,
|
||||||
'group_layout' => GroupLayout::Carousel,
|
'group_layout' => GroupLayout::Carousel,
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ class WebsiteTypeSeeder extends Seeder
|
|||||||
...self::PRESENTATION,
|
...self::PRESENTATION,
|
||||||
'site_logo' => $this->onTicketLogo(),
|
'site_logo' => $this->onTicketLogo(),
|
||||||
'footer_logo' => $this->onTicketFooterLogo(),
|
'footer_logo' => $this->onTicketFooterLogo(),
|
||||||
'favicon' => $this->onTicketFavicon(),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -71,7 +70,6 @@ class WebsiteTypeSeeder extends Seeder
|
|||||||
...self::PRESENTATION,
|
...self::PRESENTATION,
|
||||||
'site_logo' => $this->onTicketLogo(),
|
'site_logo' => $this->onTicketLogo(),
|
||||||
'footer_logo' => $this->onTicketFooterLogo(),
|
'footer_logo' => $this->onTicketFooterLogo(),
|
||||||
'favicon' => $shopIt->favicon()->firstOrFail()->key,
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -177,21 +175,4 @@ class WebsiteTypeSeeder extends Seeder
|
|||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function onTicketFavicon(): UploadedFile
|
|
||||||
{
|
|
||||||
$path = public_path('images/website_types/onticket_favicon.svg');
|
|
||||||
|
|
||||||
if (! file_exists($path)) {
|
|
||||||
throw new RuntimeException("OnTicket favicon not found at path: {$path}");
|
|
||||||
}
|
|
||||||
|
|
||||||
return new UploadedFile(
|
|
||||||
$path,
|
|
||||||
'onticket_favicon.svg',
|
|
||||||
'image/svg+xml',
|
|
||||||
null,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ return [
|
|||||||
'password_reset_invalid' => 'The password recovery request is invalid or has already been used.',
|
'password_reset_invalid' => 'The password recovery request is invalid or has already been used.',
|
||||||
'password_updated' => 'Password updated successfully.',
|
'password_updated' => 'Password updated successfully.',
|
||||||
'reset_code_invalid' => 'The code you entered is invalid.',
|
'reset_code_invalid' => 'The code you entered is invalid.',
|
||||||
'reset_code_expired' => 'The password recovery code expired. Request a new one.',
|
|
||||||
'reset_code_valid' => 'Code validated successfully.',
|
'reset_code_valid' => 'Code validated successfully.',
|
||||||
'invalid_tenant_or_return_url' => 'The tenant or return URL is invalid.',
|
'invalid_tenant_or_return_url' => 'The tenant or return URL is invalid.',
|
||||||
'request_expired' => 'The authentication request expired. Please try again.',
|
'request_expired' => 'The authentication request expired. Please try again.',
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ return [
|
|||||||
'password_reset_invalid' => 'La solicitud de recuperación es inválida o ya fue utilizada.',
|
'password_reset_invalid' => 'La solicitud de recuperación es inválida o ya fue utilizada.',
|
||||||
'password_updated' => 'Contraseña modificada correctamente.',
|
'password_updated' => 'Contraseña modificada correctamente.',
|
||||||
'reset_code_invalid' => 'El código ingresado es inválido.',
|
'reset_code_invalid' => 'El código ingresado es inválido.',
|
||||||
'reset_code_expired' => 'El código de recuperación expiró. Solicitá uno nuevo.',
|
|
||||||
'reset_code_valid' => 'Código validado correctamente.',
|
'reset_code_valid' => 'Código validado correctamente.',
|
||||||
'invalid_tenant_or_return_url' => 'El tenant o la URL de retorno no son válidos.',
|
'invalid_tenant_or_return_url' => 'El tenant o la URL de retorno no son válidos.',
|
||||||
'request_expired' => 'La solicitud de autenticación expiró. Intenta nuevamente.',
|
'request_expired' => 'La solicitud de autenticación expiró. Intenta nuevamente.',
|
||||||
|
|||||||
95
postman/attachable-s3-testing.postman_collection.json
Normal file
95
postman/attachable-s3-testing.postman_collection.json
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
{
|
||||||
|
"info": {
|
||||||
|
"_postman_id": "8faefdb8-734a-4262-a3b6-4d49e56ea901",
|
||||||
|
"name": "Storage Test S3",
|
||||||
|
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
||||||
|
},
|
||||||
|
"variable": [
|
||||||
|
{
|
||||||
|
"key": "base_url",
|
||||||
|
"value": "http://127.0.0.1:8000"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "expires_in_minutes",
|
||||||
|
"value": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "path",
|
||||||
|
"value": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"item": [
|
||||||
|
{
|
||||||
|
"name": "Upload Test File",
|
||||||
|
"request": {
|
||||||
|
"method": "POST",
|
||||||
|
"header": [],
|
||||||
|
"body": {
|
||||||
|
"mode": "formdata",
|
||||||
|
"formdata": [
|
||||||
|
{
|
||||||
|
"key": "file",
|
||||||
|
"type": "file",
|
||||||
|
"src": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "directory",
|
||||||
|
"value": "testing/manual",
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "expires_in_minutes",
|
||||||
|
"value": "{{expires_in_minutes}}",
|
||||||
|
"type": "text"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"url": {
|
||||||
|
"raw": "{{base_url}}/api/storage-test/s3/upload",
|
||||||
|
"host": [
|
||||||
|
"{{base_url}}"
|
||||||
|
],
|
||||||
|
"path": [
|
||||||
|
"api",
|
||||||
|
"storage-test",
|
||||||
|
"s3",
|
||||||
|
"upload"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"description": "Sube un archivo al disco s3 y devuelve el path junto con una temporary_url."
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Generate Temporary URL",
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"header": [],
|
||||||
|
"url": {
|
||||||
|
"raw": "{{base_url}}/api/storage-test/s3/temporary-url?path={{path}}&expires_in_minutes={{expires_in_minutes}}",
|
||||||
|
"host": [
|
||||||
|
"{{base_url}}"
|
||||||
|
],
|
||||||
|
"path": [
|
||||||
|
"api",
|
||||||
|
"storage-test",
|
||||||
|
"s3",
|
||||||
|
"temporary-url"
|
||||||
|
],
|
||||||
|
"query": [
|
||||||
|
{
|
||||||
|
"key": "path",
|
||||||
|
"value": "{{path}}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "expires_in_minutes",
|
||||||
|
"value": "{{expires_in_minutes}}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"description": "Genera una URL temporal para un path ya existente en S3."
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -67,7 +67,18 @@ function bodyFor(string $method, string $uri): ?array
|
|||||||
'POST api/password/reset-attempts' => ['tenant_codigo' => '{{tenant_code}}', 'email' => '{{user_email}}'],
|
'POST api/password/reset-attempts' => ['tenant_codigo' => '{{tenant_code}}', 'email' => '{{user_email}}'],
|
||||||
'POST api/password/reset-attempts/validate' => ['email' => '{{user_email}}', 'codigo' => '{{reset_code}}'],
|
'POST api/password/reset-attempts/validate' => ['email' => '{{user_email}}', 'codigo' => '{{reset_code}}'],
|
||||||
'POST api/password/reset' => ['email' => '{{user_email}}', 'codigo' => '{{reset_code}}', 'password' => '{{user_password}}', 'password_confirmation' => '{{user_password}}'],
|
'POST api/password/reset' => ['email' => '{{user_email}}', 'codigo' => '{{reset_code}}', 'password' => '{{user_password}}', 'password_confirmation' => '{{user_password}}'],
|
||||||
|
'POST api/clients' => ['code' => 'cliente-demo', 'name' => 'Cliente Demo'],
|
||||||
|
'PUT api/clients/{client}' => ['code' => 'cliente-demo', 'name' => 'Cliente Demo Actualizado'],
|
||||||
|
'PATCH api/clients/{client}' => ['name' => 'Cliente Demo Actualizado'],
|
||||||
|
'POST api/integrations' => ['integration_code' => 'telepagos', 'name' => 'Telepagos', 'url' => 'https://api.example.com', 'integration_data_schema' => ['api_key' => ['required', 'string']], 'requires_client_configuration' => true],
|
||||||
|
'PUT api/integrations/{integration}' => ['name' => 'Telepagos', 'url' => 'https://api.example.com', 'requires_client_configuration' => true],
|
||||||
'PUT api/clients/{client}/integrations/{integration_code}' => ['integration_data' => ['api_key' => 'replace-me']],
|
'PUT api/clients/{client}/integrations/{integration_code}' => ['integration_data' => ['api_key' => 'replace-me']],
|
||||||
|
'POST api/menues' => ['code' => 'demo', 'label' => 'Demo', 'parent_menu_code' => null, 'content_type' => 'static', 'static_content_schema' => ['title' => ['required', 'string']], 'route' => '/demo'],
|
||||||
|
'PUT api/menues/{menue}' => ['label' => 'Demo actualizado', 'route' => '/demo'],
|
||||||
|
'PATCH api/menues/{menue}' => ['label' => 'Demo actualizado'],
|
||||||
|
'POST api/{tenant_code}/menues/{menu_code}' => ['static_content' => ['title' => 'Contenido demo']],
|
||||||
|
'POST api/webhooks/telepagos/{client}' => ['id' => 'payment-id-demo'],
|
||||||
|
'POST api/{tenant_code}/mail-test/send' => ['to' => 'destinatario@example.com', 'subject' => 'Prueba ShopIt', 'message' => 'Correo de prueba enviado desde Postman.'],
|
||||||
'POST api/tenants/{tenant:codigo}/cart/items' => ['catalog_item_id' => '{{catalog_item_id}}', 'variant_id' => '{{variant_id}}', 'cantidad' => 1],
|
'POST api/tenants/{tenant:codigo}/cart/items' => ['catalog_item_id' => '{{catalog_item_id}}', 'variant_id' => '{{variant_id}}', 'cantidad' => 1],
|
||||||
'PATCH api/tenants/{tenant:codigo}/cart/items/{cartItem}' => ['cantidad' => 2, 'variant_id' => '{{variant_id}}'],
|
'PATCH api/tenants/{tenant:codigo}/cart/items/{cartItem}' => ['cantidad' => 2, 'variant_id' => '{{variant_id}}'],
|
||||||
'POST api/tenants/{tenant:codigo}/catalog-items/{catalogItem}/variant-options' => ['selected_values' => ['color' => 'azul'], 'cart_item_id' => '{{cart_item_id}}'],
|
'POST api/tenants/{tenant:codigo}/catalog-items/{catalogItem}/variant-options' => ['selected_values' => ['color' => 'azul'], 'cart_item_id' => '{{cart_item_id}}'],
|
||||||
@@ -81,8 +92,11 @@ function bodyFor(string $method, string $uri): ?array
|
|||||||
'POST api/v1/adminapp/password/reset-attempts/validate' => ['email' => '{{admin_email}}', 'codigo' => '{{reset_code}}'],
|
'POST api/v1/adminapp/password/reset-attempts/validate' => ['email' => '{{admin_email}}', 'codigo' => '{{reset_code}}'],
|
||||||
'POST api/v1/adminapp/password/reset' => ['email' => '{{admin_email}}', 'codigo' => '{{reset_code}}', 'password' => '{{admin_password}}', 'password_confirmation' => '{{admin_password}}'],
|
'POST api/v1/adminapp/password/reset' => ['email' => '{{admin_email}}', 'codigo' => '{{reset_code}}', 'password' => '{{admin_password}}', 'password_confirmation' => '{{admin_password}}'],
|
||||||
'PUT api/v1/adminapp/tenant/event' => ['title' => 'Evento Demo', 'location' => 'Buenos Aires', 'dates' => [['date' => '2026-12-01', 'start_time' => '18:00', 'end_time' => '23:00']], 'social_media' => [['code' => 'instagram', 'url' => 'https://instagram.com/example', 'orden' => 0]]],
|
'PUT api/v1/adminapp/tenant/event' => ['title' => 'Evento Demo', 'location' => 'Buenos Aires', 'dates' => [['date' => '2026-12-01', 'start_time' => '18:00', 'end_time' => '23:00']], 'social_media' => [['code' => 'instagram', 'url' => 'https://instagram.com/example', 'orden' => 0]]],
|
||||||
|
'POST api/v1/adminapp/tenant/featured-groups' => ['category_name' => 'Destacados', 'is_featured' => true],
|
||||||
|
'PUT api/v1/adminapp/tenant/featured-groups/{featuredGroup}' => ['category_name' => 'Destacados', 'is_featured' => true],
|
||||||
'POST api/v1/adminapp/tenant/staff' => ['nombre_apellido' => 'Operador Demo', 'dni' => '30123456', 'email' => 'operador@example.com', 'category_ids' => [1]],
|
'POST api/v1/adminapp/tenant/staff' => ['nombre_apellido' => 'Operador Demo', 'dni' => '30123456', 'email' => 'operador@example.com', 'category_ids' => [1]],
|
||||||
'PUT api/v1/adminapp/tenant/staff/{staff}' => ['nombre_apellido' => 'Operador Demo', 'dni' => '30123456', 'email' => 'operador@example.com', 'category_ids' => [1]],
|
'PUT api/v1/adminapp/tenant/staff/{staff}' => ['nombre_apellido' => 'Operador Demo', 'dni' => '30123456', 'email' => 'operador@example.com', 'category_ids' => [1]],
|
||||||
|
'PATCH api/v1/adminapp/tenant/staff/{staff}' => ['nombre_apellido' => 'Operador Demo', 'dni' => '30123456', 'email' => 'operador@example.com', 'category_ids' => [1]],
|
||||||
'PUT api/v1/adminapp/tenant/website-extras/{websiteExtraCode}' => ['enabled' => true, 'content' => ['title' => 'Contenido demo']],
|
'PUT api/v1/adminapp/tenant/website-extras/{websiteExtraCode}' => ['enabled' => true, 'content' => ['title' => 'Contenido demo']],
|
||||||
'PATCH api/v1/adminapp/tenant/website-extras/{websiteExtraCode}/toggle' => ['enabled' => true],
|
'PATCH api/v1/adminapp/tenant/website-extras/{websiteExtraCode}/toggle' => ['enabled' => true],
|
||||||
'POST api/v1/adminapp/tenant/accommodations' => ['variants' => [['title' => 'Habitación doble', 'description' => 'Dos personas', 'stock' => 10, 'price' => 100000]]],
|
'POST api/v1/adminapp/tenant/accommodations' => ['variants' => [['title' => 'Habitación doble', 'description' => 'Dos personas', 'stock' => 10, 'price' => 100000]]],
|
||||||
@@ -148,6 +162,10 @@ function bodyFor(string $method, string $uri): ?array
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($key === 'POST api/storage-test/s3/upload') {
|
||||||
|
return formDataBody(['path' => 'postman/test-file.png', 'expires_in_minutes' => '60'], ['file']);
|
||||||
|
}
|
||||||
|
|
||||||
if ($key === 'POST api/v1/adminapp/tenant/desfile/entries/image') {
|
if ($key === 'POST api/v1/adminapp/tenant/desfile/entries/image') {
|
||||||
return formDataBody(['is_enabled' => '1'], ['image']);
|
return formDataBody(['is_enabled' => '1'], ['image']);
|
||||||
}
|
}
|
||||||
@@ -176,6 +194,7 @@ function queryFor(string $uri): array
|
|||||||
['key' => 'per_page', 'value' => '20'],
|
['key' => 'per_page', 'value' => '20'],
|
||||||
],
|
],
|
||||||
'api/v1/scanner/tickets' => [['key' => 'q', 'value' => '', 'disabled' => true], ['key' => 'page', 'value' => '1'], ['key' => 'per_page', 'value' => '20']],
|
'api/v1/scanner/tickets' => [['key' => 'q', 'value' => '', 'disabled' => true], ['key' => 'page', 'value' => '1'], ['key' => 'per_page', 'value' => '20']],
|
||||||
|
'api/storage-test/s3/temporary-url' => [['key' => 'path', 'value' => '{{s3_path}}'], ['key' => 'expires_in_minutes', 'value' => '60']],
|
||||||
default => [],
|
default => [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -194,6 +213,14 @@ function folderFor(string $uri, string $action): array
|
|||||||
return ['Scanner API', $domain];
|
return ['Scanner API', $domain];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (str_starts_with($uri, 'api/webhooks/')) {
|
||||||
|
return ['Webhooks', $domain];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array($domain, ['StorageTest', 'MailTest'], true)) {
|
||||||
|
return ['Developer Utilities', $domain];
|
||||||
|
}
|
||||||
|
|
||||||
if (in_array($domain, ['Client', 'Integration', 'Menu', 'Tenant'], true) && ! str_contains($uri, '{tenant:codigo}')) {
|
if (in_array($domain, ['Client', 'Integration', 'Menu', 'Tenant'], true) && ! str_contains($uri, '{tenant:codigo}')) {
|
||||||
return ['Platform Management', $domain];
|
return ['Platform Management', $domain];
|
||||||
}
|
}
|
||||||
@@ -241,7 +268,8 @@ function pathFor(string $uri): string
|
|||||||
{
|
{
|
||||||
$variables = [
|
$variables = [
|
||||||
'tenant:codigo' => 'tenant_code', 'tenant' => 'tenant_id', 'client' => 'client_id',
|
'tenant:codigo' => 'tenant_code', 'tenant' => 'tenant_id', 'client' => 'client_id',
|
||||||
'integration_code' => 'integration_code', 'tenant_code' => 'tenant_code', 'catalogItem' => 'catalog_item_id',
|
'integration_code' => 'integration_code', 'integration' => 'integration_id', 'menue' => 'menu_id',
|
||||||
|
'menu_code' => 'menu_code', 'tenant_code' => 'tenant_code', 'catalogItem' => 'catalog_item_id',
|
||||||
'featuredGroup' => 'featured_group_id', 'category' => 'category_id', 'cartItem' => 'cart_item_id',
|
'featuredGroup' => 'featured_group_id', 'category' => 'category_id', 'cartItem' => 'cart_item_id',
|
||||||
'compra' => 'purchase_id', 'item' => 'purchase_item_id', 'dominio' => 'tenant_domain',
|
'compra' => 'purchase_id', 'item' => 'purchase_item_id', 'dominio' => 'tenant_domain',
|
||||||
'sale' => 'sale_id', 'staff' => 'staff_id', 'websiteExtraCode' => 'website_extra_code',
|
'sale' => 'sale_id', 'staff' => 'staff_id', 'websiteExtraCode' => 'website_extra_code',
|
||||||
@@ -392,13 +420,14 @@ $variables = [
|
|||||||
'admin_email' => 'admin@example.com', 'admin_password' => 'Password!123',
|
'admin_email' => 'admin@example.com', 'admin_password' => 'Password!123',
|
||||||
'scanner_email' => 'scanner@example.com', 'scanner_password' => 'Password!123',
|
'scanner_email' => 'scanner@example.com', 'scanner_password' => 'Password!123',
|
||||||
'tenant_code' => 'demo', 'tenant_id' => '1', 'tenant_domain' => 'demo.test',
|
'tenant_code' => 'demo', 'tenant_id' => '1', 'tenant_domain' => 'demo.test',
|
||||||
'client_id' => '1', 'integration_code' => 'telepagos',
|
'client_id' => '1', 'integration_id' => '1', 'integration_code' => 'telepagos',
|
||||||
'catalog_item_id' => '1', 'variant_id' => '1',
|
'menu_id' => '1', 'menu_code' => 'demo', 'catalog_item_id' => '1', 'variant_id' => '1',
|
||||||
'category_id' => '1', 'featured_group_id' => '1', 'cart_id' => '1', 'cart_item_id' => '1',
|
'category_id' => '1', 'featured_group_id' => '1', 'cart_id' => '1', 'cart_item_id' => '1',
|
||||||
'purchase_id' => '1', 'purchase_item_id' => '1', 'sale_id' => '1', 'staff_id' => '1',
|
'purchase_id' => '1', 'purchase_item_id' => '1', 'sale_id' => '1', 'staff_id' => '1',
|
||||||
'website_extra_code' => 'hero', 'accommodation_id' => '1', 'entry_id' => '1', 'food_id' => '1',
|
'website_extra_code' => 'hero', 'accommodation_id' => '1', 'entry_id' => '1', 'food_id' => '1',
|
||||||
'merchandise_id' => '1', 'ticket_uuid' => '00000000-0000-0000-0000-000000000000',
|
'merchandise_id' => '1', 'ticket_uuid' => '00000000-0000-0000-0000-000000000000',
|
||||||
'oauth_code' => '00000000-0000-0000-0000-000000000000', 'reset_code' => '1234',
|
'oauth_code' => '00000000-0000-0000-0000-000000000000', 'reset_code' => '1234',
|
||||||
|
's3_path' => 'postman/test-file.png',
|
||||||
];
|
];
|
||||||
|
|
||||||
$collection = [
|
$collection = [
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
<svg width="63" height="36" viewBox="0 0 63 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<path d="M44.64 0H17.94C8.05 0 0 8.05 0 17.94C0 27.83 8.05 35.88 17.94 35.88H44.64C54.53 35.88 62.58 27.83 62.58 17.94C62.58 8.05 54.53 0 44.64 0ZM44.62 31.78C36.98 31.78 30.79 25.59 30.79 17.95C30.79 10.31 36.98 4.12 44.62 4.12C52.26 4.12 58.45 10.31 58.45 17.95C58.45 25.59 52.26 31.78 44.62 31.78Z" fill="#FF7006"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 422 B |
@@ -1,4 +1,4 @@
|
|||||||
@props(['branding', 'headerLogoUrl' => null, 'footerLogoUrl' => null])
|
@props(['tenant', 'headerLogoUrl' => null, 'footerLogoUrl' => null])
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="es">
|
<html lang="es">
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta name="color-scheme" content="light">
|
<meta name="color-scheme" content="light">
|
||||||
<title>{{ $branding['name'] }}</title>
|
<title>{{ $tenant->nombre }}</title>
|
||||||
<style>
|
<style>
|
||||||
@media only screen and (max-width: 620px) {
|
@media only screen and (max-width: 620px) {
|
||||||
.mail-container { width: 100% !important; }
|
.mail-container { width: 100% !important; }
|
||||||
@@ -14,17 +14,17 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body style="margin: 0; padding: 0; background-color: {{ $branding['background_color'] }}; color: {{ $branding['body_color'] }}; font-family: Arial, Helvetica, sans-serif;">
|
<body style="margin: 0; padding: 0; background-color: #f1f5f9; color: #334155; font-family: Arial, Helvetica, sans-serif;">
|
||||||
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: {{ $branding['background_color'] }};">
|
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: #f1f5f9;">
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" style="padding: 32px 12px;">
|
<td align="center" style="padding: 32px 12px;">
|
||||||
<table role="presentation" width="600" cellspacing="0" cellpadding="0" border="0" class="mail-container" style="width: 600px; max-width: 600px; background-color: {{ $branding['surface_color'] }}; border-top: 4px solid {{ $branding['primary_color'] }}; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);">
|
<table role="presentation" width="600" cellspacing="0" cellpadding="0" border="0" class="mail-container" style="width: 600px; max-width: 600px; background-color: #ffffff; border-top: 4px solid {{ $tenant->primary_color }}; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);">
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" bgcolor="{{ $branding['header_bg_color'] }}" style="padding: 24px 32px; background-color: {{ $branding['header_bg_color'] }};">
|
<td align="center" bgcolor="{{ $tenant->header_bg_color }}" style="padding: 24px 32px; background-color: {{ $tenant->header_bg_color }};">
|
||||||
@if ($headerLogoUrl)
|
@if ($headerLogoUrl)
|
||||||
<img src="{{ $headerLogoUrl }}" alt="{{ $branding['name'] }}" width="180" style="display: block; width: auto; max-width: 180px; max-height: 64px; border: 0;">
|
<img src="{{ $headerLogoUrl }}" alt="{{ $tenant->nombre }}" width="180" style="display: block; width: auto; max-width: 180px; max-height: 64px; border: 0;">
|
||||||
@else
|
@else
|
||||||
<span style="color: {{ $branding['primary_color'] }}; font-size: 24px; font-weight: 700; line-height: 1.2;">{{ $branding['name'] }}</span>
|
<span style="color: {{ $tenant->primary_color }}; font-size: 24px; font-weight: 700; line-height: 1.2;">{{ $tenant->nombre }}</span>
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -34,11 +34,11 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" bgcolor="{{ $branding['footer_bg_color'] }}" style="padding: 24px 32px; background-color: {{ $branding['footer_bg_color'] }}; color: #ffffff; font-size: 12px; line-height: 1.5;">
|
<td align="center" bgcolor="{{ $tenant->footer_bg_color }}" style="padding: 24px 32px; background-color: {{ $tenant->footer_bg_color }}; color: #ffffff; font-size: 12px; line-height: 1.5;">
|
||||||
@if ($footerLogoUrl)
|
@if ($footerLogoUrl)
|
||||||
<img src="{{ $footerLogoUrl }}" alt="{{ $branding['name'] }}" width="140" style="display: block; width: auto; max-width: 140px; max-height: 48px; margin: 0 auto 16px; border: 0;">
|
<img src="{{ $footerLogoUrl }}" alt="{{ $tenant->nombre }}" width="140" style="display: block; width: auto; max-width: 140px; max-height: 48px; margin: 0 auto 16px; border: 0;">
|
||||||
@endif
|
@endif
|
||||||
{{ $footer ?? 'Este correo fue enviado por '.$branding['name'].'.' }}
|
{{ $footer ?? 'Este correo fue enviado por '.$tenant->nombre.'.' }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<h1 style="margin: 0 0 20px; color: {{ $brand->primary_color }};">
|
<h1 style="margin: 0 0 20px; color: {{ $tenant->primary_color }};">
|
||||||
Recuperá tu contraseña
|
Recuperá tu contraseña
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
@if($attempt->reason === \App\Domains\Auth\Models\ResetPasswordAttempt::REASON_STAFF_CREATED)
|
@if($attempt->reason === \App\Domains\Auth\Models\ResetPasswordAttempt::REASON_STAFF_CREATED)
|
||||||
<p>
|
<p>
|
||||||
Hola {{ $attempt->user->nombre_apellido }}, creamos tu cuenta de scanner en {{ $brand->nombre }}. Utilizá este código para crear tu contraseña y comenzar a usarla.
|
Hola {{ $attempt->user->nombre_apellido }}, creamos tu cuenta de scanner en {{ $tenant->nombre }}. Utilizá este código para crear tu contraseña y comenzar a usarla.
|
||||||
</p>
|
</p>
|
||||||
@elseif($attempt->reason === \App\Domains\Auth\Models\ResetPasswordAttempt::REASON_ACCOUNT_LOCKED)
|
@elseif($attempt->reason === \App\Domains\Auth\Models\ResetPasswordAttempt::REASON_ACCOUNT_LOCKED)
|
||||||
<p>
|
<p>
|
||||||
@@ -17,10 +17,10 @@
|
|||||||
</p>
|
</p>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<p>Ingresá este código en {{ $brand->nombre }}:</p>
|
<p>Ingresá este código en {{ $tenant->nombre }}:</p>
|
||||||
|
|
||||||
<div style="margin: 28px 0; padding: 20px; border: 2px solid {{ $brand->primary_color }}; border-radius: 8px; text-align: center;">
|
<div style="margin: 28px 0; padding: 20px; border: 2px solid {{ $tenant->primary_color }}; border-radius: 8px; text-align: center;">
|
||||||
<span style="color: {{ $brand->primary_color }}; font-size: 36px; font-weight: 700; letter-spacing: 12px;">
|
<span style="color: {{ $tenant->primary_color }}; font-size: 36px; font-weight: 700; letter-spacing: 12px;">
|
||||||
{{ $attempt->codigo }}
|
{{ $attempt->codigo }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
@if($recoveryUrl)
|
@if($recoveryUrl)
|
||||||
<div style="text-align: center; margin-bottom: 28px;">
|
<div style="text-align: center; margin-bottom: 28px;">
|
||||||
<a href="{{ $recoveryUrl }}"
|
<a href="{{ $recoveryUrl }}"
|
||||||
style="display: inline-block; padding: 12px 24px; background-color: {{ $brand->primary_color }}; color: #ffffff; text-decoration: none; border-radius: 6px; font-weight: bold;">
|
style="display: inline-block; padding: 12px 24px; background-color: {{ $tenant->primary_color }}; color: #ffffff; text-decoration: none; border-radius: 6px; font-weight: bold;">
|
||||||
{{ $attempt->reason === \App\Domains\Auth\Models\ResetPasswordAttempt::REASON_STAFF_CREATED ? 'Crear mi contraseña' : 'Ingresar código ahora' }}
|
{{ $attempt->reason === \App\Domains\Auth\Models\ResetPasswordAttempt::REASON_STAFF_CREATED ? 'Crear mi contraseña' : 'Ingresar código ahora' }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<h1 style="margin: 0 0 20px;">¡Compra realizada con éxito!</h1>
|
<h1 style="margin: 0 0 20px;">¡Recibimos tu pago!</h1>
|
||||||
<p>La compra <strong>#{{ $purchase->id }}</strong> fue confirmada correctamente.</p>
|
<p>La compra <strong>#{{ $purchase->id }}</strong> fue confirmada correctamente.</p>
|
||||||
<table role="presentation" style="width: 100%; border-collapse: collapse; margin: 20px 0;">
|
<table role="presentation" style="width: 100%; border-collapse: collapse; margin: 20px 0;">
|
||||||
@foreach ($purchase->items as $item)
|
@foreach ($purchase->items as $item)
|
||||||
@@ -10,6 +10,3 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
</table>
|
</table>
|
||||||
<p style="font-size: 18px;"><strong>Total pagado: ${{ number_format((float) $purchase->total, 2, ',', '.') }}</strong></p>
|
<p style="font-size: 18px;"><strong>Total pagado: ${{ number_format((float) $purchase->total, 2, ',', '.') }}</strong></p>
|
||||||
@if ($tickets->isNotEmpty())
|
|
||||||
<p><strong>Tus tickets ya están disponibles</strong></p>
|
|
||||||
@endif
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user