Move subfleet add/remove to fleet service for a flight
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Services;
|
||||
|
||||
use App\Interfaces\Service;
|
||||
use App\Models\Flight;
|
||||
use App\Models\Rank;
|
||||
use App\Models\Subfleet;
|
||||
|
||||
@@ -41,4 +42,26 @@ class FleetService extends Service
|
||||
|
||||
return $subfleet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the subfleet to a flight
|
||||
* @param Subfleet $subfleet
|
||||
* @param Flight $flight
|
||||
*/
|
||||
public function addSubfleetToFlight(Subfleet $subfleet, Flight $flight)
|
||||
{
|
||||
$flight->subfleets()->syncWithoutDetaching([$subfleet->id]);
|
||||
$subfleet->save();
|
||||
$subfleet->refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the subfleet from a flight
|
||||
* @param Subfleet $subfleet
|
||||
* @param Flight $flight
|
||||
*/
|
||||
public function removeSubfleetFromFlight(Subfleet $subfleet, Flight $flight)
|
||||
{
|
||||
$flight->subfleets()->detach($subfleet->id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user