本文整理汇总了PHP中app\models\Role::query方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::query方法的具体用法?PHP Role::query怎么用?PHP Role::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Role
的用法示例。
在下文中一共展示了Role::query方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
public function search($input)
{
$query = Role::query();
$columns = Schema::getColumnListing('roles');
$attributes = array();
foreach ($columns as $attribute) {
$attributes[$attribute] = null;
if (isset($input[$attribute]) and !empty($input[$attribute])) {
$query->where($attribute, $input[$attribute]);
$attributes[$attribute] = $input[$attribute];
}
}
/*
** Filter
*/
$this->filter($input, $query);
/*
** Get count
*/
$total = $query->count();
/*
** Pagination
*/
$this->pagination($input, $query);
/*
** Order
*/
$this->order($input, $query);
return [$query->get(), $attributes, 'total' => $total];
}
示例2: addRole
public static function addRole($name, $label = null, $description = null)
{
$role = Role::query()->where('name', $name)->first();
if (!$role) {
$role = new Role(['name' => $name]);
}
$role->label = $label;
$role->description = $description;
$role->save();
return $role;
}
示例3: search
public function search($input)
{
$query = Role::query();
$columns = Schema::getColumnListing('roles');
$attributes = array();
foreach ($columns as $attribute) {
if (isset($input[$attribute]) and !empty($input[$attribute])) {
$query->where($attribute, $input[$attribute]);
$attributes[$attribute] = $input[$attribute];
} else {
$attributes[$attribute] = null;
}
}
return [$query->get(), $attributes];
}
示例4: index
/**
* Index Layout
*
* @return @Theme View
*/
public function index()
{
Meta::title(Lang::get('meta.role'));
Meta::meta('description', Lang::get('meta.role description'));
$grid = new Grid((new GridConfig())->setDataProvider(new EloquentDataProvider(\App\Models\Role::query()))->setName('grid')->setPageSize(15)->setColumns([(new FieldConfig())->setName('id')->setLabel(Lang::get('label.id'))->setSortable(false)->setSorting(Grid::SORT_ASC), (new FieldConfig())->setName('name')->setLabel(Lang::get('label.name'))->setSortable(true), (new FieldConfig())->setName('description')->setLabel(Lang::get('label.description'))->setSortable(true), (new FieldConfig())->setName('active')->setLabel(Lang::get('label.active'))->setSortable(false)->setCallback(function ($val) {
return '<a href="javascript:active(\'' . $val . '\')"><center><i class="fa ' . ($val ? 'fa-check' : 'fa-close') . '"></i></center></a>';
}), (new FieldConfig())->setName('authorize')->setLabel(Lang::get('label.authorize'))->setSortable(false)->setCallback(function ($val) {
return '<a href="javascript:active(\'' . $val . '\')"><center><i class="fa ' . ($val ? 'fa-check' : 'fa-close') . '"></i></center></a>';
}), (new FieldConfig())->setName('id')->setLabel(Lang::get('menu.edit'))->setSortable(false)->setCallback(function ($val) {
return '
<div class="dropdown">
<button class="btn btn-primary btn-sm dropdown-toggle" type="button" data-toggle="dropdown">
<i class="glyphicon glyphicon-edit"></i>
' . Lang::get('menu.edit') . '
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="' . url('administration/role/form/' . $val) . '"><i class="remove glyphicon glyphicon-edit"></i> ' . Lang::get('menu.edit') . '</a></li>
<li><a href="#" class="delete" id="' . $val . '" ><i class="glyphicon glyphicon-trash"></i> ' . Lang::get('menu.remove') . '</a></li>
</ul>
</div>';
})]));
return Theme::view('roles.index', compact('grid', 'text'));
}