2017-06-09 09:02:52 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Repositories;
|
|
|
|
|
2017-06-20 00:50:25 +08:00
|
|
|
use App\Models\Airline;
|
2018-02-02 06:46:37 +08:00
|
|
|
use Prettus\Repository\Traits\CacheableRepository;
|
2017-12-01 10:28:45 +08:00
|
|
|
use Prettus\Repository\Contracts\CacheableInterface;
|
2017-06-09 09:02:52 +08:00
|
|
|
|
2017-12-01 10:28:45 +08:00
|
|
|
|
|
|
|
class AirlineRepository extends BaseRepository implements CacheableInterface
|
2017-06-09 09:02:52 +08:00
|
|
|
{
|
2017-12-01 10:28:45 +08:00
|
|
|
use CacheableRepository;
|
|
|
|
|
2017-06-09 09:02:52 +08:00
|
|
|
protected $fieldSearchable = [
|
|
|
|
'code',
|
2017-12-02 00:53:33 +08:00
|
|
|
'name' => 'like',
|
2017-06-09 09:02:52 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
public function model()
|
|
|
|
{
|
2017-06-20 00:50:25 +08:00
|
|
|
return Airline::class;
|
2017-06-09 09:02:52 +08:00
|
|
|
}
|
2017-12-02 01:11:03 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the list of airline formatted for a select box
|
|
|
|
* @return array
|
|
|
|
*/
|
2017-12-05 02:05:31 +08:00
|
|
|
public function selectBoxList($add_blank=false): array
|
2017-12-02 01:11:03 +08:00
|
|
|
{
|
|
|
|
$retval = [];
|
|
|
|
$items = $this->all();
|
|
|
|
|
2017-12-05 02:05:31 +08:00
|
|
|
if($add_blank) {
|
2018-01-24 05:48:30 +08:00
|
|
|
$retval[''] = '';
|
2017-12-05 02:05:31 +08:00
|
|
|
}
|
|
|
|
|
2017-12-02 01:11:03 +08:00
|
|
|
foreach ($items as $i) {
|
|
|
|
$retval[$i->id] = $i->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $retval;
|
|
|
|
}
|
2017-06-09 09:02:52 +08:00
|
|
|
}
|