本文整理汇总了PHP中app\Permission::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::save方法的具体用法?PHP Permission::save怎么用?PHP Permission::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Permission
的用法示例。
在下文中一共展示了Permission::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
public function store(Request $request)
{
$permission = new Permission();
$data = $request->all();
$permission->name = $data['name'];
$permission->display_name = $data['display_name'];
$permission->description = $data['description'];
$permission->save();
$permission->save();
alert()->success('...', 'Permission enregistrée !')->autoclose(3500);
return redirect('/entrust/permissions/' . $permission->id . '/edit');
}
示例2: 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();
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//Roles
$userAdmin = new Role();
$userAdmin->name = 'admin';
$userAdmin->display_name = 'Administrator';
$userAdmin->description = 'User is an admin and can edit and manage users';
$userAdmin->save();
$reportsUser = new Role();
$reportsUser->name = 'reports-user';
$reportsUser->display_name = 'Reports User';
$reportsUser->description = 'Reports User can use Note Code Conflicts';
$reportsUser->save();
$csUser = new Role();
$csUser->name = 'cs-user';
$csUser->display_name = 'Customer Service User';
$csUser->description = 'Customer Service User can Upload Notes Import';
$csUser->save();
//Permissions
$userRegistration = new Permission();
$userRegistration->name = 'user-reg';
$userRegistration->display_name = 'User Registration';
$userRegistration->description = 'Create new users admin only';
$userRegistration->save();
$manageUsers = new Permission();
$manageUsers->name = 'manage-users';
$manageUsers->display_name = 'Manage Users';
$manageUsers->description = 'Manage Users - Permissions, etc.';
$manageUsers->save();
$reports = new Permission();
$reports->name = 'reports';
$reports->display_name = 'Reports Section';
$reports->description = 'Access to reports section';
$reports->save();
$admin = new Permission();
$admin->name = 'admin';
$admin->display_name = 'Admin Section';
$admin->description = 'Access to admin section';
$admin->save();
$dispositions = new Permission();
$dispositions->name = 'dispositions';
$dispositions->display_name = 'Disposition Uploads';
$dispositions->description = 'Access to Disposition Uploads';
$dispositions->save();
$notesImport = new Permission();
$notesImport->name = 'notes-import';
$notesImport->display_name = 'Upload Notes Import';
$notesImport->description = 'Access to upload notes import';
$notesImport->save();
$noteConflicts = new Permission();
$noteConflicts->name = 'note-conflicts';
$noteConflicts->display_name = 'Note Code Conflicts';
$noteConflicts->description = 'Access to Node Code Conflicts';
$noteConflicts->save();
$batchRefund = new Permission();
$batchRefund->name = 'batch-refund';
$batchRefund->display_name = 'Batch Refunds';
$batchRefund->description = 'Access to Batch Refunds';
$batchRefund->save();
}
示例4: 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');
}
示例5: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
/**
* Create four roles: admin, moderator, user and guest.
*/
$admin = new Role();
$admin->name = 'admin';
$admin->display_name = 'Administrator';
$admin->description = 'Super User Do';
$admin->save();
$moderator = new Role();
$moderator->name = 'moderator';
$moderator->display_name = 'Moderator';
$moderator->description = 'Kan alle bestellingen zien en gebruikergegevens opvragen.';
$moderator->save();
$user = new Role();
$user->name = 'user';
$user->display_name = 'Gebruiker';
$user->description = 'Standaard gebruiker. Kan bestellingen plaatsen en eigen gegevens inkijken.';
$user->save();
$guest = new Role();
$guest->name = 'guest';
$guest->display_name = 'Gast';
$guest->description = 'Standaard gebruiker. Kan bestellingen plaatsen.';
$guest->save();
/**
* Attach roles to users.
*/
$adminUser = User::where('email', '=', 'sander@dekroon.xyz')->first();
$adminUser->attachRole($admin);
$moderatorUser = User::where('email', '=', 'john@doe.nl')->first();
$moderatorUser->attachRole($moderator);
$normalUser = User::where('email', '=', 'marie@doe.nl')->first();
$normalUser->attachRole($user);
$guestUser = User::where('email', '=', 'gast@gastman.com')->first();
$guestUser->attachRole($guest);
/**
* Create permissions.
*/
$createPage = new Permission();
$createPage->name = 'create-page';
$createPage->display_name = 'Create Pages';
$createPage->description = 'create new pages';
$createPage->save();
$editPage = new Permission();
$editPage->name = 'edit-page';
$editPage->display_name = 'Edit Pages';
$editPage->description = 'edit existing pages';
$editPage->save();
$editUser = new Permission();
$editUser->name = 'edit-user';
$editUser->display_name = 'Edit Users';
$editUser->description = 'edit existing users';
$editUser->save();
/**
* Attach permissions to roles.
*/
$admin->attachPermissions(array($createPage, $editPage, $editUser));
$moderator->attachPermissions(array($createPage, $editPage));
}
示例6: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('users')->insert(array(['id' => 1, 'name' => 'Admin', 'email' => 'admin@website.com', 'password' => Hash::make('admin'), 'created_at' => new DateTime(), 'updated_at' => new DateTime()], ['id' => 2, 'name' => 'Member', 'email' => 'member@website.com', 'password' => Hash::make('member'), 'created_at' => new DateTime(), 'updated_at' => new DateTime()]));
$admin = new Role();
$admin->name = 'admin';
$admin->display_name = 'User Administrator';
$admin->description = 'User is allowed to manage and edit other users';
$admin->save();
$member = new Role();
$member->name = 'member';
$member->display_name = 'Member';
$member->description = 'User is a member';
$member->save();
$user = User::where('name', '=', 'Admin')->first();
$user->attachRole($admin);
$user = User::where('name', '=', 'Member')->first();
$user->attachRole($member);
$addLocal = new Permission();
$addLocal->name = 'add-local';
$addLocal->display_name = 'Add Local Site';
$addLocal->description = 'add new local site';
$addLocal->save();
$viewContent = new Permission();
$viewContent->name = 'view-content';
$viewContent->display_name = 'View Content';
$viewContent->description = 'view content in system';
$viewContent->save();
$admin->attachPermission($addLocal);
$admin->attachPermission($viewContent);
$member->attachPermission($viewContent);
}
示例7: createdummies
/**
* Create a new controller instance.
*
* @return void
*/
public function createdummies()
{
$wizard = new Role();
$wizard->name = 'Wizard';
$wizard->save();
$muggle = new Role();
$muggle->name = 'Muggle';
$muggle->save();
$castspells = new Permission();
$castspells->name = 'can_castspells';
$castspells->display_name = 'Can Cast Spells';
$castspells->description = 'Enables you to cast awesome spells';
$castspells->save();
$bestupid = new Permission();
$bestupid->name = 'can_bestupid';
$bestupid->display_name = 'Be stupid';
$bestupid->description = 'Enables you to be stupid and not see the magic around you';
$bestupid->save();
$wizard->attachPermission($castspells);
$muggle->attachPermission($bestupid);
$wiz_role = DB::Table('roles')->where('name', '=', 'Wizard')->pluck('id');
$mug_role = DB::Table('roles')->where('name', '=', 'Muggle')->pluck('id');
$harryPotter = User::where('username', '=', 'HarryPotter')->first();
$harryPotter->roles()->attach($wiz_role);
$smithwee = User::where('username', '=', 'SmithWee')->first();
$smithwee->roles()->attach($mug_role);
return 'Abracadabra!';
}
示例8: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(PermissionRequest $request)
{
$permission = new Permission();
$permission->fill($request->all());
$permission->name = snake_case($request->display_name);
$permission->save();
return redirect()->route('permiso.index');
}
示例9: createPermission
public function createPermission(Request $request)
{
$item = new Permission();
$item->name = $request->name;
$item->display_name = $request->display_name;
$item->description = $request->description;
$item->save();
return \Response::make($item, 200);
}
示例10: run
public function run()
{
$this->command->info('Roles data seeded!');
$owner = new Role();
$owner->name = 'owner';
$owner->display_name = 'Owner';
// optional
$owner->description = 'Root';
// optional
$owner->save();
$admin = new Role();
$admin->name = 'admin';
$admin->display_name = 'Administrator';
// optional
$admin->description = 'Administradores';
// optional
$admin->save();
$this->command->info('Roles data attaching to users!');
if ($owner) {
$owner_user = User::where('name', '=', 'owner')->first();
// role attach alias
$owner_user->attachRole($owner);
// parameter can be an Role object, array, or id
$this->command->info('Owner role attached!');
}
if ($admin) {
$admin_user = User::where('name', '=', 'ligacbb')->first();
// role attach alias
$admin_user->attachRole($admin);
// parameter can be an Role object, array, or id
$this->command->info('Admin role attached!');
}
$this->command->info('Creating Permissions!');
$owner_permission = new Permission();
$owner_permission->name = 'owner-permission';
$owner_permission->display_name = 'Full control';
// optional
// Allow a user to...
$owner_permission->description = '';
// optional
$owner_permission->save();
$admin_permission = new Permission();
$admin_permission->name = 'admin-permission';
$admin_permission->display_name = 'Admin permission';
// optional
// Allow a user to...
$admin_permission->description = '';
// optional
$admin_permission->save();
$this->command->info('Attaching Owner Permission!');
$owner->attachPermission($owner_permission);
// equivalent to $admin->perms()->sync(array($owner_permission->id));
$this->command->info('Attaching Admin Permission!');
$admin->attachPermission($admin_permission);
// equivalent to $owner->perms()->sync(array($createPost->id, $editUser->id));
}
示例11: seedDataSource
/**
* Seed Data Source
*
* @author SL
* @return void
*/
protected function seedDataSource()
{
Model::unguard();
$permission = new \App\Permission();
$permission->name = 'applications-merchant-payments';
$permission->display_name = 'Merchant Payments';
$permission->description = 'merchant payments';
$permission->save();
$roles = ['manager', 'su', 'administrator'];
foreach ($roles as $roleName) {
try {
$role = \App\Role::where('name', '=', $roleName)->first();
$permission->roles()->attach($role->id);
} catch (Exception $e) {
}
}
$permission->save();
Model::reguard();
}
示例12: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$input = $request->all();
$this->validate($request, ['name' => 'required|max:255', 'label' => 'required|max:255']);
$permission = new Permission();
$permission->label = $request->label;
$permission->name = $request->name;
$permission->save();
Session::flash('flash_message', 'Permission successfully added!');
return redirect('/admin/permissions');
}
示例13: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$permission = new Permission();
$permission->name = $request->name;
$permission->display_name = $request->display_name;
$permission->description = $request->description;
$permission->save();
$parent_role = Role::find($request->role);
$parent_role->attachPermission($permission);
return redirect('permissions');
}
示例14: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$superAdmin = new Role();
$superAdmin->name = 'super admin';
$superAdmin->display_name = 'Super admin';
$superAdmin->description = 'This role holder has right to everything on the application.';
$superAdmin->save();
$authUser = new Role();
$authUser->name = 'auth user';
$authUser->display_name = 'Authenticated User';
$authUser->description = 'This is the basic role which every registered user will get by default.';
$authUser->save();
/**
* Manage Role Permissions
*/
$manageRolePermission = new Permission();
$manageRolePermission->name = 'manage-role-perm';
$manageRolePermission->display_name = 'Manage Role & Permissions';
$manageRolePermission->description = 'Manage roles and give permissions to role holders.';
$manageRolePermission->save();
$superAdmin->attachPermission($manageRolePermission);
/**
* Manage User Permission
*/
$manageUserPermission = new Permission();
$manageUserPermission->name = 'manage-users';
$manageUserPermission->display_name = 'Manage Users';
$manageUserPermission->description = 'Manage Users';
$manageUserPermission->save();
$superAdmin->attachPermission($manageUserPermission);
/**
* Manage Permission to see Activity
*/
$manageActivityViewPermission = new Permission();
$manageActivityViewPermission->name = 'view-activity';
$manageActivityViewPermission->display_name = 'View Activity';
$manageActivityViewPermission->description = 'View the different user activity in the system.';
$manageActivityViewPermission->save();
$superAdmin->attachPermission($manageActivityViewPermission);
/**
* Manage settings for application
*/
$manageSettingsPermission = new Permission();
$manageSettingsPermission->name = 'manage-settings';
$manageSettingsPermission->display_name = 'Manage Settings';
$manageSettingsPermission->description = 'Manage Settings for the application. User can change settings.';
$manageSettingsPermission->save();
$superAdmin->attachPermission($manageSettingsPermission);
$user = User::create(['name' => 'Amitav Roy', 'email' => 'reachme@amitavroy.com', 'password' => \Illuminate\Support\Facades\Hash::make('password'), 'first_name' => 'Amitav', 'last_name' => 'Roy', 'status' => 1]);
$authUser = User::create(['name' => 'Jhon Doe', 'email' => 'jhon.doe@gmail.com', 'password' => \Illuminate\Support\Facades\Hash::make('password'), 'first_name' => 'Jhon', 'last_name' => 'Doe', 'status' => 1]);
$authUser->attachRole($authUser);
$user->attachRole($superAdmin);
}
示例15: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(PermissionRequest $request)
{
//
// $input = Request::all();
// Permission::create($input);
$permission = new Permission();
$permission->name = $request->input('name');
$permission->display_name = $request->input('display_name');
$permission->description = $request->input('description');
$permission->save();
return redirect('system/permissions');
}