本文整理汇总了PHP中app\Role::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::find方法的具体用法?PHP Role::find怎么用?PHP Role::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Role
的用法示例。
在下文中一共展示了Role::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
*
* @return Response
*/
public function edit($id)
{
$role = Role::findOrFail($id);
$permission_role = Role::find($id)->permissions()->lists('permission_id')->toArray();
$permissions = Permission::lists('display_name', 'id');
return view('admin.roles.edit', compact('role', 'permissions', 'permission_role'));
}
示例2: save
public function save(Request $request)
{
$input = $request->all();
// $field_name = implode('|',$input['website']['locales']);
$company = new Company();
$company->name = $input['client']['company_name'];
$company->alias = $input['website']['sub_name'];
$company->save();
$user = new User();
$user->name = $input['client']['name'];
$user->email = $input['client']['email'];
$user->password = $input['client']['password'];
$user->ip = '*';
$user->branch_id = 1;
$user->company_id = $company->id;
$user->active = 1;
$user->save();
$user->roles()->attach(Role::find(1)->id);
// $gr_fields = new GrFields;
// $gr_fields->field_name = $field_name;
// $gr_fields->company_id = $company->id;
// $gr_fields->save();
session(['input' => $input]);
return redirect('thanks');
}
示例3: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$usuario = User::find($id);
$role = Role::all();
$rol = Role::find($id);
return view('users/show')->with('usuario', $usuario)->with('role', $role)->with('rol', $rol);
}
示例4: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$role = Role::find($id);
$role->name = Input::get('name');
$role->save();
return Redirect::route('template.role.index');
}
示例5: postSearch
public function postSearch(Request $request)
{
if (!$request->name and !$request->email) {
$models = User::paginate(10);
}
if ($request->name) {
$models = User::where('name', 'like', '%' . $request->name . '%')->paginate(10);
}
if ($request->email) {
$models = User::where('email', 'like', '%' . $request->email . '%')->paginate(10);
}
if ($request->name and $request->email) {
$models = User::where('name', 'like', '%' . $request->name . '%')->where('email', 'like', '%' . $request->email . '%')->paginate(10);
}
if ($request->role_list) {
$models = Role::find($request->role_list)->users()->paginate(10);
}
if ($request->role_list and $request->name) {
$models = Role::find($request->role_list)->users()->where('name', 'like', '%' . $request->name . '%')->paginate(10);
}
if ($request->role_list and $request->email) {
$models = Role::find($request->role_list)->users()->where('email', 'like', '%' . $request->email . '%')->paginate(10);
}
if ($request->role_list and $request->email and $request->name) {
$models = Role::find($request->role_list)->users()->where('name', 'like', '%' . $request->name . '%')->where('email', 'like', '%' . $request->email . '%')->paginate(10);
}
$model = new User();
$model->name = $request->name;
$model->email = $request->email;
$model->role_list = $request->role_list;
$roles = Role::lists('name', 'id');
$roles[''] = 'нет';
return view('admin.user.index', compact('models', 'model', 'roles'));
}
示例6: run
public function run()
{
$this->command->info('Seeding permission to role associations.');
$permissions = Permission::get()->modelKeys();
// Insert default permissions.
foreach ($this->slugs() as $role_id => $slugs) {
foreach ($slugs as $slug_key => $slug_value) {
if (!is_numeric($slug_key) && (is_numeric($slug_value) || is_bool($slug_value))) {
$permission_id = $slug_key;
$permission_value = !!$slug_value;
} else {
$permission_id = $slug_value;
$permission_value = true;
}
if (in_array($permission_id, $permissions)) {
} else {
$this->command->error("Attempting to assign non-existant permission id `{$permission_id}` to role_id `{$role_id}`.");
}
}
}
// Give admin permissions.
if (count($permissions)) {
$role = Role::find(Role::ID_ADMIN);
$role->permissions()->detach();
$attachments = [];
foreach ($permissions as $permission_id) {
$attachments[] = ['permission_id' => $permission_id, 'value' => 1];
}
$role->permissions()->attach($attachments);
}
}
示例7: validateMerchantOtp
public function validateMerchantOtp(request $request)
{
$apiKey = $request->only('api_key');
$validator = Validator::make($apiKey, ['api_key' => 'required']);
if ($validator->fails()) {
$response = response()->json(['response_code' => 'ERR_IAK', 'messages' => 'Invalid Api Key'], 403);
return $response;
}
$role = Role::find(2);
$key = Config::get('custom.JWTkey');
$decoded = JWT::decode($apiKey['api_key'], $key, array('HS256'));
if ($decoded->type != 'merchant') {
return $response = response()->json(['response_code' => 'ERR_IAK', 'messages' => 'Invalid Api Key'], 403);
}
$user = User::find($decoded->sub);
// check the current user
if (empty($user) || !$user->hasRole(['merchant']) || !$user->status) {
return $response = response()->json(['response_code' => 'ERR_IAK', 'messages' => 'Invalid Api Key'], 403);
}
$user_id = $user->id;
$input = $request->only('otp');
$matchThese = ['user_id' => $user_id, 'code' => $input['otp']];
$sms = UserSmsCode::where($matchThese)->first();
if ($sms == '' || empty($sms)) {
return response()->json(['response_code' => 'RES_IOG', 'messages' => 'Invalid OTP Given'], 422);
}
$sms->status = true;
$sms->save();
$user->is_mobile_verified = true;
$user->save();
return response()->json(['response_code' => 'RES_MV', 'messages' => 'Mobile Verified']);
}
示例8: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$permissions = Permission::all();
$role = Role::find($id);
$permission_role = $role->r_permission;
return View('role.edit', compact('role', 'permissions', 'permission_role'));
}
示例9: desasignar
public function desasignar()
{
$rol = Role::find(Input::get('role_id'));
$rolPermisos = RolesPermission::where('role_id', '=', Input::get('role_id'))->where('permission_id', '=', Input::get('permission_id'))->get()->first();
$desasignar = RolesPermission::destroy($rolPermisos->id);
return Response::json('ok');
}
示例10: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
// Validate the forum
$this->validate($request, ['name' => 'required|unique:forums|max:255', 'description' => 'required']);
// Create a new Forum
$forum = new Forum();
$forum->name = $request->name;
$forum->slug = str_slug($request->name, '-');
$forum->description = $request->description;
if ($forum->save()) {
// Grant the admin access to the forum
$admin = Role::find(1);
// Admin should be created when built, shouldn't be an issue
$accessForum = new Permission();
$accessForum->name = 'access-forum-' . $forum->id;
$accessForum->display_name = 'Access ' . $forum->name;
// optional
$accessForum->description = 'Ability to access and post in ' . $forum->name;
// optional
$accessForum->save();
$admin->attachPermission($accessForum);
Session::flash('alert-success', 'Forum created.');
} else {
Session::flash('alert-error', 'Could not create forum.');
}
return redirect('dashboard');
}
示例11: getDelete
public function getDelete($role_id)
{
$role = Role::find($role_id);
$user_role_name = User::getUserRoleName();
$users = User::getUsersFromRoleId($role_id);
return view('admin.roles.delete', compact('role'))->with(compact('user_role_name'))->with('related_users_count', $users->count());
}
示例12: addPermissionToGroup
public function addPermissionToGroup(Request $request)
{
$permission = Permission::find($request->permission_id);
$role = Role::find($request->role_id);
$role->attachPermission($permission);
Session::flash('alert-success', 'Permission Granted');
return back();
}
示例13: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker\Factory::create();
// Add dev account until we enable registration
$newUser = App\User::create(['name_first' => "Developer", 'name_last' => "EditMe", "affiliation_id" => 1, "email" => "developer@codeforcharlotte.org", 'password' => Hash::make('admin'), 'nomination_limit' => 5, 'active' => 'Y']);
$role = \App\Role::find(1);
$newUser->attachRole($role);
}
示例14: create
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
//dd($permissions);
$role = Role::find(4);
$user = User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
$user->roles()->attach($role);
return $user;
}
示例15: update
public function update(Request $request, $id)
{
$name = Input::get('e_name');
$role = Role::find($id);
$role->nombre = $name;
$role->save();
return Redirect::route('roles.index');
}