list trips
add, remove flights
This commit is contained in:
24
app/Libraries/Trips/Models/Flights.php
Normal file
24
app/Libraries/Trips/Models/Flights.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries\Trips\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Flights extends Model
|
||||
{
|
||||
|
||||
protected $fillable = ['destination'];
|
||||
|
||||
public function trips()
|
||||
{
|
||||
return $this->belongsToMany(Trips::class, 'trip_flights');
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'destination' => $this->destination,
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Libraries/Trips/Models/Trips.php
Normal file
19
app/Libraries/Trips/Models/Trips.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries\Trips\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Trips extends Model
|
||||
{
|
||||
|
||||
protected $fillable = ['name'];
|
||||
|
||||
/**
|
||||
* relation to flights
|
||||
*/
|
||||
public function flights()
|
||||
{
|
||||
return $this->belongsToMany(Flights::class, 'trip_flights');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user