Compare commits
2 Commits
19b506a465
...
68dd373d61
| Author | SHA1 | Date | |
|---|---|---|---|
| 68dd373d61 | |||
| 8d8e49fcfb |
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Domains\Event\Models;
|
namespace App\Domains\Event\Models;
|
||||||
|
|
||||||
use App\Domains\Catalog\Models\Variant;
|
use App\Domains\Catalog\Models\Variant;
|
||||||
|
use App\Domains\Event\Services\EventDateTextFormatter;
|
||||||
use App\Domains\Tenant\Models\Tenant;
|
use App\Domains\Tenant\Models\Tenant;
|
||||||
use Carbon\CarbonInterface;
|
use Carbon\CarbonInterface;
|
||||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||||
@@ -25,6 +26,12 @@ class EventDate extends Model
|
|||||||
|
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
|
protected static function booted(): void
|
||||||
|
{
|
||||||
|
static::saved(fn (self $eventDate) => $eventDate->syncTenantDateText());
|
||||||
|
static::deleted(fn (self $eventDate) => $eventDate->syncTenantDateText());
|
||||||
|
}
|
||||||
|
|
||||||
protected function casts(): array
|
protected function casts(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@@ -64,4 +71,19 @@ class EventDate extends Model
|
|||||||
{
|
{
|
||||||
return Carbon::parse($this->date->format('Y-m-d').' '.$this->time_end);
|
return Carbon::parse($this->date->format('Y-m-d').' '.$this->time_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function syncTenantDateText(): void
|
||||||
|
{
|
||||||
|
$tenant = $this->tenant()->first();
|
||||||
|
|
||||||
|
if (! $tenant) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tenant->update([
|
||||||
|
'event_date_text' => app(EventDateTextFormatter::class)->format(
|
||||||
|
$tenant->eventDates()->pluck('date')
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ class EventService
|
|||||||
'facebook_url' => 'facebook',
|
'facebook_url' => 'facebook',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct(protected EventDateTextFormatter $eventDateTextFormatter) {}
|
|
||||||
|
|
||||||
public function forTenant(Tenant $tenant): Tenant
|
public function forTenant(Tenant $tenant): Tenant
|
||||||
{
|
{
|
||||||
return $tenant->load(['eventDates', 'socialMedia']);
|
return $tenant->load(['eventDates', 'socialMedia']);
|
||||||
@@ -28,9 +26,6 @@ class EventService
|
|||||||
$tenant->update([
|
$tenant->update([
|
||||||
'event_title' => $data['title'],
|
'event_title' => $data['title'],
|
||||||
'event_location' => $data['location'],
|
'event_location' => $data['location'],
|
||||||
'event_date_text' => $this->eventDateTextFormatter->format(
|
|
||||||
array_column($data['dates'], 'date')
|
|
||||||
),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->syncDates($tenant, $data['dates']);
|
$this->syncDates($tenant, $data['dates']);
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
|||||||
'search_product_layout',
|
'search_product_layout',
|
||||||
'search_group_layout',
|
'search_group_layout',
|
||||||
'search_items_per_page',
|
'search_items_per_page',
|
||||||
|
'display_categories',
|
||||||
|
'display_seach_bar',
|
||||||
'event_title',
|
'event_title',
|
||||||
'event_location',
|
'event_location',
|
||||||
'event_date_text',
|
'event_date_text',
|
||||||
@@ -45,6 +47,8 @@ class Tenant extends Model
|
|||||||
'search_product_layout' => ProductLayout::ColumnWithImage->value,
|
'search_product_layout' => ProductLayout::ColumnWithImage->value,
|
||||||
'search_group_layout' => GroupLayout::Paginated->value,
|
'search_group_layout' => GroupLayout::Paginated->value,
|
||||||
'search_items_per_page' => 12,
|
'search_items_per_page' => 12,
|
||||||
|
'display_categories' => true,
|
||||||
|
'display_seach_bar' => true,
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getRouteKeyName(): string
|
public function getRouteKeyName(): string
|
||||||
@@ -63,6 +67,8 @@ class Tenant extends Model
|
|||||||
'search_product_layout' => ProductLayout::class,
|
'search_product_layout' => ProductLayout::class,
|
||||||
'search_group_layout' => GroupLayout::class,
|
'search_group_layout' => GroupLayout::class,
|
||||||
'search_items_per_page' => 'integer',
|
'search_items_per_page' => 'integer',
|
||||||
|
'display_categories' => 'boolean',
|
||||||
|
'display_seach_bar' => 'boolean',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ class WebsiteExtra extends Model
|
|||||||
|
|
||||||
protected $table = 'websites_extras';
|
protected $table = 'websites_extras';
|
||||||
|
|
||||||
|
protected $attributes = [
|
||||||
|
'is_enabled' => true,
|
||||||
|
];
|
||||||
|
|
||||||
private mixed $resolvedConfig = null;
|
private mixed $resolvedConfig = null;
|
||||||
|
|
||||||
private bool $hasResolvedConfig = false;
|
private bool $hasResolvedConfig = false;
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ class StoreTenantRequest extends FormRequest
|
|||||||
'search_product_layout' => ['sometimes', Rule::enum(ProductLayout::class)],
|
'search_product_layout' => ['sometimes', Rule::enum(ProductLayout::class)],
|
||||||
'search_group_layout' => ['sometimes', Rule::enum(GroupLayout::class)],
|
'search_group_layout' => ['sometimes', Rule::enum(GroupLayout::class)],
|
||||||
'search_items_per_page' => ['sometimes', 'integer', 'min:4', 'max:48'],
|
'search_items_per_page' => ['sometimes', 'integer', 'min:4', 'max:48'],
|
||||||
|
'display_categories' => ['sometimes', 'boolean'],
|
||||||
|
'display_seach_bar' => ['sometimes', 'boolean'],
|
||||||
'website_type_code' => [
|
'website_type_code' => [
|
||||||
'required_with:extras',
|
'required_with:extras',
|
||||||
'sometimes',
|
'sometimes',
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ class UpdateTenantRequest extends FormRequest
|
|||||||
'search_product_layout' => ['sometimes', Rule::enum(ProductLayout::class)],
|
'search_product_layout' => ['sometimes', Rule::enum(ProductLayout::class)],
|
||||||
'search_group_layout' => ['sometimes', Rule::enum(GroupLayout::class)],
|
'search_group_layout' => ['sometimes', Rule::enum(GroupLayout::class)],
|
||||||
'search_items_per_page' => ['sometimes', 'integer', 'min:4', 'max:48'],
|
'search_items_per_page' => ['sometimes', 'integer', 'min:4', 'max:48'],
|
||||||
|
'display_categories' => ['sometimes', 'boolean'],
|
||||||
|
'display_seach_bar' => ['sometimes', 'boolean'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ class TenantResource extends JsonResource
|
|||||||
'search_product_layout' => $this->search_product_layout->value,
|
'search_product_layout' => $this->search_product_layout->value,
|
||||||
'search_group_layout' => $this->search_group_layout->value,
|
'search_group_layout' => $this->search_group_layout->value,
|
||||||
'search_items_per_page' => $this->search_items_per_page,
|
'search_items_per_page' => $this->search_items_per_page,
|
||||||
|
'display_categories' => $this->display_categories,
|
||||||
|
'display_seach_bar' => $this->display_seach_bar,
|
||||||
'social_media' => $this->whenLoaded(
|
'social_media' => $this->whenLoaded(
|
||||||
'socialMedia',
|
'socialMedia',
|
||||||
fn () => $this->socialMedia
|
fn () => $this->socialMedia
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('tenants', function (Blueprint $table): void {
|
||||||
|
$table->boolean('display_categories')->default(true)->after('search_items_per_page');
|
||||||
|
$table->boolean('display_seach_bar')->default(true)->after('display_categories');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('tenants', function (Blueprint $table): void {
|
||||||
|
$table->dropColumn(['display_categories', 'display_seach_bar']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
DB::table('tenants')
|
||||||
|
->where('codigo', 'fiesta_futbol_infantil')
|
||||||
|
->update([
|
||||||
|
'display_categories' => false,
|
||||||
|
'display_seach_bar' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
DB::table('tenants')
|
||||||
|
->where('codigo', 'sonder')
|
||||||
|
->update([
|
||||||
|
'display_categories' => true,
|
||||||
|
'display_seach_bar' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void {}
|
||||||
|
};
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
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
|
||||||
|
{
|
||||||
|
DB::table('websites_extras')
|
||||||
|
->whereNull('is_enabled')
|
||||||
|
->update(['is_enabled' => true]);
|
||||||
|
|
||||||
|
Schema::table('websites_extras', function (Blueprint $table): void {
|
||||||
|
$table->boolean('is_enabled')->default(true)->nullable(false)->change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('websites_extras', function (Blueprint $table): void {
|
||||||
|
$table->boolean('is_enabled')->nullable()->default(null)->change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -56,6 +56,8 @@ class TenantSeeder extends Seeder
|
|||||||
'success_color' => '#198754',
|
'success_color' => '#198754',
|
||||||
'header_bg_color' => '#ffffff',
|
'header_bg_color' => '#ffffff',
|
||||||
'footer_bg_color' => '#313131',
|
'footer_bg_color' => '#313131',
|
||||||
|
'display_categories' => true,
|
||||||
|
'display_seach_bar' => true,
|
||||||
'header_logo' => $this->uploadedImage('images/tennants/sonder/sonder_header.png', 'sonder_header.png'),
|
'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'),
|
'footer_logo' => $this->uploadedImage('images/tennants/sonder/sonder_footer.png', 'sonder_footer.png'),
|
||||||
'social_media' => self::SOCIAL_MEDIA,
|
'social_media' => self::SOCIAL_MEDIA,
|
||||||
@@ -107,6 +109,8 @@ class TenantSeeder extends Seeder
|
|||||||
'success_color' => '#198754',
|
'success_color' => '#198754',
|
||||||
'header_bg_color' => '#ffffff',
|
'header_bg_color' => '#ffffff',
|
||||||
'footer_bg_color' => '#015327',
|
'footer_bg_color' => '#015327',
|
||||||
|
'display_categories' => false,
|
||||||
|
'display_seach_bar' => false,
|
||||||
'header_logo' => $this->uploadedImage(
|
'header_logo' => $this->uploadedImage(
|
||||||
'images/tennants/fiesta_futbol_infantil/futbol_infantil_header.png',
|
'images/tennants/fiesta_futbol_infantil/futbol_infantil_header.png',
|
||||||
'futbol_infantil_header.png',
|
'futbol_infantil_header.png',
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ class FiestaFutbolInfantilProductSeederTest extends TestCase
|
|||||||
$this->seed([AttributeSeeder::class, FiestaFutbolInfantilProductSeeder::class]);
|
$this->seed([AttributeSeeder::class, FiestaFutbolInfantilProductSeeder::class]);
|
||||||
$this->seed([AttributeSeeder::class, FiestaFutbolInfantilProductSeeder::class]);
|
$this->seed([AttributeSeeder::class, FiestaFutbolInfantilProductSeeder::class]);
|
||||||
|
|
||||||
|
$this->assertSame('9, 10, 11 y 12 de Octubre 2026', $tenant->fresh()->event_date_text);
|
||||||
|
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
['color', 'event_date', 'horario', 'servicio', 'talle', 'tipo_alojamiento'],
|
['color', 'event_date', 'horario', 'servicio', 'talle', 'tipo_alojamiento'],
|
||||||
Attribute::query()->where('tenant_codigo', $tenant->codigo)->orderBy('codigo')->pluck('codigo')->all(),
|
Attribute::query()->where('tenant_codigo', $tenant->codigo)->orderBy('codigo')->pluck('codigo')->all(),
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ class BootstrapTenantControllerTest extends TestCase
|
|||||||
'header_logo_id' => $headerAttachment->id,
|
'header_logo_id' => $headerAttachment->id,
|
||||||
'footer_logo_id' => $footerAttachment->id,
|
'footer_logo_id' => $footerAttachment->id,
|
||||||
'event_date_text' => '9, 10, 11 y 12 de Octubre 2026',
|
'event_date_text' => '9, 10, 11 y 12 de Octubre 2026',
|
||||||
|
'display_categories' => false,
|
||||||
|
'display_seach_bar' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response = $this->getJson('/api/tenants/bootstrap/acme.com');
|
$response = $this->getJson('/api/tenants/bootstrap/acme.com');
|
||||||
@@ -66,6 +68,8 @@ class BootstrapTenantControllerTest extends TestCase
|
|||||||
->assertJsonPath('data.danger_color', '#0000ff')
|
->assertJsonPath('data.danger_color', '#0000ff')
|
||||||
->assertJsonPath('data.success_color', '#00ff00')
|
->assertJsonPath('data.success_color', '#00ff00')
|
||||||
->assertJsonPath('data.event_date_text', '9, 10, 11 y 12 de Octubre 2026')
|
->assertJsonPath('data.event_date_text', '9, 10, 11 y 12 de Octubre 2026')
|
||||||
|
->assertJsonPath('data.display_categories', false)
|
||||||
|
->assertJsonPath('data.display_seach_bar', false)
|
||||||
->assertJsonPath('data.header_bg_color', '#ffffff')->assertJsonPath('data.footer_bg_color', '#ffffff');
|
->assertJsonPath('data.header_bg_color', '#ffffff')->assertJsonPath('data.footer_bg_color', '#ffffff');
|
||||||
|
|
||||||
$headerUrl = $response->json('data.header_logo');
|
$headerUrl = $response->json('data.header_logo');
|
||||||
|
|||||||
Reference in New Issue
Block a user