2017-06-11 07:27:19 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
|
|
use App\Models\AircraftClass;
|
|
|
|
use Dompdf\Exception;
|
|
|
|
|
|
|
|
class AircraftService extends BaseService
|
|
|
|
{
|
|
|
|
|
|
|
|
public function create(
|
|
|
|
array $attributes,
|
|
|
|
AircraftClass $class = null
|
|
|
|
) {
|
|
|
|
|
2017-06-24 06:33:18 +08:00
|
|
|
$repo = app('App\Repositories\SubfleetRepository');
|
2017-06-11 07:27:19 +08:00
|
|
|
try {
|
|
|
|
$model = $repo->create($attributes);
|
|
|
|
} catch (Exception $e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($class != null) {
|
|
|
|
$model->class()->associate($class);
|
|
|
|
$model->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
return $model;
|
|
|
|
}
|
|
|
|
}
|