Server IP : 66.29.132.124 / Your IP : 13.59.69.58 Web Server : LiteSpeed System : Linux business141.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : wavevlvu ( 1524) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/wavevlvu/book24.ng/modules/Flight/Models/ |
Upload File : |
<?php namespace Modules\Flight\Models; use App\BaseModel; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\SoftDeletes; use Modules\Flight\Factories\FlightSeatFactory; class FlightSeat extends BaseModel { use SoftDeletes; use HasFactory; protected $table = 'bravo_flight_seat'; protected $fillable=['seat_type','flight_id','price','max_passengers','person','baggage_check_in','baggage_cabin']; public function flight() { return $this->belongsTo(Flight::class,'flight_id')->withDefault(); } public function seatType(){ return $this->belongsTo(SeatType::class,'seat_type','code')->withDefault(); } protected static function newFactory() { return FlightSeatFactory::new(); } public function save(array $options = []) { $save = parent::save($options); // TODO: Change the autogenerated stub if($save){ $min_price = self::where('flight_id',$this->flight_id)->get()->min('price'); $flight= $this->flight; if($min_price < $flight->min_price or empty($flight->min_price)){ $flight->min_price = $min_price; $flight->save(); } } return $save; } }