fix: update public tour functionality

This commit is contained in:
2026-08-20 08:27:53 +03:30
parent 9b7934c0ba
commit 2a980ecc55
2 changed files with 78 additions and 15 deletions
+14 -2
View File
@@ -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 یعنی غیرفعال/پیش‌نویس
}
});
}
}