本文整理汇总了PHP中app\models\Permission::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::where方法的具体用法?PHP Permission::where怎么用?PHP Permission::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Permission
的用法示例。
在下文中一共展示了Permission::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forcePermission
/**
*
* Force the role to have the given permission.
*
* @param $permissionName
*/
public function forcePermission($permissionName)
{
// If the role has not been given a the said permission
if (null == $this->perms()->where('name', $permissionName)->first()) {
// Load the given permission and attach it to the role.
$permToForce = Permission::where('name', $permissionName)->first();
$this->perms()->attach($permToForce->id);
}
}
示例2: composeAllPermissions
/**
* compose permissions variable.
*/
private function composeAllPermissions()
{
View::composer(['manage.role.show'], function ($view) {
$groups = Permission::distinct()->lists('group');
foreach ($groups as $group) {
$permission_groups[$group] = Permission::where('group', $group)->get();
}
$view->with(['permission_groups' => $permission_groups]);
});
}
示例3: addPermission
public static function addPermission($name, $label = null, $description = null)
{
$permission = Permission::where('name', $name)->first();
if (!$permission) {
$permission = new Permission(['name' => $name]);
}
$permission->label = $label;
$permission->description = $description;
$permission->save();
return $permission;
}
示例4: addMenuAction
public function addMenuAction(Request $request)
{
if ($request->action == 'update') {
try {
$fun = Permission::where('id', $request->col0)->update(['name' => $request->col1, 'display_name' => $request->col2, 'description' => $request->col3, 'link' => $request->col4, 'parent' => $request->col5, 'icon' => $request->col6]);
Log::info($fun);
if ($fun) {
return response(array('sukses bisa bro!!', $request->all()), 200)->header('Content-Type', 'application/json');
} else {
return response('There is no data changes!!', 400)->header('Content-Type', 'application/json');
}
} catch (PDOException $exception) {
Log::info($exception->getMessage());
return response('Proses Gagal!!', 400)->header('Content-Type', 'application/json');
}
}
if ($request->action == 'insert') {
try {
$fun = new Permission();
$fun->name = $request->col1;
$fun->display_name = $request->col2;
$fun->description = $request->col3;
$fun->link = $request->col4;
$fun->parent = $request->col5;
$fun->icon = $request->col6;
if ($fun->save()) {
$request->merge(array('col0' => $fun->id));
return response(array('sukses bisa bro!!', $request->all()), 200)->header('Content-Type', 'application/json');
} else {
return response('There is no data changes!!', 400)->header('Content-Type', 'application/json');
}
} catch (PDOException $exception) {
Log::info($exception->getMessage());
return response('Proses Gagal!!', 400)->header('Content-Type', 'application/json');
}
}
if ($request->action == 'delete') {
try {
$fun = Permission::where('ID', $request->col0);
if ($fun->delete()) {
return response(array('sukses bisa bro!!', $request->all()), 200)->header('Content-Type', 'application/json');
} else {
return response('There is no data changes!!', 400)->header('Content-Type', 'application/json');
}
} catch (PDOException $exception) {
Log::info($exception->getMessage());
return response('Proses Gagal!!', 400)->header('Content-Type', 'application/json');
}
}
//return response(array('sukses bisa bro!!'), 200)
return response('Proses Gagal!!', 400)->header('Content-Type', 'application/json');
}
示例5: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store($user, Request $request)
{
$uperms = Permission::where('user_id', '=', $user)->delete();
$perms = $request->except('_token');
foreach ($perms as $kk => $perm) {
if (substr($kk, 0, 3) != "new") {
$soc = substr($kk, 0, strpos($kk, '_'));
$key = substr($kk, 1 + strpos($kk, '_'));
$data[$soc][$key] = $perm;
}
}
if (isset($data)) {
foreach ($data as $ss => $dat) {
$newp = new Permission();
$newp->society_id = $ss;
$newp->user_id = $user;
foreach ($dat as $kkk => $vvv) {
$newp->{$kkk} = $vvv;
}
$newp->save();
}
}
if ($request->new_society != 0) {
$news = new Permission();
$news->society_id = $request->new_society;
$news->user_id = $user;
if (isset($request->new_admin)) {
$news->admin = $request->new_admin;
}
if (isset($request->new_email)) {
$news->email = $request->new_email;
}
if (isset($request->new_sms)) {
$news->sms = $request->new_sms;
}
if (isset($request->new_edit)) {
$news->edit = $request->new_edit;
}
if (isset($request->new_preaching)) {
$news->preaching = $request->new_preaching;
}
if (isset($request->new_view)) {
$news->view = $request->new_view;
}
if (isset($request->new_worship)) {
$news->worship = $request->new_worship;
}
$news->save();
}
return redirect()->route('users.permissions.index', $user);
}
示例6: deleteRolesPermissions
public function deleteRolesPermissions()
{
$role = Role::where('name', 'master')->first();
if ($role) {
$role->delete();
}
$permission = Permission::where('name', 'user-create')->first();
$permission->delete();
$permission = Permission::where('name', 'user-edit')->first();
$permission->delete();
$permission = Permission::where('name', 'user-delete')->first();
$permission->delete();
// $role->forceDelete();
return redirect()->route('access.test');
}
示例7: welcome
public function welcome()
{
if (!Schema::hasTable('settings')) {
$data['firsttime'] = "yes";
return view('firsttime', $data)->with('okmessage', 'Please create a user before you can use Connexion');
}
$user = Auth::user();
if ($user and $user->individual_id) {
$today = date('d-m-Y');
$data['tasks'] = Task::where('donedate', '=', '')->where('project_id', '<>', 0)->where('individual_id', $user->individual_id)->orderBy('duedate')->get();
$data['personal'] = Task::where('donedate', '=', '')->where('project_id', '=', 0)->where('individual_id', $user->individual_id)->orderBy('duedate')->get();
$data['individuals'] = Individual::orderBy('surname')->get();
$data['projects'] = Project::with('undonetask')->where('individual_id', $user->individual_id)->orderBy('project')->get();
$data['projectselect'] = Project::orderBy('project')->lists('project', 'id');
$data['page_title'] = Helpers::getSetting('circuit_name') . " Circuit";
$data['page_description'] = "Administrator home page";
$socs = Permission::where('user_id', '=', $user->id)->select('society_id')->get();
foreach ($socs as $soc) {
$thissoc = Society::where('id', '=', $soc->society_id)->get();
$dum['googleCalendarId'] = $thissoc[0]->society_calendar;
$dum['color'] = $thissoc[0]->calendar_colour;
$data['cals'][] = $dum;
}
$dum['googleCalendarId'] = Helpers::getSetting('circuit_calendar');
$dum['color'] = 'black';
$data['cals'][] = $dum;
if (Helpers::is_online() and $user->googlecalendar != "") {
$privatecal = new GoogleCalendar();
$pcals = $privatecal->getTen($user->googlecalendar);
foreach ($pcals as $pcal) {
$pcal['color'] = $user->calendar_colour;
$data['pcals'][] = $pcal;
}
} else {
$data['pcals'] = array();
}
if (!count($socs)) {
$soc = strtolower($user->individual->household->society->society);
return redirect()->action('SocietiesController@show', $soc);
} else {
return view('home', $data);
}
} elseif ($user) {
return view('shared.registered');
} else {
return view('landingwebpage');
}
}
示例8: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Role::create(['name' => 'Admin', 'display_name' => '超级管理员']);
Role::create(['name' => 'Editor', 'display_name' => '编辑']);
Role::create(['name' => 'Demo', 'display_name' => '演示']);
Role::get()->each(function ($role) {
if ($role->name === 'Admin') {
$permissions = Permission::get()->pluck('id')->all();
$role->perms()->sync($permissions);
}
if ($role->name === 'Editor') {
$permissions = Permission::where('name', 'manage_contents')->first();
$role->perms()->sync([$permissions->id]);
}
});
}
示例9: search
public function search()
{
$input = Input::all();
$data['q'] = $input['q'];
$perms = array_flatten(Permission::where('user_id', '=', Auth::user()->id)->select('society_id')->get()->toArray());
$individuals = Individual::where('surname', 'like', '%' . $input['q'] . '%')->orWhere('firstname', 'like', '%' . $input['q'] . '%')->whereNull('deleted_at')->orderBy('surname')->get();
foreach ($individuals as $indiv) {
if ($indiv->household) {
if (in_array($indiv->household->society_id, $perms)) {
$ids[] = $indiv->id;
}
}
}
$data['individuals'] = Individual::wherein('id', $ids)->get();
$data['groups'] = Group::where('groupname', 'like', '%' . $input['q'] . '%')->whereIn('society_id', $perms)->whereNull('deleted_at')->get();
$data['projects'] = Project::where('project', 'like', '%' . $input['q'] . '%')->whereNull('deleted_at')->get();
return view('home', $data);
}
示例10: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('roles')->delete();
/**
* Role Attributes
*
* name: Unique name for the permission, used for looking up permission information in the
* application layer. For example: "create-post", "edit-user", "post-payment", "mailing-list-subscribe".
*
* display_name: Human readable name for the permission. Not necessarily unique, and is optional.
* For example "Create Posts", "Edit Users", "Post Payments", "Subscribe to mailing list".
*
* description: A more detailed explanation of the Role. This is also optional.
*
* permissions: A list of permission names to assign to the user. Optional.
*/
$roles = array(array('name' => 'owner', 'display_name' => 'Owner', 'description' => 'Owner of the management system. Has access to all aspects of the system.', 'permissions' => PermissionNames::AllGlobalPermissions()));
foreach ($roles as $r) {
$entry = new Role();
$entry->name = $r['name'];
if (array_key_exists('permissions', $r)) {
$permissions = $r['permissions'];
unset($r['permissions']);
}
if (array_key_exists('display_name', $r)) {
$entry->display_name = $r['display_name'];
}
if (array_key_exists('description', $r)) {
$entry->description = $r['description'];
}
$entry->save();
if (isset($permissions)) {
foreach ($permissions as $p) {
$entry->attachPermission(Permission::where('name', $p)->get()->first());
}
unset($permissions);
}
}
$rolePermissions = Permission::whereIn('name', PermissionNames::AllGlobalPermissions())->get();
RoleCreate::createPermissionRoles($rolePermissions);
}
示例11: composeMessage
public function composeMessage($society, $type)
{
$today = date('d-m-Y');
$data['society'] = $society;
$soc = Society::find($society);
if ($type == "sms") {
$username = $soc->sms_username;
$pword = $soc->sms_password;
if ($soc->sms_provider == "bulksms") {
if (Helpers::is_online()) {
$data['credits'] = SMSfunctions::BS_get_credits($username, $pword);
} else {
$data['credits'] = "Bulk SMS is offline";
}
} elseif ($soc->sms_provider == "smsfactory") {
if (Helpers::is_online()) {
$data['credits'] = intval(SMSfunctions::SF_checkCredits($username, $pword));
} else {
$data['credits'] = "Bulk SMS is offline";
}
} else {
$data['credits'] = "SMS credentials are not set up yet";
}
$data['perms'] = Permission::where('user_id', '=', Auth::user()->id)->where('sms', '=', 1)->select('society_id')->get()->toArray();
} else {
$data['perms'] = Permission::where('user_id', '=', Auth::user()->id)->where('email', '=', 1)->select('society_id')->get()->toArray();
}
foreach ($data['perms'] as $perm) {
$psoc[] = $perm['society_id'];
}
$data['indivs'] = Individual::orderBy('surname')->orderBy('firstname')->get();
$data['groups'] = Group::with('individual')->wherein('society_id', $psoc)->orderBy('groupname')->get();
$view = "messages." . $type;
if ($type == "sms" and (Helpers::perm('admin', $society) or Helpers::perm('sms', $society))) {
return view('messages.sms', $data);
} elseif ($type == "email" and (Helpers::perm('admin', $society) or Helpers::perm('email', $society))) {
return view('messages.email', $data);
} else {
return view('shared.unauthorised');
}
}
示例12: destroyRbacRules
public function destroyRbacRules()
{
$permissions = $this->getPermissionsArray();
$members = GroupMember::where('group_id', '=', $this->id)->get();
$roles = Role::where('name', '=', "group_{$this->id}_owner")->orWhere('name', '=', "group_{$this->id}_editor")->orWhere('name', '=', "group_{$this->id}_staff")->get();
foreach ($roles as $role) {
foreach ($members as $member) {
$user = User::where('id', '=', $member->user_id)->first();
$user->detachRole($role);
}
if ($role instanceof Role) {
$role->delete();
}
}
foreach ($permissions as $permData) {
$perm = Permission::where('name', '=', $permData['name'])->first();
if ($perm instanceof Permission) {
$perm->delete();
}
}
}
示例13: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// TODO: Remove this before release...
// Look for and delete route named 'do-not-pre-load' if it exist.
// That route is used to test a failure with the Authorization middleware and should not be loaded automatically.
$routeToDelete = Route::where('name', 'test-acl.do-not-pre-load')->get()->first();
if ($routeToDelete) {
Route::destroy($routeToDelete->id);
}
$testUserOne = User::create(['username' => 'user1', 'first_name' => 'User', 'last_name' => 'One', 'email' => 'user1@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
$testUserTwo = User::create(['username' => 'user2', 'first_name' => 'User', 'last_name' => 'Two', 'email' => 'user2@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
$testUserThree = User::create(['username' => 'user3', 'first_name' => 'User', 'last_name' => 'Three', 'email' => 'user3@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
$testUserFour = User::create(['username' => 'user4', 'first_name' => 'User', 'last_name' => 'Four', 'email' => 'user4@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
$testUserFive = User::create(['username' => 'user5', 'first_name' => 'User', 'last_name' => 'Five', 'email' => 'user5@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
$testUserSix = User::create(['username' => 'user6', 'first_name' => 'User', 'last_name' => 'Six', 'email' => 'user6@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
$testUserSeven = User::create(['username' => 'user7', 'first_name' => 'User', 'last_name' => 'Seven', 'email' => 'user7@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
$testUserEight = User::create(['username' => 'user8', 'first_name' => 'User', 'last_name' => 'Eight', 'email' => 'user8@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
$testUserNine = User::create(['username' => 'user9', 'first_name' => 'User', 'last_name' => 'Nine', 'email' => 'user9@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
$testUserTen = User::create(['username' => 'user10', 'first_name' => 'User', 'last_name' => 'Ten', 'email' => 'user10@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
$testUserEleven = User::create(['username' => 'user11', 'first_name' => 'User', 'last_name' => 'Eleven', 'email' => 'user11@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
$testUserTwelve = User::create(['username' => 'user12', 'first_name' => 'User', 'last_name' => 'Twelve', 'email' => 'user12@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
$testUserThirteen = User::create(['username' => 'user13', 'first_name' => 'User', 'last_name' => 'Thirteen', 'email' => 'user13@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
$testUserFourteen = User::create(['username' => 'user14', 'first_name' => 'User', 'last_name' => 'Fourteen', 'email' => 'user14@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
$testUserFifteen = User::create(['username' => 'user15', 'first_name' => 'User', 'last_name' => 'Fifteen', 'email' => 'user15@email.com', "password" => "Password1", "auth_type" => "internal", "enabled" => true]);
/////////
// Create a few test permissions for the flash-test pages.
$permTestLevelSuccess = Permission::create(['name' => 'test-level-success', 'display_name' => 'Test level success', 'description' => 'Testing level success', 'enabled' => true]);
$permTestLevelInfo = Permission::create(['name' => 'test-level-info', 'display_name' => 'Test level info', 'description' => 'Testing level info', 'enabled' => true]);
$permTestLevelWarning = Permission::create(['name' => 'test-level-warning', 'display_name' => 'Test level warning', 'description' => 'Testing level warning', 'enabled' => true]);
$permTestLevelError = Permission::create(['name' => 'test-level-error', 'display_name' => 'Test level error', 'description' => 'Testing level error', 'enabled' => true]);
////////////////////////////////////
// Create some roles for the flash test pages.
////////////////////////////////////
// Success
$roleFlashSuccessViewer = Role::create(["name" => "flash-success-viewer", "display_name" => "Flash success viewer", "description" => "Can see the success flash test page.", "enabled" => true]);
// Assign permission TestLevelSuccess
$roleFlashSuccessViewer->perms()->attach($permTestLevelSuccess->id);
// Assign user membership to role
$roleFlashSuccessViewer->users()->attach($testUserTwo->id);
// Info
$roleFlashInfoViewer = Role::create(["name" => "flash-info-viewer", "display_name" => "Flash info viewer", "description" => "Can see the info flash test page.", "enabled" => true]);
// Assign permission Info and Success to the InfoViewer role.
$roleFlashInfoViewer->perms()->attach($permTestLevelInfo->id);
$roleFlashInfoViewer->perms()->attach($permTestLevelSuccess->id);
// Assign user membership to role
$roleFlashInfoViewer->users()->attach($testUserThree->id);
// Warning
$roleFlashWarningViewer = Role::create(["name" => "flash-warning-viewer", "display_name" => "Flash warning viewer", "description" => "Can see the warning flash test page.", "enabled" => true]);
// Assign permission Warning, Info and Success to the WarningViewer role.
$roleFlashWarningViewer->perms()->attach($permTestLevelWarning->id);
$roleFlashWarningViewer->perms()->attach($permTestLevelInfo->id);
$roleFlashWarningViewer->perms()->attach($permTestLevelSuccess->id);
// Assign user membership to role
$roleFlashWarningViewer->users()->attach($testUserFour->id);
// Error
$roleFlashErrorViewer = Role::create(["name" => "flash-error-viewer", "display_name" => "Flash error viewer", "description" => "Can see the error flash test page.", "enabled" => true]);
// Assign permission Error, Warning, Info and Success to the ErrorViewer role.
$roleFlashErrorViewer->perms()->attach($permTestLevelError->id);
$roleFlashErrorViewer->perms()->attach($permTestLevelWarning->id);
$roleFlashErrorViewer->perms()->attach($permTestLevelInfo->id);
$roleFlashErrorViewer->perms()->attach($permTestLevelSuccess->id);
// Assign user membership to role
$roleFlashErrorViewer->users()->attach($testUserFive->id);
/////////
// Find basic-authenticated permission.
$permBasicAuthenticated = Permission::where('name', 'basic-authenticated')->first();
// Find guest-only permission.
$permGuestOnly = Permission::where('name', 'guest-only')->first();
// Find open-to-all permission.
$permOpenToAll = Permission::where('name', 'open-to-all')->first();
// Find admin-settings permission.
$permAdminSettings = Permission::where('name', 'admin-settings')->first();
////////////////////////////////////
// Associate some permission to acl test routes
$routeTestACLHome = Route::where('name', 'test-acl.home')->get()->first();
$routeTestACLHome->permission()->associate($permOpenToAll);
$routeTestACLHome->save();
//
$routeTestACLAdmins = Route::where('name', 'test-acl.admins')->get()->first();
$routeTestACLAdmins->permission()->associate($permAdminSettings);
$routeTestACLAdmins->save();
//
$routeTestACLBasicAuthenticated = Route::where('name', 'test-acl.basic-authenticated')->get()->first();
$routeTestACLBasicAuthenticated->permission()->associate($permBasicAuthenticated);
$routeTestACLBasicAuthenticated->save();
//
$routeTestACLGuestOnly = Route::where('name', 'test-acl.guest-only')->get()->first();
$routeTestACLGuestOnly->permission()->associate($permGuestOnly);
$routeTestACLGuestOnly->save();
//
$routeTestACLOpenToAll = Route::where('name', 'test-acl.open-to-all')->get()->first();
$routeTestACLOpenToAll->permission()->associate($permOpenToAll);
$routeTestACLOpenToAll->save();
////////////////////////////////////
// Associate some permission to flash test routes
//.........这里部分代码省略.........
示例14: delete
public function delete(Request $request)
{
$del = ParentFrontpage::find($request->input('id'));
$permission = Permission::where('name', $del->name)->get();
if (count($permission) > 0) {
foreach ($permission as $key => $p) {
$p->delete();
}
}
$del->delete();
return $del == true ? 'success' : 'fail';
}
示例15: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function edit($society, $id)
{
if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society)) {
$data['society'] = $society;
$data['categories'] = array('forms', 'preaching');
$data['download'] = Download::find($id);
$data['chosensoc'] = explode(',', $data['download']->societies);
$allsoc = Permission::where('user_id', '=', Auth::user()->id)->get();
foreach ($allsoc as $asoc) {
$data['societies'][$asoc->society_id] = $asoc->society->society;
}
return view('downloads.edit', $data);
} else {
return View::make("shared.unauthorised");
}
}