fix: update travel models
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
@@ -14,21 +15,22 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $city
|
||||
* @property string $country
|
||||
* @property string $province
|
||||
* @property string $code
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class Airport extends Model
|
||||
{
|
||||
protected $table = 'airports';
|
||||
public $timestamps = false;
|
||||
public static $snakeAttributes = false;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'city',
|
||||
'country',
|
||||
'province',
|
||||
'code'
|
||||
];
|
||||
}
|
||||
|
||||
@@ -45,6 +45,18 @@ class Flight extends Model
|
||||
'status',
|
||||
];
|
||||
|
||||
// مبدا پرواز
|
||||
public function origin()
|
||||
{
|
||||
return $this->belongsTo(Airport::class, 'origin_airport_id');
|
||||
}
|
||||
|
||||
// مقصد پرواز
|
||||
public function destination()
|
||||
{
|
||||
return $this->belongsTo(Airport::class, 'destination_airport_id');
|
||||
}
|
||||
|
||||
/* ------------------------- روابط (Relations) ------------------------- */
|
||||
|
||||
/**
|
||||
|
||||
+45
-75
@@ -14,95 +14,65 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user