Move subfleet add/remove to fleet service for a flight

This commit is contained in:
Nabeel Shahzad
2018-03-23 14:10:18 -05:00
parent 1161106d9c
commit f8f5a71564
5 changed files with 61 additions and 2 deletions

View File

@@ -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);
}
}