53 lines
1.3 KiB
PHP
Raw Normal View History

2017-09-14 22:21:00 +03:00
<?php
namespace App\Models\Auth;
2020-05-02 14:53:06 +03:00
use App\Traits\Tenants;
2020-10-14 17:07:59 +03:00
use Illuminate\Database\Eloquent\Factories\HasFactory;
2019-11-16 10:21:14 +03:00
use Laratrust\Models\LaratrustRole;
2017-09-14 22:21:00 +03:00
use Laratrust\Traits\LaratrustRoleTrait;
use Kyslik\ColumnSortable\Sortable;
2019-11-16 10:21:14 +03:00
use Lorisleiva\LaravelSearchString\Concerns\SearchString;
2017-09-14 22:21:00 +03:00
class Role extends LaratrustRole
{
2020-10-14 17:07:59 +03:00
use HasFactory, LaratrustRoleTrait, SearchString, Sortable, Tenants;
2019-11-16 10:21:14 +03:00
2017-09-14 22:21:00 +03:00
protected $table = 'roles';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['name', 'display_name', 'description'];
/**
* Scope to get all rows filtered, sorted and paginated.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param $sort
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeCollect($query, $sort = 'display_name')
{
$request = request();
2019-11-16 10:21:14 +03:00
$search = $request->get('search');
$limit = (int) $request->get('limit', setting('default.list_limit', '25'));
2017-09-14 22:21:00 +03:00
2019-11-16 10:21:14 +03:00
return $query->usingSearchString($search)->sortable($sort)->paginate($limit);
2017-09-14 22:21:00 +03:00
}
2020-10-14 17:07:59 +03:00
/**
* Create a new factory instance for the model.
*
* @return \Illuminate\Database\Eloquent\Factories\Factory
*/
protected static function newFactory()
{
return \Database\Factories\Role::new();
}
2017-09-14 22:21:00 +03:00
}