fix: update travel models

This commit is contained in:
2026-08-19 08:11:32 +03:30
parent 4aa2e9fb65
commit a9d46fe64c
3 changed files with 64 additions and 80 deletions
+47 -77
View File
@@ -12,97 +12,67 @@ use Illuminate\Database\Eloquent\Model;
/**
* Class Tour
*
*
* @property int $id
* @property int $travel_type_id
* @property int|null $travel_type_id
* @property string $title
* @property string $slug
* @property string $description
* @property string $duration
* @property Carbon $start_date
* @property Carbon $end_date
* @property string|null $slug
* @property string|null $image
* @property string|null $description
* @property string|null $duration
* @property Carbon|null $start_date
* @property Carbon|null $end_date
* @property float $price
* @property int $capacity
* @property int|null $capacity
* @property int $views_count
* @property int $status
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @property TravelType $travelType
*
* @property TravelType|null $travelType
* @property Collection|Flight[] $flights
*
* @package App\Models
*/
class Tour extends Model
{
protected $table = 'tours';
public static $snakeAttributes = false;
protected $table = 'tours';
public static $snakeAttributes = false;
protected $casts = [
'start_date' => 'date',
'end_date' => 'date',
'price' => 'decimal:2',
'status' => 'integer',
protected $casts = [
'travel_type_id' => 'int',
'start_date' => 'datetime',
'end_date' => 'datetime',
'price' => 'float',
'capacity' => 'int',
'views_count' => 'int',
'status' => 'int'
];
// 'travel_type_id' => 'int',
// 'start_date' => 'datetime',
// 'end_date' => 'datetime',
// 'price' => 'float',
// 'capacity' => 'int',
// 'status' => 'int'
];
protected $fillable = [
'travel_type_id',
'title',
'slug',
'description',
'duration',
'start_date',
'end_date',
'price',
'capacity',
'status',
'image',
];
public function travelType()
{
return $this->belongsTo(TravelType::class);
}
public function flights()
{
return $this->belongsToMany(Flight::class, 'tour_flights')
->withPivot('id')
->withTimestamps();
}
//اضافه شده (بعدا بررسی بشه)
public function comments()
{
return $this->morphMany(Comment::class, 'commentable');
}
public function favorites()
{
return $this->morphMany(Favorite::class, 'favoritable');
}
public function files()
{
return $this->morphMany(File::class, 'fileable');
}
public function getRouteKeyName()
{
return 'slug';
}
public function getStatusLabelAttribute()
{
return $this->status == 1 ? 'فعال' : 'پیش‌نویس';
}
protected $fillable = [
'travel_type_id',
'title',
'slug',
'image',
'description',
'duration',
'start_date',
'end_date',
'price',
'capacity',
'views_count',
'status'
];
public function travelType()
{
return $this->belongsTo(TravelType::class);
}
public function flights()
{
return $this->belongsToMany(Flight::class, 'tour_flights')
->withPivot('id')
->withTimestamps();
}
}