2019-06-21 04:52:37 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Repositories;
|
|
|
|
|
2019-07-16 03:44:31 +08:00
|
|
|
use App\Contracts\Repository;
|
2019-06-21 04:52:37 +08:00
|
|
|
use App\Models\Permission;
|
|
|
|
use Prettus\Repository\Contracts\CacheableInterface;
|
|
|
|
use Prettus\Repository\Traits\CacheableRepository;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class RoleRepository
|
|
|
|
*/
|
|
|
|
class PermissionsRepository extends Repository implements CacheableInterface
|
|
|
|
{
|
|
|
|
use CacheableRepository;
|
|
|
|
|
|
|
|
protected $fieldSearchable = [
|
|
|
|
'name' => 'like',
|
|
|
|
];
|
|
|
|
|
|
|
|
public function model(): string
|
|
|
|
{
|
|
|
|
return Permission::class;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the list of roles formatted for a select box
|
|
|
|
*
|
2019-06-21 11:19:35 +08:00
|
|
|
* @param bool $add_blank
|
2019-06-21 04:52:37 +08:00
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function selectBoxList($add_blank = false): array
|
|
|
|
{
|
|
|
|
$retval = [];
|
|
|
|
$items = $this->all();
|
|
|
|
|
|
|
|
if ($add_blank) {
|
|
|
|
$retval[''] = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($items as $i) {
|
|
|
|
$retval[$i->id] = $i->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $retval;
|
|
|
|
}
|
|
|
|
}
|