本文整理汇总了PHP中app\Role::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::save方法的具体用法?PHP Role::save怎么用?PHP Role::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Role
的用法示例。
在下文中一共展示了Role::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$role = new Role();
$role->name = Input::get('name');
$role->save();
return Redirect::route('template.role.index');
}
示例2: 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!';
}
示例3: setupFounderAndBaseRolesPermission
/**
* Initialize the user group
*
*/
public function setupFounderAndBaseRolesPermission()
{
//Create Roles
$founder = new Role();
$founder->name = 'Founder';
$founder->save();
$admin = new Role();
$admin->name = 'Admin';
$admin->save();
//Create User
$user = new User();
$user->name = 'muzhuang';
$user->email = 'admin@admin.com';
$user->password = Hash::make('secret');
if (!$user->save()) {
Log::info('Unabel to create user ' . $user->username, (array) $user->errors());
} else {
Log::info('Create user "' . $user->username . '" <' . $user->email . '>');
}
//Attach Roles to user
$user->roles()->attach($founder->id);
//Create Permissions
$manageUsers = new Permission();
$manageUsers->name = 'admin.user';
$manageUsers->display_name = 'Manage Users';
$manageUsers->save();
// Assign Permission to Role
$founder->perms()->sync([$manageUsers->id]);
$admin->perms()->sync([$manageUsers->id]);
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(RoleFormRequest $request)
{
//Guarda datos del formulario de roles
$role = new Role(array('name' => $request->get('name'), 'display_name' => $request->get('display_name'), 'description' => $request->get('description')));
$role->save();
return redirect('/admin/roles/create')->with('status', 'A new role has been created!');
}
示例5: run
/**
* Run the database seeds.
*/
public function run()
{
//初始化系统默认 Role
foreach (['销售', '售后', '产品', '硬件'] as $name) {
$role = Role::where('name', $name)->first();
if (!$role) {
$role = new Role();
}
$role->name = $name;
$role->system = true;
$role->save();
}
//销售权限设定
$role = Role::where('name', '销售')->first();
$role->perms = ['产品查看', '服务器查看', '硬件查看', '客户查看', '硬件查看', '项目查看', '客户信息管理', '项目签约', '项目信息管理', '项目模块管理', '项目参数管理', '项目硬件管理', '项目服务器管理'];
$role->save();
//售后权限设定
$role = Role::where('name', '售后')->first();
$role->perms = ['产品查看', '服务器查看', '硬件查看', '客户查看', '硬件查看', '项目查看', '项目信息管理', '项目模块管理', '项目参数管理', '项目硬件管理', '项目服务器管理', '服务器信息管理', '项目文件管理', '项目外出记录管理', '项目硬件部署管理'];
$role->save();
//产品权限设定
$role = Role::where('name', '产品')->first();
$role->perms = ['产品查看', '服务器查看', '硬件查看', '客户查看', '硬件查看', '项目查看', '产品信息管理', '产品类别管理', '产品模块管理', '产品参数管理', '服务器信息管理'];
$role->save();
//硬件权限设定
$role = Role::where('name', '硬件')->first();
$role->perms = ['产品查看', '服务器查看', '硬件查看', '客户查看', '硬件查看', '项目查看', '硬件管理'];
$role->save();
}
示例6: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$admin = new Role();
$admin->name = 'admin';
$admin->display_name = 'Администратор';
// optional
$admin->description = '';
// optional
$admin->save();
DB::table('users')->delete();
$row1 = array_combine(['id', 'name', 'email', 'phone', 'avatar', 'provider', 'provider_id'], $this->items[0]) + ['password' => bcrypt('111111')];
$user1 = User::create($row1);
$row2 = array_combine(['id', 'name', 'email', 'phone', 'avatar', 'provider', 'provider_id'], $this->items[1]) + ['password' => bcrypt('111111')];
$user2 = User::create($row2);
$row3 = array_combine(['id', 'name', 'email', 'phone', 'avatar', 'provider', 'provider_id'], $this->items[2]) + ['password' => bcrypt('zaurzaur')];
$user3 = User::create($row3);
$row4 = array_combine(['id', 'name', 'email', 'phone', 'avatar', 'provider', 'provider_id'], $this->items[3]) + ['password' => bcrypt('16180339887')];
$user4 = User::create($row4);
$row5 = array_combine(['id', 'name', 'email', 'phone', 'avatar', 'provider', 'provider_id'], $this->items[4]) + ['password' => bcrypt('16180339887')];
$user5 = User::create($row5);
$user1->attachRole($admin);
$user3->attachRole($admin);
$user4->attachRole($admin);
$user5->attachRole($admin);
}
示例7: 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));
}
示例8: 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();
}
示例9: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// Creating Roles
$admin = new Role();
$admin->name = 'admin';
$admin->display_name = 'User Administrator';
// optional
$admin->description = 'User is allowed to manage and edit';
// optional
$admin->save();
$moderator = new Role();
$moderator->name = 'moderator';
$moderator->display_name = 'Moderator';
// optional
$moderator->description = 'Moderator is allowed to moderate';
// optional
$moderator->save();
$user = new Role();
$user->name = 'user';
$user->display_name = 'General User';
// optional
$user->description = 'General User is allowed to use facilities of the site';
// optional
$user->save();
// creating an array of roles
$roles = array($admin, $moderator, $user);
// assigning roles to user
$users = User::all();
foreach ($users as $u) {
$u->attachRole($roles[rand(0, 2)]);
}
}
示例10: run
public function run()
{
DB::table('roles')->delete();
$adminRole = new Role();
$adminRole->name = 'admin';
$adminRole->display_name = 'admin';
$adminRole->description = 'description';
$adminRole->is_admin = 1;
$adminRole->save();
$commentRole = new Role();
$commentRole->name = 'comment';
$commentRole->display_name = 'comment';
$commentRole->description = 'description';
$commentRole->is_admin = 0;
$commentRole->save();
$user = User::where('email', '=', 'admin@admin.com')->first();
$assignedrole = new AssignedRoles();
$assignedrole->user_id = $user->id;
$assignedrole->role_id = $adminRole->id;
$assignedrole->save();
$user = User::where('email', '=', 'user@user.com')->first();
$assignedrole = new AssignedRoles();
$assignedrole->user_id = $user->id;
$assignedrole->role_id = $commentRole->id;
$assignedrole->save();
}
示例11: 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);
}
示例12: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$role = new Role();
$role->name = 'admin';
$role->display_name = '管理員';
$role->save();
}
示例13: postCreate
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function postCreate(Request $request)
{
// Declare the rules for the form validation
$rules = array('name' => 'required|unique:roles', 'display_name' => 'required|unique:roles');
// Validate the inputs
$validator = Validator::make($request->all(), $rules, ['name.required' => 'A name is required.', 'name.unique' => 'Please use a different name.', 'display_name.required' => 'A display name is required', 'display_name.unique' => 'Please use a different display name.']);
// Check if the form validates with success
if ($validator->passes()) {
// Get the inputs, with some exceptions
$inputs = $request->except('csrf_token');
$this->role->name = $request->input('name');
$this->role->display_name = $request->input('display_name');
$this->role->is_protected = $request->has('is_protected') ? 1 : 0;
$this->role->is_superuser = $request->has('is_superuser') ? 1 : 0;
$this->role->save();
// Save permissions
$this->role->perms()->sync($this->permission->preparePermissionsForSave($inputs['permissions']));
// Was the role created?
if ($this->role->id) {
// Redirect to the new role page
Flash::success('Created role');
return redirect('admin/roles/' . $this->role->id . '/edit');
}
// Redirect to the new role page
Flash::error('Could not create role');
return redirect('admin/roles/create');
}
// Form validation failed
return redirect('admin/roles/create')->withInput()->withErrors($validator);
}
示例14: postCreate
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function postCreate(RoleRequest $request)
{
$is_admin = 0;
// Check if role is for admin user
if (!empty($request->permission)) {
$permissionsAdmin = Permission::where('is_admin', '=', 1)->get();
foreach ($permissionsAdmin as $perm) {
foreach ($request->permission as $item) {
if ($item == $perm['id'] && $perm['is_admin'] == '1') {
$is_admin = 1;
}
}
}
}
$role = new Role();
$role->is_admin = $is_admin;
$role->name = $request->name;
$role->save();
if (is_array($request->permission)) {
foreach ($request->permission as $item) {
$permission = new PermissionRole();
$permission->permission_id = $item;
$permission->role_id = $role->id;
$permission->save();
}
}
}
示例15: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$projectManager = new Role();
$projectManager->name = 'project-manager';
$projectManager->display_name = 'Project Manager';
// optional
$projectManager->description = 'User is the manager of a given project';
// optional
$projectManager->save();
$admin = new Role();
$admin->name = 'admin';
$admin->display_name = 'User Administrator';
// optional
$admin->description = 'User is allowed to manage and edit other users';
// optional
$admin->save();
$teamLeader = new Role();
$teamLeader->name = 'team-leader';
$teamLeader->display_name = 'Team Leader';
// optional
$teamLeader->description = 'User is the team leader of a given project';
// optional
$teamLeader->save();
$programmer = new Role();
$programmer->name = 'programmer';
$programmer->display_name = 'Programmer';
// optional
$programmer->description = 'User is the team programmer of a given project';
// optional
$programmer->save();
}