phpvms/app/Repositories/AirlineRepository.php

55 lines
1.0 KiB
PHP
Raw Normal View History

2017-06-09 09:02:52 +08:00
<?php
namespace App\Repositories;
use App\Contracts\Repository;
2017-06-20 00:50:25 +08:00
use App\Models\Airline;
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
/**
* @mixin \App\Models\Airline
*/
class AirlineRepository extends Repository implements CacheableInterface
2017-06-09 09:02:52 +08:00
{
use CacheableRepository;
2017-06-09 09:02:52 +08:00
protected $fieldSearchable = [
'code',
'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
}
/**
* Return the list of airline formatted for a select box
2018-08-27 00:40:04 +08:00
*
* @param bool $add_blank
* @param bool $only_active
2018-08-27 00:40:04 +08:00
*
* @return array
*/
public function selectBoxList($add_blank = false, $only_active = true): array
{
$retval = [];
$where = [
'active' => $only_active,
];
$items = $this->findWhere($where);
if ($add_blank) {
$retval[''] = '';
}
foreach ($items as $i) {
$retval[$i->id] = $i->name;
}
return $retval;
}
2017-06-09 09:02:52 +08:00
}