diff --git a/app/app/Forms/HostPropertyForm.php b/app/app/Forms/HostPropertyForm.php new file mode 100644 index 0000000..04279d0 --- /dev/null +++ b/app/app/Forms/HostPropertyForm.php @@ -0,0 +1,111 @@ + 'required|array', + 'amenities.*' => 'required', + ], as: [ + 'amenities' => 'amenities', + 'amenities.*' => 'amenity item', + ], message: [ + 'amenities.required' => 'Amenities are required.', + ])] + public array $amenities = []; + + // Rates + #[Validate('required|numeric|min:1|max:1000|decimal:0,2', as: 'base rate')] + public int|string $base_rate = ''; + + #[Validate('required|numeric|min:0|max:99', as: 'tax rate')] + public int|string $tax_rate = ''; + + #[Validate([ + 'fees' => 'nullable|array:name,amount,type', + 'fees.*.name' => 'required|string|max:250', + 'fees.*.amount' => 'required|numeric|min:0|max:1000|decimal:0,2', + 'fees.*.type' => 'required|in:fixed,variable', + ], as: [ + 'fees.*.name' => 'fee name', + 'fees.*.amount' => 'fee amount', + 'fees.*.type' => 'fee type', + ])] + public array $fees = []; + + // Photos + #[Validate([ + 'photos' => 'required', + 'photos.*' => 'required|image|mimes:jpg,jpeg,png,webp,bmp|extensions:jpg,jpeg,png,webp,bmp|max:10240', + ], as: [ + 'photos.' => 'photos', + 'photos.*' => 'photo', + ])] + public array $photos = []; + + // Options + #[Validate('required|string|max:250|unique:properties,slug|regex:^[a-z0-9]+(?:-[a-z0-9]+)*$', as: 'url', onUpdate: false)] + public ?string $slug; + + #[Validate('required|integer|min:1|max:99', as: 'minimum nights')] + public int $duration_min = 1; + + #[Validate('required|integer|min:1|max:99', as: 'maximum nights')] + public int $duration_max = 14; + + #[Validate('required|string|in:private,unlisted,public', as: 'visibility')] + public ?string $visibility; + + #[Validate('required|regex:/^#[0-9A-Fa-f]{6}$/', as: 'color')] + public string $calendar_color = '#2563eb'; +} diff --git a/app/app/Models/Property.php b/app/app/Models/Property.php index 36fb229..0322cc8 100644 --- a/app/app/Models/Property.php +++ b/app/app/Models/Property.php @@ -2,6 +2,7 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Concerns\HasUuids; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; @@ -9,7 +10,7 @@ class Property extends Model { - use HasFactory; + use HasFactory, HasUuids; /** * Automatically generate a unique slug for the property. diff --git a/app/database/migrations/2023_12_25_042434_create_properties_table.php b/app/database/migrations/2023_12_25_042434_create_properties_table.php index dd40b93..a705dad 100644 --- a/app/database/migrations/2023_12_25_042434_create_properties_table.php +++ b/app/database/migrations/2023_12_25_042434_create_properties_table.php @@ -22,9 +22,9 @@ public function up(): void $table->integer('address_postal'); $table->string('address_country'); // Listing - $table->integer('type_id'); $table->string('listing_headline'); $table->text('listing_description'); + $table->integer('type_id'); $table->integer('guest_count'); $table->integer('bed_count'); $table->integer('bedroom_count'); @@ -33,11 +33,11 @@ public function up(): void $table->integer('base_rate'); $table->integer('tax_rate'); // Options + $table->string('slug'); + $table->string('calendar_color'); $table->integer('duration_min'); $table->integer('duration_max'); $table->string('visibility'); - $table->string('slug'); - $table->string('calendar_color'); $table->integer('host_id'); $table->timestamps(); diff --git a/app/resources/js/app.js b/app/resources/js/app.js index c71c059..bfdd73a 100644 --- a/app/resources/js/app.js +++ b/app/resources/js/app.js @@ -46,11 +46,15 @@ window.addEventListener("console", (event) => { console.log(event.detail); }); -// window.addEventListener( -// "popstate", -// (event) => { -// // The popstate event is fired each time when the current history entry changes. -// location.reload(); -// }, -// false, -// ); + +/** + * https://github.com/marchershey/lodge-board-beta/issues/130 + */ +window.addEventListener( + "popstate", + (event) => { + // The popstate event is fired each time when the current history entry changes. + location.reload(); + }, + false, +); diff --git a/app/resources/views/layouts/host.blade.php b/app/resources/views/layouts/host.blade.php index 0c7d227..aa825a3 100644 --- a/app/resources/views/layouts/host.blade.php +++ b/app/resources/views/layouts/host.blade.php @@ -154,7 +154,7 @@ {{-- Content Container --}} -
+