本文整理汇总了PHP中app\Permission::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::where方法的具体用法?PHP Permission::where怎么用?PHP Permission::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Permission
的用法示例。
在下文中一共展示了Permission::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removePermission
public function removePermission($permission)
{
if (is_string($permission)) {
$permission = Permission::where('name', $permission)->first();
}
return $this->permissions()->detach($permission);
}
示例2: update
public function update($id, $request)
{
if ($this->valid($request->all(), $this->rules($id))) {
$user = $this->findItem($id);
$user->name = $request->input('name');
$pass = $request->input('password');
$user->password = empty($pass) ? $user->password : bcrypt($pass);
$user->email = $request->input('email');
$group_id = $request->input('group_id');
$active = $request->input('active');
$user->active = empty($active) ? 0 : $active;
if ($group_id == '0') {
$user->group_id = -1;
} else {
$user->group_id = $group_id;
$rules = Permission::where('object_id', $group_id)->lists('rule', 'admenu_id')->toArray();
if (!is_null($rules)) {
$user->admenus()->detach();
foreach ($rules as $menu_id => $rule) {
$user->admenus()->attach($menu_id, ['rule' => $rule, 'type' => 'user']);
}
}
}
$user->update();
} else {
throw new ValidationException('valid', $this->getError());
}
}
示例3: postStudent
public function postStudent(StudentRequest $request)
{
$user = new User();
$user->username = $request->txtten;
$user->password = Hash::make($request->txtten);
$user->name = $request->txtten;
$user->save();
$user_id = $user->id;
$permission = Permission::where('slug', 'student')->get()->first();
$permissionUser = new PermissionUser();
$permissionUser->permission_id = $permission->id;
$permissionUser->user_id = $user_id;
$permissionUser->save();
$student = new ThiSinh();
$student->ten = $request->txtten;
$student->gioitinh = $request->sltGt;
$student->namsinh = $request->txtns;
$student->quequan = $request->txtqq;
$student->khuvuc = $request->txtkv;
$student->user_id = $user_id;
$student->save();
$thisinh_id = $student->id;
$point = new Diem();
$point->sbd = $request->txtsbd;
$point->mon1 = 0;
$point->mon2 = 0;
$point->mon3 = 0;
$point->khoi = $request->txtkt;
$point->thisinh_id = $thisinh_id;
$point->save();
return redirect()->route('cluster-staff.quan-ly-thong-tin-thi-sinh.listStudent')->with(['flash_level' => 'success', 'flash_message' => 'Success!!! Complete Add Student']);
}
示例4: permission_edit
public function permission_edit(Request $request)
{
$this->validate($request, array('permission' => 'required', 'permission_name' => 'required'));
//check repeat before operate the database
$error_msg_route = 'This route has already existed!';
$error_msg_route_name = 'This route name has already existed!';
if (!$request->input('id')) {
if (Permission::where('permission', $request->input('permission'))->first()) {
return redirect()->back()->withErrors($error_msg_route);
}
if (Permission::where('permission_name', $request->input('permission_name'))->first()) {
return redirect()->back()->withErrors($error_msg_route_name);
}
$lastInsert = Permission::create($request->all());
PermissionRole::create(array('permission_id' => $lastInsert->id, 'role_id' => 1));
} else {
$self = Permission::find($request->input('id'));
if ($self->permission != $request->input('permission') && Permission::where('permission', $request->input('permission'))->first()) {
return redirect()->back()->withErrors($error_msg_route);
}
if ($self->permission_name != $request->input('permission_name') && Permission::where('permission_name', $request->input('permission_name'))->first()) {
return redirect()->back()->withErrors($error_msg_route_name);
}
Permission::find($request->input('id'))->update($request->all());
}
return redirect()->back();
}
示例5: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// Admin
$admin = User::where(['email' => 'admin@foobarinc.com'])->first();
$adminRole = Role::where(['name' => 'admin'])->first();
$adminPermission = Permission::where(['name' => 'sudo'])->first();
$admin->attachRole($adminRole);
$adminRole->attachPermission($adminPermission);
// PM
$projectManager = User::where(['email' => 'pm@foobarinc.com'])->first();
$projectManagerRole = Role::where(['name' => 'project-manager'])->first();
$projectManagerPermission = Permission::where(['name' => 'listing-budget'])->first();
$projectManager->attachRole($projectManagerRole);
$projectManagerRole->attachPermission($projectManagerPermission);
// Team Leader
$teamLeader = User::where(['email' => 'tl@foobarinc.com'])->first();
$teamLeaderRole = Role::where(['name' => 'team-leader'])->first();
$teamLeaderPermission = Permission::where(['name' => 'make-timeline'])->first();
$teamLeader->attachRole($teamLeaderRole);
$teamLeaderRole->attachPermission($teamLeaderPermission);
// Programmer
$programmer = User::where(['email' => 'pg@foobarinc.com'])->first();
$programmerRole = Role::where(['name' => 'programmer'])->first();
$programmerPermission = Permission::where(['name' => 'knowing-tasks'])->first();
$programmer->attachRole($programmerRole);
$programmerRole->attachPermission($programmerPermission);
}
示例6: getTeamAttribute
public function getTeamAttribute()
{
$permissions = Permission::where('model_name', 'App\\Project')->where('model_id', $this->jobId)->get();
$team = [];
foreach ($permissions as $permission) {
array_push($team, $permission->user->teammate->full_name);
}
return $team;
}
示例7: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!Auth::check()) {
return response('Unauthorized.', 401);
}
if (!Permission::where('route', $this->route->getActionName())->whereIn('roles_id', Auth::user()->role()->lists('id'))->exists()) {
return response('Unauthorized.', 401);
}
return $next($request);
}
示例8: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
//
$q = \Request::get('q');
if ($q != '') {
$permissions = \App\Permission::where('name', 'RLIKE', $q)->paginate(10);
} else {
$permissions = \App\Permission::paginate(10);
}
return view('permissions.index', compact('permissions', 'q'));
}
示例9: getWhere
public static function getWhere($fieldName, $id, $mode)
{
if ($mode == "MODEL_MODE") {
return Permission::where($fieldName, $id);
} else {
if ($mode == "DATA_MODE") {
return Permission::where($fieldName, $id)->get();
} else {
return false;
}
}
}
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $permission)
{
if (Auth::user()->id == 1) {
return $next($request);
}
$idP = Permission::where('ip', $permission)->value('id');
$rol = Auth::user()->rol;
if (!Permissions_assigned::where('role', $rol)->where('permission', $idP)->first()) {
return redirect('auth/logout');
}
return $next($request);
}
示例11: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// su permissoin
$permission_su = Permission::where('name', 'all')->first();
// admin permission
$create_user = Permission::where('name', 'create-user')->first();
$update_user = Permission::where('name', 'update-user')->first();
$drop_user = Permission::where('name', 'drop-user')->first();
$permission_admin = [$create_user, $update_user, $drop_user];
$role_su = Role::where('name', 'su')->first();
$role_su->attachPermission($permission_su);
$role_admin = Role::where('name', 'admin')->first();
$role_admin->attachPermissions($permission_admin);
}
示例12: updatePermissionStatus
/**
* Methods
*/
public static function updatePermissionStatus($user_id, $resource, $actions)
{
$permission = Permission::where('user_id', $user_id)->where('resource', $resource)->first();
if (!$permission) {
$permissionData = array_merge(['user_id' => $user_id, 'resource' => $resource], $actions);
$permission = new Permission($permissionData);
$permission->save();
return true;
}
foreach ($actions as $action => $status) {
$permission->{$action} = $status;
}
$permission->save();
}
示例13: down
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//Delete the rootadmin user
$user = User::where('name', 'admin')->first();
$user->roles()->sync(array());
$user->delete();
//Delete the rootadmin role
$rootadmin = Role::where('name', 'rootadmin')->first();
$rootadmin->perms()->sync(array());
$rootadmin->delete();
//Delete all the permissions
foreach ($this->permissions as $permission) {
$wp_perm = Permission::where('name', $permission['name']);
$wp_perm->delete();
}
}
开发者ID:brucewu16899,项目名称:WebPanel-Core,代码行数:21,代码来源:2015_05_20_000000_webpanel_add_permissions_roles.php
示例14: postTaoTaiKhoanQuanLyNhanVienCum
public function postTaoTaiKhoanQuanLyNhanVienCum(TaiKhoanQuanLyNhanVienCumRequest $request)
{
// thêm vào bảng users
$user = new User();
$user->username = $request->txtUsername;
$user->name = $request->txtName;
$user->password = Hash::make($request->txtPassword);
$user->save();
// thêm vào bảng permission_user
$permission = Permission::where('slug', 'clusterstaffmanager')->get()->first();
$permissionUser = new PermissionUser();
$permissionUser->permission_id = $permission->id;
$permissionUser->user_id = $user->id;
$permissionUser->save();
return redirect()->action('AdminController@getTaoTaiKhoanQuanLyNhanVienCum')->with(['flash_level' => 'success', 'flash_message' => 'Thêm tài khoản thành công!']);
}
示例15: checkPermission
public static function checkPermission()
{
$userInfo = Session::get('user');
$uri = new Permission();
$currentRoute = Route::getFacadeRoot()->current()->uri();
if (Cache::has('user')) {
$user = Cache::get('user');
$permission = $user['permission'];
$ck = in_array($userInfo['role_id'] . '|' . $currentRoute, $permission);
} else {
$ck = $uri->where('name', $userInfo['role_id'] . '|' . $currentRoute)->count();
}
if ($ck > 0 || $userInfo['role_id'] == 1) {
return true;
}
return false;
}