diff --git a/app/Domains/Bootstrap/Resources/AdminAppBootstrapResource.php b/app/Domains/Bootstrap/Resources/AdminAppBootstrapResource.php index e81effb..69383e8 100644 --- a/app/Domains/Bootstrap/Resources/AdminAppBootstrapResource.php +++ b/app/Domains/Bootstrap/Resources/AdminAppBootstrapResource.php @@ -2,21 +2,21 @@ namespace App\Domains\Bootstrap\Resources; -use App\Domains\Tenant\Models\WebsiteType; +use App\Domains\Tenant\Models\AdminWebsiteType; use Illuminate\Http\Request; use Illuminate\Http\Resources\Json\JsonResource; -/** @mixin array{website_type: WebsiteType} */ +/** @mixin array{website_type: AdminWebsiteType} */ class AdminAppBootstrapResource extends JsonResource { /** @return array */ public function toArray(Request $request): array { - /** @var WebsiteType $websiteType */ + /** @var AdminWebsiteType $websiteType */ $websiteType = $this->resource['website_type']; return [ - 'website_type_code' => $websiteType->codigo, + 'admin_website_type_code' => $websiteType->codigo, 'site_title' => $websiteType->site_title, 'primary_color' => $websiteType->primary_color, 'secondary_color' => $websiteType->secondary_color, diff --git a/app/Domains/Bootstrap/Services/AdminAppBootstrapService.php b/app/Domains/Bootstrap/Services/AdminAppBootstrapService.php index 743f4a0..01bee6a 100644 --- a/app/Domains/Bootstrap/Services/AdminAppBootstrapService.php +++ b/app/Domains/Bootstrap/Services/AdminAppBootstrapService.php @@ -2,15 +2,15 @@ namespace App\Domains\Bootstrap\Services; -use App\Domains\Tenant\Models\WebsiteType; +use App\Domains\Tenant\Models\AdminWebsiteType; class AdminAppBootstrapService { - /** @return array{website_type: WebsiteType} */ + /** @return array{website_type: AdminWebsiteType} */ public function get(string $domain): array { return [ - 'website_type' => WebsiteType::query() + 'website_type' => AdminWebsiteType::query() ->with(['siteLogo', 'footerLogo', 'favicon']) ->where('dominio', $domain) ->firstOrFail(), diff --git a/app/Domains/Bootstrap/Services/ScannerBootstrapService.php b/app/Domains/Bootstrap/Services/ScannerBootstrapService.php index 4a088a1..9aaad48 100644 --- a/app/Domains/Bootstrap/Services/ScannerBootstrapService.php +++ b/app/Domains/Bootstrap/Services/ScannerBootstrapService.php @@ -2,15 +2,15 @@ namespace App\Domains\Bootstrap\Services; -use App\Domains\Tenant\Models\WebsiteType; +use App\Domains\Tenant\Models\AdminWebsiteType; class ScannerBootstrapService { - /** @return array{website_type: WebsiteType} */ + /** @return array{website_type: AdminWebsiteType} */ public function get(string $domain): array { return [ - 'website_type' => WebsiteType::query() + 'website_type' => AdminWebsiteType::query() ->with(['siteLogo', 'footerLogo', 'favicon']) ->where('scanner_domain', $domain) ->firstOrFail(), diff --git a/app/Domains/Catalog/Controllers/AdminApp/OnTicketFeaturedGroupController.php b/app/Domains/Catalog/Controllers/AdminApp/OnTicketFeaturedGroupController.php index 7017d66..1a984ef 100644 --- a/app/Domains/Catalog/Controllers/AdminApp/OnTicketFeaturedGroupController.php +++ b/app/Domains/Catalog/Controllers/AdminApp/OnTicketFeaturedGroupController.php @@ -58,7 +58,7 @@ class OnTicketFeaturedGroupController extends Controller { $tenant = $request->user()->tenant()->firstOrFail(); - abort_unless($tenant->website_type_code === 'onticket', 404); + abort_unless($tenant->storefront_website_type_code === 'onticket', 404); return $tenant; } diff --git a/app/Domains/Integration/Controllers/WebsiteTypeIntegrationController.php b/app/Domains/Integration/Controllers/AdminWebsiteTypeIntegrationController.php similarity index 51% rename from app/Domains/Integration/Controllers/WebsiteTypeIntegrationController.php rename to app/Domains/Integration/Controllers/AdminWebsiteTypeIntegrationController.php index 847ac39..ef6d19d 100644 --- a/app/Domains/Integration/Controllers/WebsiteTypeIntegrationController.php +++ b/app/Domains/Integration/Controllers/AdminWebsiteTypeIntegrationController.php @@ -6,37 +6,37 @@ use App\Domains\Integration\Models\Integration; use App\Domains\Integration\Requests\ConfigureIntegrationRequest; use App\Domains\Integration\Resources\IntegrationAssociationResource; use App\Domains\Integration\Services\IntegrationAssociationService; -use App\Domains\Tenant\Models\WebsiteType; +use App\Domains\Tenant\Models\AdminWebsiteType; use App\Http\Controllers\Controller; -class WebsiteTypeIntegrationController extends Controller +class AdminWebsiteTypeIntegrationController extends Controller { public function __construct(private readonly IntegrationAssociationService $service) {} - public function index(WebsiteType $websiteType) + public function index(AdminWebsiteType $adminWebsiteType) { - return IntegrationAssociationResource::collection($websiteType->integrations()->with('integrationInstance')->get()); + return IntegrationAssociationResource::collection($adminWebsiteType->integrations()->with('integrationInstance')->get()); } - public function show(WebsiteType $websiteType, string $integrationCode) + public function show(AdminWebsiteType $adminWebsiteType, string $integrationCode) { - return new IntegrationAssociationResource($websiteType->integrations()->with('integrationInstance')->where('integration_code', $integrationCode)->firstOrFail()); + return new IntegrationAssociationResource($adminWebsiteType->integrations()->with('integrationInstance')->where('integration_code', $integrationCode)->firstOrFail()); } - public function store(ConfigureIntegrationRequest $request, WebsiteType $websiteType, string $integrationCode) + public function store(ConfigureIntegrationRequest $request, AdminWebsiteType $adminWebsiteType, string $integrationCode) { $integration = Integration::query()->where('integration_code', $integrationCode)->firstOrFail(); return new IntegrationAssociationResource($this->service->configure( - $websiteType, + $adminWebsiteType, $integration, $request->validated('integration_data'), )); } - public function destroy(WebsiteType $websiteType, string $integrationCode) + public function destroy(AdminWebsiteType $adminWebsiteType, string $integrationCode) { - $this->service->detach($websiteType, $integrationCode); + $this->service->detach($adminWebsiteType, $integrationCode); return response()->noContent(); } diff --git a/app/Domains/Integration/Models/WebsiteTypeIntegration.php b/app/Domains/Integration/Models/AdminWebsiteTypeIntegration.php similarity index 54% rename from app/Domains/Integration/Models/WebsiteTypeIntegration.php rename to app/Domains/Integration/Models/AdminWebsiteTypeIntegration.php index 6b791f3..f95efad 100644 --- a/app/Domains/Integration/Models/WebsiteTypeIntegration.php +++ b/app/Domains/Integration/Models/AdminWebsiteTypeIntegration.php @@ -2,18 +2,19 @@ namespace App\Domains\Integration\Models; -use App\Domains\Tenant\Models\WebsiteType; +use App\Domains\Tenant\Models\AdminWebsiteType; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; -class WebsiteTypeIntegration extends Model +class AdminWebsiteTypeIntegration extends Model { - protected $fillable = ['website_type_code', 'integration_code', 'integration_instance_id']; + protected $table = 'admin_website_type_integrations'; + protected $fillable = ['admin_website_type_code', 'integration_code', 'integration_instance_id']; - /** @return BelongsTo */ - public function websiteType(): BelongsTo + /** @return BelongsTo */ + public function adminWebsiteType(): BelongsTo { - return $this->belongsTo(WebsiteType::class, 'website_type_code', 'codigo'); + return $this->belongsTo(AdminWebsiteType::class, 'admin_website_type_code', 'codigo'); } /** @return BelongsTo */ diff --git a/app/Domains/Integration/Models/Integration.php b/app/Domains/Integration/Models/Integration.php index ea03ae8..28d3b86 100644 --- a/app/Domains/Integration/Models/Integration.php +++ b/app/Domains/Integration/Models/Integration.php @@ -34,9 +34,9 @@ class Integration extends Model return $this->hasMany(ClientIntegration::class, 'integration_code', 'integration_code'); } - /** @return HasMany */ + /** @return HasMany */ public function websiteTypeIntegrations(): HasMany { - return $this->hasMany(WebsiteTypeIntegration::class, 'integration_code', 'integration_code'); + return $this->hasMany(AdminWebsiteTypeIntegration::class, 'integration_code', 'integration_code'); } } diff --git a/app/Domains/Integration/Models/IntegrationInstance.php b/app/Domains/Integration/Models/IntegrationInstance.php index db242eb..75de6ef 100644 --- a/app/Domains/Integration/Models/IntegrationInstance.php +++ b/app/Domains/Integration/Models/IntegrationInstance.php @@ -33,9 +33,9 @@ class IntegrationInstance extends Model return $this->hasMany(ClientIntegration::class); } - /** @return HasMany */ + /** @return HasMany */ public function websiteTypeIntegrations(): HasMany { - return $this->hasMany(WebsiteTypeIntegration::class); + return $this->hasMany(AdminWebsiteTypeIntegration::class); } } diff --git a/app/Domains/Integration/Resources/IntegrationAssociationResource.php b/app/Domains/Integration/Resources/IntegrationAssociationResource.php index 31339ca..1b1853f 100644 --- a/app/Domains/Integration/Resources/IntegrationAssociationResource.php +++ b/app/Domains/Integration/Resources/IntegrationAssociationResource.php @@ -12,7 +12,7 @@ class IntegrationAssociationResource extends JsonResource return [ 'id' => $this->id, 'client_id' => $this->when(isset($this->client_id), $this->client_id), - 'website_type_code' => $this->when(isset($this->website_type_code), $this->website_type_code), + 'admin_website_type_code' => $this->when(isset($this->admin_website_type_code), $this->admin_website_type_code), 'integration_code' => $this->integration_code, 'integration_instance_id' => $this->integration_instance_id, 'integration_instance' => new IntegrationInstanceResource($this->whenLoaded('integrationInstance')), diff --git a/app/Domains/Integration/Services/BaseIntegrationService.php b/app/Domains/Integration/Services/BaseIntegrationService.php index 0ca9302..7fd2374 100644 --- a/app/Domains/Integration/Services/BaseIntegrationService.php +++ b/app/Domains/Integration/Services/BaseIntegrationService.php @@ -6,7 +6,7 @@ use App\Domains\Client\Models\Client; use App\Domains\Integration\Models\ClientIntegration; use App\Domains\Integration\Models\Integration; use App\Domains\Integration\Models\IntegrationInstance; -use App\Domains\Integration\Models\WebsiteTypeIntegration; +use App\Domains\Integration\Models\AdminWebsiteTypeIntegration; use App\Domains\Tenant\Models\Tenant; use Exception; use Illuminate\Http\Client\PendingRequest; @@ -111,9 +111,9 @@ abstract class BaseIntegrationService ->where('integration_code', $this->integrationCode) ->first()?->integrationInstance; - if (! $this->integrationInstance && $this->tenant?->website_type_code) { - $this->integrationInstance = WebsiteTypeIntegration::with('integrationInstance') - ->where('website_type_code', $this->tenant->website_type_code) + if (! $this->integrationInstance && $this->tenant?->admin_website_type_code) { + $this->integrationInstance = AdminWebsiteTypeIntegration::with('integrationInstance') + ->where('admin_website_type_code', $this->tenant->admin_website_type_code) ->where('integration_code', $this->integrationCode) ->first()?->integrationInstance; } diff --git a/app/Domains/Integration/Services/IntegrationAssociationService.php b/app/Domains/Integration/Services/IntegrationAssociationService.php index 78aced5..0531959 100644 --- a/app/Domains/Integration/Services/IntegrationAssociationService.php +++ b/app/Domains/Integration/Services/IntegrationAssociationService.php @@ -6,15 +6,15 @@ use App\Domains\Client\Models\Client; use App\Domains\Integration\Models\ClientIntegration; use App\Domains\Integration\Models\Integration; use App\Domains\Integration\Models\IntegrationInstance; -use App\Domains\Integration\Models\WebsiteTypeIntegration; -use App\Domains\Tenant\Models\WebsiteType; +use App\Domains\Integration\Models\AdminWebsiteTypeIntegration; +use App\Domains\Tenant\Models\AdminWebsiteType; use Illuminate\Support\Facades\DB; class IntegrationAssociationService { - public function configure(Client|WebsiteType $owner, Integration $integration, array $integrationData): ClientIntegration|WebsiteTypeIntegration + public function configure(Client|AdminWebsiteType $owner, Integration $integration, array $integrationData): ClientIntegration|AdminWebsiteTypeIntegration { - return DB::transaction(function () use ($owner, $integration, $integrationData): ClientIntegration|WebsiteTypeIntegration { + return DB::transaction(function () use ($owner, $integration, $integrationData): ClientIntegration|AdminWebsiteTypeIntegration { $instance = IntegrationInstance::create([ 'integration_code' => $integration->integration_code, 'name' => $integration->name.' / '.$this->ownerName($owner), @@ -25,9 +25,9 @@ class IntegrationAssociationService }); } - public function associate(Client|WebsiteType $owner, string $code, IntegrationInstance $instance): ClientIntegration|WebsiteTypeIntegration + public function associate(Client|AdminWebsiteType $owner, string $code, IntegrationInstance $instance): ClientIntegration|AdminWebsiteTypeIntegration { - return DB::transaction(function () use ($owner, $code, $instance): ClientIntegration|WebsiteTypeIntegration { + return DB::transaction(function () use ($owner, $code, $instance): ClientIntegration|AdminWebsiteTypeIntegration { $association = $owner->integrations() ->where('integration_code', $code) ->lockForUpdate() @@ -62,7 +62,7 @@ class IntegrationAssociationService }); } - public function detach(Client|WebsiteType $owner, string $code): void + public function detach(Client|AdminWebsiteType $owner, string $code): void { DB::transaction(function () use ($owner, $code): void { $association = $owner->integrations() @@ -91,7 +91,7 @@ class IntegrationAssociationService } } - private function ownerName(Client|WebsiteType $owner): string + private function ownerName(Client|AdminWebsiteType $owner): string { return $owner instanceof Client ? $owner->name : $owner->nombre; } diff --git a/app/Domains/Integration/Services/MailService.php b/app/Domains/Integration/Services/MailService.php index d2cd30f..491f13a 100644 --- a/app/Domains/Integration/Services/MailService.php +++ b/app/Domains/Integration/Services/MailService.php @@ -4,7 +4,7 @@ namespace App\Domains\Integration\Services; use App\Domains\Client\Models\Client; use App\Domains\Tenant\Models\Tenant; -use App\Domains\Tenant\Models\WebsiteType; +use App\Domains\Tenant\Models\AdminWebsiteType; use Exception; use Illuminate\Contracts\Mail\Factory as MailFactory; use Illuminate\Contracts\Mail\Mailer; @@ -79,7 +79,7 @@ class MailService extends BaseIntegrationService string|array $recipient, string $subject, string $content, - Tenant|WebsiteType|null $brand = null, + Tenant|AdminWebsiteType|null $brand = null, array $attachments = [], ): void { if (! $this->mailer || ! $this->tenant) { @@ -97,7 +97,7 @@ class MailService extends BaseIntegrationService BLADE, [ 'branding' => $branding, - 'headerLogoUrl' => $brand instanceof WebsiteType + 'headerLogoUrl' => $brand instanceof AdminWebsiteType ? $brand->siteLogo?->getTemporaryUrl(1440) : $brand->headerLogo?->getTemporaryUrl(1440), 'footerLogoUrl' => $brand->footerLogo?->getTemporaryUrl(1440), @@ -128,9 +128,9 @@ class MailService extends BaseIntegrationService } /** @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 + private function brandingFor(Tenant|AdminWebsiteType $brand): array { - if ($brand instanceof WebsiteType) { + if ($brand instanceof AdminWebsiteType) { $brand->loadMissing(['siteLogo', 'footerLogo']); return [ diff --git a/app/Domains/Integration/routes/api.php b/app/Domains/Integration/routes/api.php index bad0f08..9e1000c 100644 --- a/app/Domains/Integration/routes/api.php +++ b/app/Domains/Integration/routes/api.php @@ -2,16 +2,16 @@ use App\Domains\Integration\Controllers\ClientIntegrationController; use App\Domains\Integration\Controllers\TelepagosWebhookController; -use App\Domains\Integration\Controllers\WebsiteTypeIntegrationController; +use App\Domains\Integration\Controllers\AdminWebsiteTypeIntegrationController; use App\Domains\Integration\Models\Integration; use Illuminate\Support\Facades\Route; Route::middleware(['auth:sanctum', 'can:manage,'.Integration::class])->group(function (): void { - Route::prefix('website-types/{websiteType:codigo}/integrations')->group(function (): void { - Route::get('/', [WebsiteTypeIntegrationController::class, 'index']); - Route::get('/{integration_code}', [WebsiteTypeIntegrationController::class, 'show']); - Route::put('/{integration_code}', [WebsiteTypeIntegrationController::class, 'store']); - Route::delete('/{integration_code}', [WebsiteTypeIntegrationController::class, 'destroy']); + Route::prefix('admin-website-types/{adminWebsiteType:codigo}/integrations')->group(function (): void { + Route::get('/', [AdminWebsiteTypeIntegrationController::class, 'index']); + Route::get('/{integration_code}', [AdminWebsiteTypeIntegrationController::class, 'show']); + Route::put('/{integration_code}', [AdminWebsiteTypeIntegrationController::class, 'store']); + Route::delete('/{integration_code}', [AdminWebsiteTypeIntegrationController::class, 'destroy']); }); Route::group(['prefix' => 'clients/{client}/integrations'], function () { diff --git a/app/Domains/Notification/Services/NotificationMailService.php b/app/Domains/Notification/Services/NotificationMailService.php index 6652a04..f61fd64 100644 --- a/app/Domains/Notification/Services/NotificationMailService.php +++ b/app/Domains/Notification/Services/NotificationMailService.php @@ -31,7 +31,7 @@ class NotificationMailService 'user_id' => $userId, 'tenant_code' => $tenantCode, ]; - $tenant = Tenant::query()->with('websiteType')->where('codigo', $tenantCode)->firstOrFail(); + $tenant = Tenant::query()->where('codigo', $tenantCode)->firstOrFail(); $user = User::query()->findOrFail($userId); $this->sendIdempotently( @@ -41,7 +41,7 @@ class NotificationMailService $context, $user->email, function () use ($user, $tenant, $tenantCode): array { - $brand = $tenant->websiteType ?? $tenant; + $brand = $tenant; $tenantUrl = 'https://'.$tenant->dominio.$tenant->base_path; $this->mailService @@ -54,7 +54,7 @@ class NotificationMailService ); return [ - 'brand_type' => $tenant->websiteType === null ? 'tenant' : 'website_type', + 'brand_type' => 'tenant', ]; }, ); @@ -72,7 +72,7 @@ class NotificationMailService ]; $tenant = Tenant::query() - ->with('websiteType') + ->with('adminWebsiteType') ->where('codigo', $tenantCode) ->firstOrFail(); $attempt = ResetPasswordAttempt::query() @@ -97,8 +97,8 @@ class NotificationMailService $attempt->user->email, function () use ($attempt, $tenant, $tenantCode, $channel): array { $recoveryDomain = match ($channel) { - PasswordResetRequested::CHANNEL_ADMINAPP => $tenant->websiteType?->dominio, - PasswordResetRequested::CHANNEL_SCANNER => $tenant->websiteType?->scanner_domain, + PasswordResetRequested::CHANNEL_ADMINAPP => $tenant->adminWebsiteType?->dominio, + PasswordResetRequested::CHANNEL_SCANNER => $tenant->adminWebsiteType?->scanner_domain, default => $tenant->dominio, }; $recoveryBasePath = $channel === PasswordResetRequested::CHANNEL_STOREFRONT @@ -115,7 +115,9 @@ class NotificationMailService $recoveryUrl = $recoveryDomain === null ? null : 'https://'.$recoveryDomain.$recoveryBasePath.'/recuperar-contrasena/codigo?'.http_build_query($recoveryQuery); - $brand = $tenant->websiteType ?? $tenant; + $brand = $channel === PasswordResetRequested::CHANNEL_STOREFRONT + ? $tenant + : ($tenant->adminWebsiteType ?? $tenant); [$subject, $template] = match ($attempt->reason) { ResetPasswordAttempt::REASON_STAFF_CREATED => [ @@ -291,7 +293,7 @@ class NotificationMailService $newDate, $tickets, ): array { - $brand = $purchase->tenant->websiteType ?? $purchase->tenant; + $brand = $purchase->tenant; $this->mailService ->forTenant($tenantCode) @@ -392,7 +394,7 @@ class NotificationMailService $disabledTickets, $activeTickets, ): array { - $brand = $purchase->tenant->websiteType ?? $purchase->tenant; + $brand = $purchase->tenant; $this->mailService ->forTenant($tenantCode) @@ -419,7 +421,7 @@ class NotificationMailService { return Purchase::query() ->where('tenant_codigo', $tenantCode) - ->with(['tenant.websiteType', 'user']) + ->with(['tenant', 'user']) ->find($purchaseId); } diff --git a/app/Domains/Tenant/Controllers/AdminApp/WebsiteExtraController.php b/app/Domains/Tenant/Controllers/AdminApp/WebsiteExtraController.php index 835329b..cf50a96 100644 --- a/app/Domains/Tenant/Controllers/AdminApp/WebsiteExtraController.php +++ b/app/Domains/Tenant/Controllers/AdminApp/WebsiteExtraController.php @@ -76,7 +76,7 @@ class WebsiteExtraController extends Controller $tenant = $user->tenant()->firstOrFail(); return $this->tenantInformationService->load($tenant, [ - 'websiteType.extras', + 'storefrontWebsiteType.extras', ]); } } diff --git a/app/Domains/Tenant/Models/WebsiteType.php b/app/Domains/Tenant/Models/AdminWebsiteType.php similarity index 72% rename from app/Domains/Tenant/Models/WebsiteType.php rename to app/Domains/Tenant/Models/AdminWebsiteType.php index 91acc11..0450d16 100644 --- a/app/Domains/Tenant/Models/WebsiteType.php +++ b/app/Domains/Tenant/Models/AdminWebsiteType.php @@ -3,7 +3,7 @@ namespace App\Domains\Tenant\Models; use App\Domains\Attachable\Models\Attachment; -use App\Domains\Integration\Models\WebsiteTypeIntegration; +use App\Domains\Integration\Models\AdminWebsiteTypeIntegration; use Illuminate\Database\Eloquent\Attributes\Fillable; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -31,16 +31,16 @@ use Illuminate\Database\Eloquent\Relations\HasMany; 'footer_logo', 'favicon_id', ])] -class WebsiteType extends Model +class AdminWebsiteType extends Model { use HasFactory; - protected $table = 'website_type'; + protected $table = 'admin_website_types'; - /** @return HasMany */ + /** @return HasMany */ public function integrations(): HasMany { - return $this->hasMany(WebsiteTypeIntegration::class, 'website_type_code', 'codigo'); + return $this->hasMany(AdminWebsiteTypeIntegration::class, 'admin_website_type_code', 'codigo'); } /** @@ -67,19 +67,11 @@ class WebsiteType extends Model return $this->belongsTo(Attachment::class, 'favicon_id'); } - /** - * @return HasMany - */ - public function extras(): HasMany - { - return $this->hasMany(WebsiteTypeExtra::class, 'website_type_code', 'codigo'); - } - /** * @return HasMany */ public function tenants(): HasMany { - return $this->hasMany(Tenant::class, 'website_type_code', 'codigo'); + return $this->hasMany(Tenant::class, 'admin_website_type_code', 'codigo'); } } diff --git a/app/Domains/Tenant/Models/StorefrontWebsiteType.php b/app/Domains/Tenant/Models/StorefrontWebsiteType.php new file mode 100644 index 0000000..2235196 --- /dev/null +++ b/app/Domains/Tenant/Models/StorefrontWebsiteType.php @@ -0,0 +1,28 @@ + */ + public function extras(): HasMany + { + return $this->hasMany(StorefrontWebsiteTypeExtra::class, 'storefront_website_type_code', 'codigo'); + } + + /** @return HasMany */ + public function tenants(): HasMany + { + return $this->hasMany(Tenant::class, 'storefront_website_type_code', 'codigo'); + } +} diff --git a/app/Domains/Tenant/Models/WebsiteTypeExtra.php b/app/Domains/Tenant/Models/StorefrontWebsiteTypeExtra.php similarity index 70% rename from app/Domains/Tenant/Models/WebsiteTypeExtra.php rename to app/Domains/Tenant/Models/StorefrontWebsiteTypeExtra.php index 87be8c3..c68bab5 100644 --- a/app/Domains/Tenant/Models/WebsiteTypeExtra.php +++ b/app/Domains/Tenant/Models/StorefrontWebsiteTypeExtra.php @@ -9,18 +9,18 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; #[Fillable([ - 'website_type_code', + 'storefront_website_type_code', 'codigo', 'nombre', 'descripcion', 'is_required', 'config_schema', ])] -class WebsiteTypeExtra extends Model +class StorefrontWebsiteTypeExtra extends Model { use HasFactory; - protected $table = 'website_type_extras'; + protected $table = 'storefront_website_type_extras'; /** * @return array @@ -34,11 +34,11 @@ class WebsiteTypeExtra extends Model } /** - * @return BelongsTo + * @return BelongsTo */ - public function websiteType(): BelongsTo + public function storefrontWebsiteType(): BelongsTo { - return $this->belongsTo(WebsiteType::class, 'website_type_code', 'codigo'); + return $this->belongsTo(StorefrontWebsiteType::class, 'storefront_website_type_code', 'codigo'); } /** diff --git a/app/Domains/Tenant/Models/Tenant.php b/app/Domains/Tenant/Models/Tenant.php index e119319..3f3129c 100644 --- a/app/Domains/Tenant/Models/Tenant.php +++ b/app/Domains/Tenant/Models/Tenant.php @@ -42,7 +42,8 @@ use Illuminate\Support\Facades\Schema; 'favicon_id', 'header_bg_image_id', 'footer_bg_image_id', - 'website_type_code', + 'admin_website_type_code', + 'storefront_website_type_code', 'search_product_layout', 'search_group_layout', 'search_items_per_page', @@ -210,11 +211,17 @@ class Tenant extends Model } /** - * @return BelongsTo + * @return BelongsTo */ - public function websiteType(): BelongsTo + public function adminWebsiteType(): BelongsTo { - return $this->belongsTo(WebsiteType::class, 'website_type_code', 'codigo'); + return $this->belongsTo(AdminWebsiteType::class, 'admin_website_type_code', 'codigo'); + } + + /** @return BelongsTo */ + public function storefrontWebsiteType(): BelongsTo + { + return $this->belongsTo(StorefrontWebsiteType::class, 'storefront_website_type_code', 'codigo'); } public function catalogItems(): HasMany diff --git a/app/Domains/Tenant/Models/WebsiteExtra.php b/app/Domains/Tenant/Models/WebsiteExtra.php index 2698dc2..d87c000 100644 --- a/app/Domains/Tenant/Models/WebsiteExtra.php +++ b/app/Domains/Tenant/Models/WebsiteExtra.php @@ -48,11 +48,11 @@ class WebsiteExtra extends Model } /** - * @return BelongsTo + * @return BelongsTo */ public function websiteTypeExtra(): BelongsTo { - return $this->belongsTo(WebsiteTypeExtra::class, 'website_type_extra_id'); + return $this->belongsTo(StorefrontWebsiteTypeExtra::class, 'website_type_extra_id'); } public function setResolvedConfig(mixed $config): self diff --git a/app/Domains/Tenant/Requests/StoreTenantRequest.php b/app/Domains/Tenant/Requests/StoreTenantRequest.php index 2dc435b..5413e01 100644 --- a/app/Domains/Tenant/Requests/StoreTenantRequest.php +++ b/app/Domains/Tenant/Requests/StoreTenantRequest.php @@ -127,12 +127,13 @@ class StoreTenantRequest extends FormRequest 'min:0', 'max:99.99', ], - 'website_type_code' => [ + 'storefront_website_type_code' => [ 'required_with:extras', 'sometimes', 'string', - Rule::exists('website_type', 'codigo'), + Rule::exists('storefront_website_types', 'codigo'), ], - ], app(WebsiteExtraService::class)->requestRules($this->input('website_type_code'))); + 'admin_website_type_code' => ['sometimes', 'nullable', 'string', Rule::exists('admin_website_types', 'codigo')], + ], app(WebsiteExtraService::class)->requestRules($this->input('storefront_website_type_code'))); } } diff --git a/app/Domains/Tenant/Requests/UpdateTenantRequest.php b/app/Domains/Tenant/Requests/UpdateTenantRequest.php index 4acc110..02ce350 100644 --- a/app/Domains/Tenant/Requests/UpdateTenantRequest.php +++ b/app/Domains/Tenant/Requests/UpdateTenantRequest.php @@ -148,6 +148,18 @@ class UpdateTenantRequest extends FormRequest 'min:0', 'max:99.99', ], + 'admin_website_type_code' => ['sometimes', 'nullable', 'string', Rule::exists('admin_website_types', 'codigo')], + 'storefront_website_type_code' => [ + 'sometimes', + 'nullable', + 'string', + Rule::exists('storefront_website_types', 'codigo'), + function (string $attribute, mixed $value, Closure $fail) use ($tenant): void { + if ($tenant && $value !== $tenant->storefront_website_type_code && $tenant->websiteExtras()->exists()) { + $fail('The storefront website type cannot be changed while the tenant has extras.'); + } + }, + ], ]; } } diff --git a/app/Domains/Tenant/Resources/AdminApp/WebsiteExtrasResource.php b/app/Domains/Tenant/Resources/AdminApp/WebsiteExtrasResource.php index 4a8a1b5..29dc4a8 100644 --- a/app/Domains/Tenant/Resources/AdminApp/WebsiteExtrasResource.php +++ b/app/Domains/Tenant/Resources/AdminApp/WebsiteExtrasResource.php @@ -23,11 +23,11 @@ class WebsiteExtrasResource extends JsonResource ); return [ - 'website_type' => $this->websiteType ? [ - 'codigo' => $this->websiteType->codigo, - 'nombre' => $this->websiteType->nombre, + 'storefront_website_type' => $this->storefrontWebsiteType ? [ + 'codigo' => $this->storefrontWebsiteType->codigo, + 'nombre' => $this->storefrontWebsiteType->nombre, ] : null, - 'definitions' => $this->websiteType?->extras + 'definitions' => $this->storefrontWebsiteType?->extras ->mapWithKeys(fn ($definition) => [ $definition->codigo => [ 'codigo' => $definition->codigo, diff --git a/app/Domains/Tenant/Resources/TenantResource.php b/app/Domains/Tenant/Resources/TenantResource.php index da71d67..31c47bb 100644 --- a/app/Domains/Tenant/Resources/TenantResource.php +++ b/app/Domains/Tenant/Resources/TenantResource.php @@ -35,21 +35,19 @@ class TenantResource extends JsonResource 'nombre' => $this->nombre, 'dominio' => $this->dominio, 'base_path' => $this->base_path, - 'site_title' => $this->site_title - ?? $this->websiteType?->site_title - ?? 'ShopitFront', + 'site_title' => $this->site_title ?? 'ShopitFront', 'asset_url' => config('filesystems.disks.s3.url'), 'address' => $this->address, 'phone' => $this->phone, - 'favicon' => ($this->favicon ?? $this->websiteType?->favicon) - ?->getTemporaryUrl(1440), + 'favicon' => $this->favicon?->getTemporaryUrl(1440), 'primary_color' => $this->primary_color, 'secondary_color' => $this->secondary_color, 'danger_color' => $this->danger_color, 'success_color' => $this->success_color, 'header_bg_color' => $this->header_bg_color, 'footer_bg_color' => $this->footer_bg_color, - 'website_type_code' => $this->website_type_code, + 'admin_website_type_code' => $this->admin_website_type_code, + 'storefront_website_type_code' => $this->storefront_website_type_code, 'event_date_text' => $this->event_date_text, 'event' => $this->whenLoaded('eventDates', fn () => $this->event_title === null ? null diff --git a/app/Domains/Tenant/Services/WebsiteTypeService.php b/app/Domains/Tenant/Services/AdminWebsiteTypeService.php similarity index 79% rename from app/Domains/Tenant/Services/WebsiteTypeService.php rename to app/Domains/Tenant/Services/AdminWebsiteTypeService.php index 9c57eba..db65142 100644 --- a/app/Domains/Tenant/Services/WebsiteTypeService.php +++ b/app/Domains/Tenant/Services/AdminWebsiteTypeService.php @@ -4,11 +4,11 @@ namespace App\Domains\Tenant\Services; use App\Domains\Attachable\Models\Attachment; use App\Domains\Attachable\Services\AttachmentService; -use App\Domains\Tenant\Models\WebsiteType; +use App\Domains\Tenant\Models\AdminWebsiteType; use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; -class WebsiteTypeService +class AdminWebsiteTypeService { public function __construct( protected AttachmentService $attachmentService, @@ -19,9 +19,9 @@ class WebsiteTypeService * * @param array $data */ - public function create(array $data): WebsiteType + public function create(array $data): AdminWebsiteType { - return $this->save(new WebsiteType, $data); + return $this->save(new AdminWebsiteType, $data); } /** @@ -30,10 +30,10 @@ class WebsiteTypeService * @param array $attributes * @param array $values */ - public function updateOrCreate(array $attributes, array $values = []): WebsiteType + public function updateOrCreate(array $attributes, array $values = []): AdminWebsiteType { - /** @var WebsiteType $websiteType */ - $websiteType = WebsiteType::query()->firstOrNew($attributes); + /** @var AdminWebsiteType $websiteType */ + $websiteType = AdminWebsiteType::query()->firstOrNew($attributes); return $this->save($websiteType, [...$attributes, ...$values]); } @@ -41,9 +41,9 @@ class WebsiteTypeService /** * @param array $data */ - private function save(WebsiteType $websiteType, array $data): WebsiteType + private function save(AdminWebsiteType $websiteType, array $data): AdminWebsiteType { - return DB::transaction(function () use ($websiteType, $data): WebsiteType { + return DB::transaction(function () use ($websiteType, $data): AdminWebsiteType { $previousLogos = []; $attachmentFields = [ @@ -68,7 +68,7 @@ class WebsiteTypeService if ($logo) { $attachment = is_string($logo) && Str::isUuid($logo) ? Attachment::query()->where('key', $logo)->first() - : $this->attachmentService->store($logo, 'website-types'); + : $this->attachmentService->store($logo, 'admin-website-types'); } $data[$attachmentField['column']] = $attachment?->id; @@ -82,7 +82,7 @@ class WebsiteTypeService && $previousLogo->id !== $websiteType->site_logo && $previousLogo->id !== $websiteType->footer_logo && $previousLogo->id !== $websiteType->favicon_id - && ! $this->isReferencedByWebsiteType($previousLogo) + && ! $this->isReferencedByBrand($previousLogo) ) { $this->attachmentService->delete($previousLogo); } @@ -92,9 +92,10 @@ class WebsiteTypeService }); } - private function isReferencedByWebsiteType(Attachment $attachment): bool + private function isReferencedByBrand(Attachment $attachment): bool { - return WebsiteType::query() + return Tenant::query()->where('favicon_id', $attachment->id)->exists() + || AdminWebsiteType::query() ->where(function ($query) use ($attachment): void { $query ->where('site_logo', $attachment->id) diff --git a/app/Domains/Tenant/Services/TenantInformationService.php b/app/Domains/Tenant/Services/TenantInformationService.php index 184d266..2e75502 100644 --- a/app/Domains/Tenant/Services/TenantInformationService.php +++ b/app/Domains/Tenant/Services/TenantInformationService.php @@ -14,7 +14,6 @@ class TenantInformationService 'headerLogo', 'footerLogo', 'favicon', - 'websiteType.favicon', 'headerBackgroundImage', 'footerBackgroundImage', 'socialMedia', diff --git a/app/Domains/Tenant/Services/WebsiteExtraService.php b/app/Domains/Tenant/Services/WebsiteExtraService.php index a86a4aa..922cd23 100644 --- a/app/Domains/Tenant/Services/WebsiteExtraService.php +++ b/app/Domains/Tenant/Services/WebsiteExtraService.php @@ -9,8 +9,8 @@ use App\Domains\Shared\Rules\CroppedImageOrBase64Rule; use App\Domains\Shared\Rules\ImageOrBase64Rule; use App\Domains\Tenant\Models\Tenant; use App\Domains\Tenant\Models\WebsiteExtra; -use App\Domains\Tenant\Models\WebsiteType; -use App\Domains\Tenant\Models\WebsiteTypeExtra; +use App\Domains\Tenant\Models\StorefrontWebsiteType; +use App\Domains\Tenant\Models\StorefrontWebsiteTypeExtra; use Illuminate\Support\Collection; use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; @@ -37,7 +37,7 @@ class WebsiteExtraService $definitions = $this->definitionsFor($websiteTypeCode); $allowedCodes = $definitions->pluck('codigo')->all(); $hasRequiredExtras = $definitions->contains( - fn (WebsiteTypeExtra $definition): bool => $definition->is_required + fn (StorefrontWebsiteTypeExtra $definition): bool => $definition->is_required ); $rules = [ @@ -95,11 +95,11 @@ class WebsiteExtraService return; } - $definitions = $this->definitionsFor((string) $tenant->website_type_code) + $definitions = $this->definitionsFor((string) $tenant->storefront_website_type_code) ->keyBy('codigo'); foreach ($extras as $name => $config) { - /** @var WebsiteTypeExtra|null $definition */ + /** @var StorefrontWebsiteTypeExtra|null $definition */ $definition = $definitions->get($name); if (! $definition) { @@ -193,20 +193,20 @@ class WebsiteExtraService }); } - public function definitionForTenant(Tenant $tenant, string $extraCode): WebsiteTypeExtra + public function definitionForTenant(Tenant $tenant, string $extraCode): StorefrontWebsiteTypeExtra { - return WebsiteTypeExtra::query() - ->where('website_type_code', $tenant->website_type_code) + return StorefrontWebsiteTypeExtra::query() + ->where('storefront_website_type_code', $tenant->storefront_website_type_code) ->where('codigo', $extraCode) ->firstOrFail(); } /** - * @return Collection + * @return Collection */ private function definitionsFor(string $websiteTypeCode): Collection { - $websiteType = WebsiteType::query() + $websiteType = StorefrontWebsiteType::query() ->where('codigo', $websiteTypeCode) ->with('extras') ->first(); @@ -252,7 +252,7 @@ class WebsiteExtraService private function applyTransforms( Tenant $tenant, - WebsiteTypeExtra $definition, + StorefrontWebsiteTypeExtra $definition, mixed $config, string $requestRoot ): mixed { @@ -318,7 +318,7 @@ class WebsiteExtraService */ private function transformValue( Tenant $tenant, - WebsiteTypeExtra $definition, + StorefrontWebsiteTypeExtra $definition, string $path, mixed $value, array $transform, diff --git a/database/migrations/2026_09_17_000000_split_website_types.php b/database/migrations/2026_09_17_000000_split_website_types.php new file mode 100644 index 0000000..b42eaf9 --- /dev/null +++ b/database/migrations/2026_09_17_000000_split_website_types.php @@ -0,0 +1,132 @@ +id(); + $table->string('codigo')->unique(); + $table->string('nombre'); + $table->timestamps(); + }); + + DB::table('website_type')->orderBy('id')->chunk(100, function ($types): void { + foreach ($types as $type) { + DB::table('storefront_website_types')->insert([ + 'id' => $type->id, + 'codigo' => $type->codigo, + 'nombre' => $type->nombre, + 'created_at' => $type->created_at, + 'updated_at' => $type->updated_at, + ]); + } + }); + + Schema::table('tenants', function (Blueprint $table): void { + $table->string('storefront_website_type_code')->nullable(); + }); + + DB::table('tenants')->orderBy('id')->chunk(100, function ($tenants): void { + foreach ($tenants as $tenant) { + $type = $tenant->website_type_code + ? DB::table('website_type')->where('codigo', $tenant->website_type_code)->first() + : null; + + DB::table('tenants')->where('id', $tenant->id)->update([ + 'storefront_website_type_code' => $tenant->website_type_code, + 'site_title' => $tenant->site_title ?? $type?->site_title, + 'favicon_id' => $tenant->favicon_id ?? $type?->favicon_id, + ]); + } + }); + + if (DB::getDriverName() !== 'sqlite') { + Schema::table('tenants', fn (Blueprint $table) => $table->dropForeign(['website_type_code'])); + Schema::table('website_type_extras', fn (Blueprint $table) => $table->dropForeign(['website_type_code'])); + Schema::table('website_type_integrations', fn (Blueprint $table) => $table->dropForeign(['website_type_code'])); + } + + Schema::rename('website_type', 'admin_website_types'); + Schema::rename('website_type_extras', 'storefront_website_type_extras'); + Schema::rename('website_type_integrations', 'admin_website_type_integrations'); + + Schema::table('tenants', fn (Blueprint $table) => $table->renameColumn('website_type_code', 'admin_website_type_code')); + Schema::table('storefront_website_type_extras', fn (Blueprint $table) => $table->renameColumn('website_type_code', 'storefront_website_type_code')); + Schema::table('admin_website_type_integrations', fn (Blueprint $table) => $table->renameColumn('website_type_code', 'admin_website_type_code')); + + if (DB::getDriverName() === 'sqlite') { + Schema::disableForeignKeyConstraints(); + Schema::create('storefront_website_type_extras_rebuilt', function (Blueprint $table): void { + $table->id(); + $table->string('storefront_website_type_code'); + $table->foreign('storefront_website_type_code')->references('codigo')->on('storefront_website_types')->cascadeOnUpdate()->cascadeOnDelete(); + $table->string('codigo')->nullable(); + $table->string('nombre'); + $table->text('descripcion'); + $table->boolean('is_required')->default(false); + $table->json('config_schema'); + $table->timestamps(); + $table->unique(['storefront_website_type_code', 'codigo']); + }); + DB::table('storefront_website_type_extras')->orderBy('id')->chunk(100, function ($extras): void { + foreach ($extras as $extra) { + DB::table('storefront_website_type_extras_rebuilt')->insert((array) $extra); + } + }); + Schema::drop('storefront_website_type_extras'); + Schema::rename('storefront_website_type_extras_rebuilt', 'storefront_website_type_extras'); + Schema::enableForeignKeyConstraints(); + } + + Schema::table('tenants', function (Blueprint $table): void { + if (DB::getDriverName() !== 'sqlite') { + $table->foreign('admin_website_type_code')->references('codigo')->on('admin_website_types')->cascadeOnUpdate()->nullOnDelete(); + } + $table->foreign('storefront_website_type_code')->references('codigo')->on('storefront_website_types')->cascadeOnUpdate()->nullOnDelete(); + }); + if (DB::getDriverName() !== 'sqlite') { + Schema::table('storefront_website_type_extras', function (Blueprint $table): void { + $table->foreign('storefront_website_type_code')->references('codigo')->on('storefront_website_types')->cascadeOnUpdate()->cascadeOnDelete(); + }); + Schema::table('admin_website_type_integrations', function (Blueprint $table): void { + $table->foreign('admin_website_type_code')->references('codigo')->on('admin_website_types')->cascadeOnDelete(); + }); + } + } + + public function down(): void + { + if (DB::getDriverName() === 'sqlite') { + throw new RuntimeException('SQLite rollback is unsupported for this foreign-key refactor. Recreate the test database instead.'); + } + + Schema::table('tenants', function (Blueprint $table): void { + $table->dropForeign(['admin_website_type_code']); + $table->dropForeign(['storefront_website_type_code']); + }); + Schema::table('storefront_website_type_extras', fn (Blueprint $table) => $table->dropForeign(['storefront_website_type_code'])); + Schema::table('admin_website_type_integrations', fn (Blueprint $table) => $table->dropForeign(['admin_website_type_code'])); + + Schema::table('tenants', fn (Blueprint $table) => $table->renameColumn('admin_website_type_code', 'website_type_code')); + Schema::table('storefront_website_type_extras', fn (Blueprint $table) => $table->renameColumn('storefront_website_type_code', 'website_type_code')); + Schema::table('admin_website_type_integrations', fn (Blueprint $table) => $table->renameColumn('admin_website_type_code', 'website_type_code')); + + Schema::rename('admin_website_types', 'website_type'); + Schema::rename('storefront_website_type_extras', 'website_type_extras'); + Schema::rename('admin_website_type_integrations', 'website_type_integrations'); + + Schema::table('tenants', function (Blueprint $table): void { + $table->foreign('website_type_code')->references('codigo')->on('website_type')->cascadeOnUpdate()->nullOnDelete(); + $table->dropColumn('storefront_website_type_code'); + }); + Schema::table('website_type_extras', fn (Blueprint $table) => $table->foreign('website_type_code')->references('codigo')->on('website_type')->cascadeOnUpdate()->cascadeOnDelete()); + Schema::table('website_type_integrations', fn (Blueprint $table) => $table->foreign('website_type_code')->references('codigo')->on('website_type')->cascadeOnDelete()); + Schema::dropIfExists('storefront_website_types'); + } +}; diff --git a/database/seeders/DesfilePuraTendenciaSeeder.php b/database/seeders/DesfilePuraTendenciaSeeder.php index 73dfa82..3a29bcb 100644 --- a/database/seeders/DesfilePuraTendenciaSeeder.php +++ b/database/seeders/DesfilePuraTendenciaSeeder.php @@ -78,7 +78,8 @@ class DesfilePuraTendenciaSeeder extends Seeder 'checkout_editing_policy' => 'disabled', 'display_cart_item_images' => false, 'scanner_category_validation_enabled' => false, - 'website_type_code' => 'onticket', + 'admin_website_type_code' => 'onticket', + 'storefront_website_type_code' => 'onticket', 'header_logo' => $this->uploadedImage( 'images/tennants/desfile_pura_tendencia/desfile_pura_tendencia_header.png', 'desfile_pura_tendencia_header.png', diff --git a/database/seeders/TenantSeeder.php b/database/seeders/TenantSeeder.php index 84d39ef..e822e90 100644 --- a/database/seeders/TenantSeeder.php +++ b/database/seeders/TenantSeeder.php @@ -6,7 +6,7 @@ use App\Domains\Attachable\Models\Attachment; use App\Domains\Attachable\Services\AttachmentService; use App\Domains\Client\Models\Client; use App\Domains\Tenant\Models\Tenant; -use App\Domains\Tenant\Models\WebsiteType; +use App\Domains\Tenant\Models\AdminWebsiteType; use App\Domains\Tenant\Services\TenantService; use Illuminate\Database\Seeder; use Illuminate\Http\UploadedFile; @@ -56,7 +56,7 @@ class TenantSeeder extends Seeder ['name' => 'OnTicket'], ); - $onTicketType = WebsiteType::query()->where('codigo', 'onticket')->firstOrFail(); + $onTicketType = AdminWebsiteType::query()->where('codigo', 'onticket')->firstOrFail(); $onTicketTenant = Tenant::query()->where('codigo', 'onticket')->first(); @@ -75,7 +75,8 @@ class TenantSeeder extends Seeder 'footer_bg_color' => $onTicketType->surface_color, 'display_categories' => false, 'display_seach_bar' => false, - 'website_type_code' => $onTicketType->codigo, + 'admin_website_type_code' => $onTicketType->codigo, + 'storefront_website_type_code' => $onTicketType->codigo, 'header_logo' => $this->uploadedImage( 'images/tennants/onticket/onticket_logo.png', 'onticket_logo.png', @@ -127,7 +128,8 @@ class TenantSeeder extends Seeder 'header_logo' => $this->uploadedImage('images/tennants/sonder/sonder_header.png', 'sonder_header.png'), 'footer_logo' => $this->uploadedImage('images/tennants/sonder/sonder_footer.png', 'sonder_footer.png'), 'social_media' => self::SOCIAL_MEDIA, - 'website_type_code' => 'shopit', + 'admin_website_type_code' => 'shopit', + 'storefront_website_type_code' => 'shopit', 'extras' => [ 'carousel' => [ $this->uploadedImage( @@ -195,7 +197,8 @@ class TenantSeeder extends Seeder 'futbol_infantil_favicon.png', ), 'social_media' => self::SOCIAL_MEDIA, - 'website_type_code' => 'onticket', + 'admin_website_type_code' => 'onticket', + 'storefront_website_type_code' => 'onticket', 'extras' => [ 'heroConfig' => [ 'title_html' => '

Fiesta Fútbol Infantil

', diff --git a/database/seeders/WebsiteTypeSeeder.php b/database/seeders/WebsiteTypeSeeder.php index 7db0556..dccbe01 100644 --- a/database/seeders/WebsiteTypeSeeder.php +++ b/database/seeders/WebsiteTypeSeeder.php @@ -2,7 +2,8 @@ namespace Database\Seeders; -use App\Domains\Tenant\Services\WebsiteTypeService; +use App\Domains\Tenant\Services\AdminWebsiteTypeService; +use App\Domains\Tenant\Models\StorefrontWebsiteType; use Illuminate\Database\Seeder; use Illuminate\Http\UploadedFile; use RuntimeException; @@ -22,7 +23,7 @@ class WebsiteTypeSeeder extends Seeder 'border_color' => '#EAEAEA', ]; - public function __construct(private readonly WebsiteTypeService $websiteTypeService) {} + public function __construct(private readonly AdminWebsiteTypeService $websiteTypeService) {} public function run(): void { @@ -40,7 +41,9 @@ class WebsiteTypeSeeder extends Seeder ], ); - $shopIt->extras()->updateOrCreate( + $shopItStorefront = StorefrontWebsiteType::query()->updateOrCreate(['codigo' => 'shopit'], ['nombre' => 'ShopIt']); + + $shopItStorefront->extras()->updateOrCreate( ['codigo' => 'carousel'], [ 'nombre' => 'Carrusel principal', @@ -75,7 +78,9 @@ class WebsiteTypeSeeder extends Seeder ], ); - $onTicket->extras()->updateOrCreate( + $onTicketStorefront = StorefrontWebsiteType::query()->updateOrCreate(['codigo' => 'onticket'], ['nombre' => 'OnTicket']); + + $onTicketStorefront->extras()->updateOrCreate( ['codigo' => 'heroConfig'], [ 'nombre' => 'Configuración del hero', @@ -100,7 +105,7 @@ class WebsiteTypeSeeder extends Seeder ], ); - $onTicket->extras()->updateOrCreate( + $onTicketStorefront->extras()->updateOrCreate( ['codigo' => 'eventConfig'], [ 'nombre' => 'Información del evento', @@ -127,7 +132,7 @@ class WebsiteTypeSeeder extends Seeder ], ); - $onTicket->extras()->updateOrCreate( + $onTicketStorefront->extras()->updateOrCreate( ['codigo' => 'additionalInfoConfig'], [ 'nombre' => 'Información adicional',