Files
shahrzadzandi09/app/Models/Tour.php
T

97 lines
1.9 KiB
PHP

<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
/**
* Class Tour
*
* @property int $id
* @property int $travel_type_id
* @property string $title
* @property string $slug
* @property string $description
* @property string $duration
* @property Carbon $start_date
* @property Carbon $end_date
* @property float $price
* @property int $capacity
* @property int $status
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @property TravelType $travelType
* @property Collection|Flight[] $flights
*
* @package App\Models
*/
class Tour extends Model
{
protected $table = 'tours';
public static $snakeAttributes = false;
protected $casts = [
'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'
];
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';
}
}