@@ -5,6 +5,9 @@ namespace App\Contracts;
|
||||
use Illuminate\Validation\Validator;
|
||||
use Prettus\Repository\Eloquent\BaseRepository;
|
||||
|
||||
/**
|
||||
* @mixin \Prettus\Repository\Eloquent\BaseRepository
|
||||
*/
|
||||
abstract class Repository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -47,6 +47,12 @@
|
||||
options: ''
|
||||
type: text
|
||||
description: 'Enter your Google Analytics Tracking ID'
|
||||
- key: units.currency
|
||||
name: 'Currency'
|
||||
group: units
|
||||
value: USD
|
||||
type: select
|
||||
description: 'The currency to use'
|
||||
- key: units.distance
|
||||
name: 'Distance Units'
|
||||
group: units
|
||||
|
||||
@@ -63,7 +63,7 @@ class AirlinesController extends Controller
|
||||
public function store(CreateAirlineRequest $request)
|
||||
{
|
||||
$input = $request->all();
|
||||
$airlines = $this->airlineRepo->create($input);
|
||||
$this->airlineSvc->createAirline($input);
|
||||
|
||||
Flash::success('Airlines saved successfully.');
|
||||
return redirect(route('admin.airlines.index'));
|
||||
|
||||
@@ -7,6 +7,9 @@ use App\Models\Airline;
|
||||
use Prettus\Repository\Contracts\CacheableInterface;
|
||||
use Prettus\Repository\Traits\CacheableRepository;
|
||||
|
||||
/**
|
||||
* @mixin \App\Models\Airline
|
||||
*/
|
||||
class AirlineRepository extends Repository implements CacheableInterface
|
||||
{
|
||||
use CacheableRepository;
|
||||
|
||||
@@ -28,6 +28,21 @@ class AirlineService extends Service
|
||||
$this->subfleetRepo = $subfleetRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new airline, and initialize the journal
|
||||
*
|
||||
* @param array $attr
|
||||
*
|
||||
* @return \App\Models\Airline
|
||||
*/
|
||||
public function createAirline(array $attr): Airline
|
||||
{
|
||||
$airline = $this->airlineRepo->create($attr);
|
||||
$airline->initJournal(setting('units.currency'));
|
||||
|
||||
return $airline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the airline be deleted? Check if there are flights, etc associated with it
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user