From 2a980ecc55f856c134793a20dcb8acf0c9e0d6e3 Mon Sep 17 00:00:00 2001 From: shahrzad011 Date: Thu, 20 Aug 2026 08:27:53 +0330 Subject: [PATCH] fix: update public tour functionality --- app/Models/Tour.php | 16 ++++- resources/views/components/tour.blade.php | 77 +++++++++++++++++++---- 2 files changed, 78 insertions(+), 15 deletions(-) diff --git a/app/Models/Tour.php b/app/Models/Tour.php index c7d7044..e32ebca 100644 --- a/app/Models/Tour.php +++ b/app/Models/Tour.php @@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class Tour - * + * * @property int $id * @property int|null $travel_type_id * @property string $title @@ -28,7 +28,7 @@ use Illuminate\Database\Eloquent\Model; * @property int $status * @property Carbon $created_at * @property Carbon $updated_at - * + * * @property TravelType|null $travelType * @property Collection|Flight[] $flights * @@ -75,4 +75,16 @@ class Tour extends Model ->withPivot('id') ->withTimestamps(); } + protected static function booted() + { + static::creating(function ($tour) { + // اگر مقداری تعیین نشده بود، پیش‌فرض‌ها را اعمال کن + if (is_null($tour->views_count)) { + $tour->views_count = 0; + } + if (is_null($tour->status)) { + $tour->status = 0; // فرض بر اینکه 0 یعنی غیرفعال/پیش‌نویس + } + }); + } } diff --git a/resources/views/components/tour.blade.php b/resources/views/components/tour.blade.php index fdbba36..11988b6 100644 --- a/resources/views/components/tour.blade.php +++ b/resources/views/components/tour.blade.php @@ -1,19 +1,70 @@ -@props(['tour']) +