本文整理汇总了PHP中app\models\Role::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::select方法的具体用法?PHP Role::select怎么用?PHP Role::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Role
的用法示例。
在下文中一共展示了Role::select方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: all
public function all($params)
{
$params['order'] = isset($params['order']) ? $params['order'] : ['display_name|ASC'];
$roles = Role::select("roles.*");
$roles = parent::execute($roles, $params);
return $roles;
}
示例2: create
public function create()
{
$roles = Role::select('id', 'role_name')->get();
$roles = $this->toOptionArray($roles);
//dd($roles);
return view($this->view_path . 'create', compact('roles', 'data'));
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$role = Role::select('id')->where('name', '=', 'admin')->first();
$user = User::create(['name' => 'Administrador', 'lastname' => 'Administrador', 'email' => 'admin@admin.com', 'password' => bcrypt('admin'), 'dni' => '34785999', 'state_id' => '12', 'city_id' => '228', 'role_id' => $role->id, 'active' => '1']);
$role = Role::select('id')->where('name', '=', 'user')->first();
$user = User::create(['name' => 'User', 'lastname' => 'User', 'email' => 'user@user.com', 'password' => bcrypt('123456'), 'dni' => '34785998', 'state_id' => '12', 'city_id' => '228', 'role_id' => $role->id, 'active' => '1']);
}
示例4: update
public static function update(UserRequest $request, $id)
{
$user = User::find($id);
if (!$user) {
return redirect()->back()->withErrors('No se encontro el usuario solicitado');
}
$role = Role::select('name', 'id')->where('id', '=', $request->input('role_id'))->first();
if ($role->name == 'Admin') {
//Admin
$user->role_id = $role->id;
} else {
//Client
$client = Role::select('id')->where('name', '=', 'User')->first();
//$token = str_random(32);
$user->role_id = $client->id;
//$user->active = 0;
}
if (!$request->has('active')) {
//check checkbox :D
$user->active = 0;
} else {
$user->active = $request->input('active');
}
$user->password = Hash::make($request->input('password'));
$user->name = $request->input('name');
$user->lastname = $request->input('lastname');
$user->email = $request->input('email');
$user->dni = $request->input('dni');
$user->state_id = $request->input('state_id');
$user->city_id = $request->input('city_id');
$user->save();
return redirect()->route('users.index')->with('success', 'El usuario se ha modificado correctamente');
}
示例5: onDelete
/**
* Function Remove
* Process Delete the Brand Data
*
* @return \Illuminate\Http\JsonResponse
*/
public function onDelete()
{
$id = Input::get('id');
$Model = \App\Models\Role::select(['id'])->where('id', $id)->first();
if ($Model) {
\App\Models\Role::where('id', $id)->delete();
$param['message'] = Lang::get('info.has deleted');
$param['error'] = false;
} else {
$param['message'] = Lang::get('info.has error');
$param['error'] = true;
}
return json_encode($param);
}