git commit "add comments and fix tour comments display"
This commit is contained in:
+52
-42
@@ -23,10 +23,10 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @property Carbon|null $departure_time
|
||||
* @property Carbon|null $arrival_time
|
||||
* @property string|null $flight_class
|
||||
* @property string|null $image
|
||||
* @property string $views
|
||||
* @property int|null $capacity
|
||||
* @property float|null $price
|
||||
* @property string|null $image
|
||||
* @property string|null $views
|
||||
* @property int|null $status
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
@@ -35,49 +35,59 @@ use Illuminate\Database\Eloquent\Model;
|
||||
*/
|
||||
class Flight extends Model
|
||||
{
|
||||
protected $table = 'flights';
|
||||
public static $snakeAttributes = false;
|
||||
protected $table = 'flights';
|
||||
public static $snakeAttributes = false;
|
||||
|
||||
protected $casts = [
|
||||
'departure_date' => 'datetime',
|
||||
'departure_time' => 'datetime',
|
||||
'arrival_time' => 'datetime',
|
||||
'capacity' => 'int',
|
||||
'price' => 'float',
|
||||
'status' => 'int'
|
||||
];
|
||||
protected $casts = [
|
||||
'departure_date' => 'datetime',
|
||||
'departure_time' => 'datetime',
|
||||
'arrival_time' => 'datetime',
|
||||
'capacity' => 'int',
|
||||
'price' => 'float',
|
||||
'status' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'airline',
|
||||
'flight_number',
|
||||
'origin',
|
||||
'destination',
|
||||
'departure_date',
|
||||
'departure_time',
|
||||
'arrival_time',
|
||||
'flight_class',
|
||||
'capacity',
|
||||
'price',
|
||||
protected $fillable = [
|
||||
'airline',
|
||||
'flight_number',
|
||||
'origin',
|
||||
'destination',
|
||||
'departure_date',
|
||||
'departure_time',
|
||||
'arrival_time',
|
||||
'flight_class',
|
||||
'capacity',
|
||||
'price',
|
||||
'image',
|
||||
'views',
|
||||
'status'
|
||||
];
|
||||
'status'
|
||||
];
|
||||
|
||||
#[Scope]
|
||||
public function applySearch(Builder $query, array $filters): void
|
||||
{
|
||||
$query
|
||||
->when($filters['origin'] ?? null, function ($query, $origin) {
|
||||
$query->where('origin', $origin);
|
||||
})
|
||||
->when($filters['destination'] ?? null, function ($query, $destination) {
|
||||
$query->where('destination', $destination);
|
||||
})
|
||||
->when($filters['departure_date'] ?? null, function ($query, $date) {
|
||||
$query->whereDate('departure_date', $date);
|
||||
})
|
||||
->when($filters['passengers'] ?? null, function ($query, $passengers) {
|
||||
$query->where('capacity', '>=', $passengers);
|
||||
});
|
||||
public function travelType()
|
||||
{
|
||||
return $this->belongsTo(TravelType::class);
|
||||
}
|
||||
|
||||
public function comments()
|
||||
{
|
||||
return $this->hasMany(Comment::class);
|
||||
}
|
||||
|
||||
#[Scope]
|
||||
public function applySearch(Builder $query, array $filters): void
|
||||
{
|
||||
$query
|
||||
->when($filters['origin'] ?? null, function ($query, $origin) {
|
||||
$query->where('origin', $origin);
|
||||
})
|
||||
->when($filters['destination'] ?? null, function ($query, $destination) {
|
||||
$query->where('destination', $destination);
|
||||
})
|
||||
->when($filters['departure_date'] ?? null, function ($query, $date) {
|
||||
$query->whereDate('departure_date', $date);
|
||||
})
|
||||
->when($filters['passengers'] ?? null, function ($query, $passengers) {
|
||||
$query->where('capacity', '>=', $passengers);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user