git commit "add comments and fix tour comments display"
This commit is contained in:
+18
-11
@@ -11,16 +11,17 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Comment
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property int $tour_id
|
||||
* @property int $flight_id
|
||||
* @property int $rating
|
||||
* @property string|null $comment
|
||||
* @property int $status
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*
|
||||
*
|
||||
* @property Tour $tour
|
||||
* @property User $user
|
||||
*
|
||||
@@ -34,6 +35,7 @@ class Comment extends Model
|
||||
protected $casts = [
|
||||
'user_id' => 'int',
|
||||
'tour_id' => 'int',
|
||||
'flight_id' => 'int',
|
||||
'rating' => 'int',
|
||||
'status' => 'int'
|
||||
];
|
||||
@@ -41,18 +43,23 @@ class Comment extends Model
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'tour_id',
|
||||
'flight_id',
|
||||
'rating',
|
||||
'comment',
|
||||
'status'
|
||||
];
|
||||
|
||||
public function tour()
|
||||
{
|
||||
return $this->belongsTo(Tour::class);
|
||||
}
|
||||
public function tour()
|
||||
{
|
||||
return $this->belongsTo(Tour::class, 'tour_id');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
public function flight()
|
||||
{
|
||||
return $this->belongsTo(Flight::class, 'flight_id');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}}
|
||||
|
||||
+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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @property string $summary
|
||||
* @property string $description
|
||||
* @property string $image
|
||||
* @property string $views
|
||||
* @property int $travel_type_id
|
||||
* @property float $price
|
||||
* @property Carbon $departure_date
|
||||
@@ -46,6 +47,7 @@ class Tour extends Model
|
||||
'summary',
|
||||
'description',
|
||||
'image',
|
||||
'views',
|
||||
'travel_type_id',
|
||||
'price',
|
||||
'departure_date',
|
||||
|
||||
@@ -37,4 +37,8 @@ class TravelType extends Model
|
||||
{
|
||||
return $this->hasMany(Tour::class, 'travel_type_id');
|
||||
}
|
||||
public function flights()
|
||||
{
|
||||
return $this->hasMany(Flight::class, 'travel_type_id');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user