2017-06-09 09:02:52 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Repositories;
|
|
|
|
|
2019-07-16 03:44:31 +08:00
|
|
|
use App\Contracts\Repository;
|
2017-06-20 00:50:25 +08:00
|
|
|
use App\Models\Airline;
|
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:02:52 +08:00
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
class AirlineRepository extends Repository 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
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
|
|
|
* @param mixed $add_blank
|
|
|
|
*
|
2017-12-02 01:11:03 +08:00
|
|
|
* @return array
|
|
|
|
*/
|
2018-03-20 09:50:40 +08:00
|
|
|
public function selectBoxList($add_blank = false): array
|
2017-12-02 01:11:03 +08:00
|
|
|
{
|
|
|
|
$retval = [];
|
|
|
|
$items = $this->all();
|
|
|
|
|
2018-03-20 09:50:40 +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
|
|
|
}
|