add separate flight_fields table and move over to flight_field_values

This commit is contained in:
Nabeel Shahzad
2018-03-20 13:06:06 -05:00
parent a9454c319a
commit 485c6e86bb
17 changed files with 147 additions and 45 deletions

View File

@@ -6,6 +6,7 @@ use App\Exceptions\BidExists;
use App\Interfaces\Service;
use App\Models\Bid;
use App\Models\Flight;
use App\Models\FlightFieldValue;
use App\Models\User;
use App\Repositories\FlightRepository;
use App\Repositories\NavdataRepository;
@@ -104,13 +105,33 @@ class FlightService extends Service
* @param Flight $flight
* @throws \Exception
*/
public function deleteFlight(Flight $flight)
public function deleteFlight(Flight $flight): void
{
$where = ['flight_id' => $flight->id];
Bid::where($where)->delete();
$flight->delete();
}
/**
* Update any custom PIREP fields
* @param Flight $flight_id
* @param array $field_values
*/
public function updateCustomFields(Flight $flight_id, array $field_values): void
{
foreach ($field_values as $fv) {
FlightFieldValue::updateOrCreate(
[
'flight_id' => $flight_id,
'name' => $fv['name'],
],
[
'value' => $fv['value']
]
);
}
}
/**
* Return all of the navaid points as a collection
* @param Flight $flight