fix: update public tour functionality
This commit is contained in:
+14
-2
@@ -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 یعنی غیرفعال/پیشنویس
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user