2017-06-09 09:37:51 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Repositories;
|
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
use App\Interfaces\Repository;
|
2017-06-09 09:37:51 +08:00
|
|
|
use App\Models\Aircraft;
|
2017-12-01 10:28:45 +08:00
|
|
|
use Prettus\Repository\Contracts\CacheableInterface;
|
2018-02-21 12:33:09 +08:00
|
|
|
use Prettus\Repository\Traits\CacheableRepository;
|
2017-06-09 09:37:51 +08:00
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
/**
|
|
|
|
* Class AircraftRepository
|
|
|
|
* @package App\Repositories
|
|
|
|
*/
|
|
|
|
class AircraftRepository extends Repository implements CacheableInterface
|
2017-06-09 09:37:51 +08:00
|
|
|
{
|
2017-12-01 10:28:45 +08:00
|
|
|
use CacheableRepository;
|
|
|
|
|
2017-12-02 00:53:33 +08:00
|
|
|
protected $fieldSearchable = [
|
2018-03-20 09:50:40 +08:00
|
|
|
'name' => 'like',
|
2017-12-02 00:53:33 +08:00
|
|
|
'registration' => 'like',
|
|
|
|
'active',
|
|
|
|
];
|
2017-06-09 09:37:51 +08:00
|
|
|
|
|
|
|
public function model()
|
|
|
|
{
|
|
|
|
return Aircraft::class;
|
|
|
|
}
|
2017-12-02 01:11:03 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the list of aircraft formatted for a select box
|
|
|
|
* @return array
|
|
|
|
*/
|
2017-12-02 01:27:32 +08:00
|
|
|
public function selectBoxList(): array
|
2017-12-02 01:11:03 +08:00
|
|
|
{
|
|
|
|
$retval = [];
|
|
|
|
$items = $this->all();
|
|
|
|
|
|
|
|
foreach ($items as $i) {
|
2018-03-20 09:50:40 +08:00
|
|
|
$retval[$i->id] = $i->subfleet->name.' - '.$i->name.' ('.$i->registration.')';
|
2017-12-02 01:11:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return $retval;
|
|
|
|
}
|
2017-06-09 09:37:51 +08:00
|
|
|
}
|