feat: complete flight index blade
This commit is contained in:
+28
-2
@@ -7,12 +7,14 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Attributes\Scope;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Flight
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $title
|
||||
* @property int|null $file_id
|
||||
@@ -28,7 +30,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @property int $status
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*
|
||||
*
|
||||
* @property Airline $airline
|
||||
* @property File|null $file
|
||||
* @property Airport $airport
|
||||
@@ -49,6 +51,7 @@ class Flight extends Model
|
||||
'arrival_airport_id' => 'int',
|
||||
'price' => 'float',
|
||||
'capacity' => 'int',
|
||||
'views' => 'int',
|
||||
'status' => 'int'
|
||||
];
|
||||
|
||||
@@ -64,6 +67,7 @@ class Flight extends Model
|
||||
'summary',
|
||||
'capacity',
|
||||
'description',
|
||||
'views',
|
||||
'status'
|
||||
];
|
||||
|
||||
@@ -86,4 +90,26 @@ class Flight extends Model
|
||||
{
|
||||
return $this->hasMany(Booking::class);
|
||||
}
|
||||
public function arrivalAirport()
|
||||
{
|
||||
return $this->belongsTo(Airport::class, 'arrival_airport_id');
|
||||
}
|
||||
public function departureAirport()
|
||||
{
|
||||
return $this->belongsTo(Airport::class, 'departure_airport_id');
|
||||
}
|
||||
public function comments()
|
||||
{
|
||||
return $this->hasMany(Comment::class, 'flight_id');
|
||||
}
|
||||
|
||||
#[Scope]
|
||||
protected function applyFilter(Builder $query): void
|
||||
{
|
||||
$request = request();
|
||||
|
||||
if ($request->filled('flight_type')) {
|
||||
$query->where('flight_type', $request->input('flight_type'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user