Add interface to additional roles/permissions
This commit is contained in:
48
app/Repositories/PermissionsRepository.php
Normal file
48
app/Repositories/PermissionsRepository.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Interfaces\Repository;
|
||||
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
|
||||
*
|
||||
* @param boolean $add_blank
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user