本文整理汇总了PHP中app\models\Role::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::orderBy方法的具体用法?PHP Role::orderBy怎么用?PHP Role::orderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Role
的用法示例。
在下文中一共展示了Role::orderBy方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testStore
public function testStore()
{
$this->withSession(['SOURCE_URL' => URL::route('role.create')]);
$this->withoutMiddleware();
$this->call('POST', '/role', $this->systemRoleWorks);
$role = Role::orderBy('id', 'desc')->first();
$this->assertEquals($this->systemRoleWorks['name'], $role->name);
$this->call('POST', '/role', $this->systemRoleFailsValidationNoName);
// todo: the test environment has source route '/' on failure redirect->back() -> the test below wont do
// $this->assertRedirectedToRoute('role.create');
// todo: this is the best I can do for now
// $this->assertSessionHasErrors('name');
$this->assertSessionHasErrors();
$this->call('POST', '/role', $this->systemRoleFailsValidationSameRole);
// todo: redirect is failing for some reason
// todo: the test environment has source route '/' on failure redirect->back() -> the test below wont do
// $this->assertRedirectedToRoute('role.create');
// todo: this is the best I can do for now
// $this->assertSessionHasErrors('name');
$this->assertSessionHasErrors();
$this->call('POST', '/role', $this->systemRoleFailsValidationShortRole);
$this->assertRedirectedToRoute('role.create');
// todo: this is the best I can do for now
// $this->assertSessionHasErrors('name');
$this->assertSessionHasErrors();
}
示例2: getAllRoles
/**
* @param string $order_by
* @param string $sort
* @param bool $withPermissions
* @return mixed
*/
public function getAllRoles($order_by = 'id', $sort = 'asc', $withPermissions = false)
{
if ($withPermissions) {
return Role::with('permissions')->orderBy($order_by, $sort)->get();
}
return Role::orderBy($order_by, $sort)->get();
}
示例3: lastUpdated
public function lastUpdated()
{
$query = Role::orderBy('updated_at', 'DESC')->first();
if ($query) {
return $query->updated_at->format('Y-m-d H:i:s');
}
return date("Y-m-d H:i:s");
}
示例4: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$roles = Role::orderBy('created_at', 'DESC')->paginate(10);
return view('backend.role.index', compact('roles'));
}
示例5: edit
/**
* Show the form for editing the specified resource.
*
* @param User $user
* @return \Illuminate\View\View
*/
public function edit(User $user)
{
$roles = Role::orderBy('id', 'asc')->get();
return view('admin.user.edit', ['user' => $user, 'roles' => $roles]);
}
示例6: groups_roles
public function groups_roles()
{
$data['title'] = "Associate Roles to Groups";
$data['groups'] = Group::orderBy('display_name')->paginate(PAGINATION);
$data['roles'] = Role::orderBy('display_name')->get();
return view('groups/groups_roles', $data);
}
示例7: edit
/**
* Show the form for editing the specified resource.
*
* @param User $user
* @return \Illuminate\View\View
*/
public function edit(User $user)
{
$roles = Role::orderBy('id', 'asc')->get();
$page = $_SERVER['HTTP_REFERER'];
return view('admin.user.edit', ['user' => $user, 'roles' => $roles])->with('page', $page);
}
示例8: getAllOrderedBy
public function getAllOrderedBy($column = 'id', $order = 'asc')
{
$roles = Role::orderBy($column, $order)->get();
return $roles;
}