Example #1
0
 /**
  * Create new Permission;
  * @param $name
  * @param $perm
  */
 private function registerPermissionsCreate($name, $perm)
 {
     $flag = Permission::where('name', '=', $name . '.' . $perm)->first();
     if (empty($flag)) {
         Permission::create(['name' => $name . '.' . $perm, 'display_name' => $this->registerPermissionsDisplay($perm), 'description' => '']);
     }
 }
 public function store(Request $request)
 {
     $keys = 'name,display_name,description';
     $data = $this->autoValidate($request, 'permission.store', $keys);
     Permission::create($data);
     return $this->success('', url('admin/permission'));
 }
Example #3
0
 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();
 }
Example #4
0
 /**
  * do add data
  * @param mixed $request
  * @return redirect
  */
 public function store(Request $request)
 {
     $messages = ['name.required' => 'Permission name is necessary!'];
     $this->validate($request, ['name' => 'required'], $messages);
     Permission::create($request->all());
     return redirect(route('admin.permission.index'))->with('info', 'Added Successfully~~');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Create Roles
     $subscriberRole = Role::create(['name' => '订阅者', 'slug' => 'subscriber']);
     $contributorRole = Role::create(['name' => '投稿者', 'slug' => 'contributor']);
     $authorRole = Role::create(['name' => '作者', 'slug' => 'author']);
     $editorRole = Role::create(['name' => '编辑', 'slug' => 'editor']);
     $adminRole = Role::create(['name' => '管理员', 'slug' => 'admin']);
     // Create Permission
     $createArticlePermission = Permission::create(['name' => '发布文章', 'slug' => 'article.create']);
     $uploadImagePermission = Permission::create(['name' => '上传图片', 'slug' => 'image.upload']);
     $manageArticlePermission = Permission::create(['name' => '文章管理', 'slug' => 'article.manage']);
     $manageImagePermission = Permission::create(['name' => '图片管理', 'slug' => 'image.manage']);
     $manageUserPermission = Permission::create(['name' => '用户管理', 'slug' => 'user.manage']);
     $contributorRole->assignPermission($createArticlePermission->id);
     $authorRole->assignPermission($createArticlePermission->id);
     $authorRole->assignPermission($uploadImagePermission->id);
     $editorRole->assignPermission($createArticlePermission->id);
     $editorRole->assignPermission($uploadImagePermission->id);
     $editorRole->assignPermission($manageArticlePermission->id);
     $editorRole->assignPermission($manageImagePermission->id);
     // Create User
     $admin = User::create(['name' => env('ADMIN_NAME', 'Admin'), 'email' => env('ADMIN_EMAIL', '*****@*****.**'), 'password' => bcrypt(env('ADMIN_PASSWORD', 'password'))]);
     if (!$admin->save()) {
         Log::info('Unable to create admin ' . $admin->username, (array) $admin->errors());
     } else {
         $admin->assignRole($adminRole->id);
         Log::info('Created admin "' . $admin->username . '" <' . $admin->email . '>');
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('permissions')->truncate();
     Permission::create(['name' => 'can-create-request', 'display_name' => 'Can create request', 'description' => 'Allows the user to submit a new request']);
     Permission::create(['name' => 'can-approve-request', 'display_name' => 'Can approve request', 'description' => 'User can approve submitted requests']);
     Permission::create(['name' => 'can-admin', 'display_name' => 'Can Admin', 'description' => 'User can so anything']);
 }
Example #7
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Role::create(['name' => 'manager_receive', 'label' => 'Manager of Receive.']);
     Role::create(['name' => 'manager_requesition', 'label' => 'Manager of Requesition.']);
     Role::create(['name' => 'manager_product_list', 'label' => 'Manager of Product list.']);
     Role::create(['name' => 'manager_product', 'label' => 'Manager of Product.']);
     Role::create(['name' => 'manager_product_type', 'label' => 'Manager of Product Type.']);
     Role::create(['name' => 'manager_unit', 'label' => 'Manager of Unit.']);
     Role::create(['name' => 'manager_location', 'label' => 'Manager of Location.']);
     Role::create(['name' => 'manager_project', 'label' => 'Manager of Project.']);
     Role::create(['name' => 'manager_user', 'label' => 'Manager of User.']);
     Permission::create(['name' => 'create_form', 'label' => 'Create of form.']);
     Permission::create(['name' => 'update_form', 'label' => 'Update of form.']);
     Permission::create(['name' => 'delete_form', 'label' => 'Delete of form.']);
     $roles = Role::all();
     $permissions = Permission::all();
     foreach ($roles as $role) {
         foreach ($permissions as $permission) {
             $role->givePermissionTo($permission);
         }
     }
     $user = User::whereEmail('*****@*****.**')->first();
     foreach ($roles as $role) {
         $user->assignRole($role->name);
     }
     $user = User::whereEmail('*****@*****.**')->first();
     foreach ($roles as $role) {
         $user->assignRole($role->name);
     }
 }
Example #8
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $admin = Role::create(['name' => 'admin', 'display_name' => 'Administrator']);
     $managePieces = Permission::create(['name' => 'manage-pieces', 'display_name' => 'create and edit pieces']);
     $admin->attachPermission($managePieces);
     $super = User::where('email', '*****@*****.**')->first()->attachRole($admin);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param \Illuminate\Http\Request $request
  *
  * @return void
  */
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required']);
     Permission::create($request->all());
     Session::flash('flash_message', 'Permission added!');
     return redirect('admin/permissions');
 }
 public function run()
 {
     // create roles
     $admin = Role::create(['name' => 'admin', 'display_name' => 'Admin', 'description' => 'performs administrative tasks', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     $cashier = Role::create(['name' => 'cashier', 'display_name' => 'Cashier', 'description' => 'performs cashier tasks', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     $user = Role::create(['name' => 'user', 'display_name' => 'Portal User', 'description' => 'performs all basic tasks like print receipt, etc...', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     // create permissions
     $editUser = Permission::create(['name' => 'edit-user', 'display_name' => 'Edit Users', 'description' => 'manage users', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     $reporting = Permission::create(['name' => 'reporting', 'display_name' => 'Print Report, Print receipt', 'description' => 'manage reports', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     $editReporting = Permission::create(['name' => 'edit-reporting', 'display_name' => 'Edit Report, Edit receipt', 'description' => 'manage reports', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     $receipt = Permission::create(['name' => 'view-receipt', 'display_name' => 'View receipt, View Billings', 'description' => 'View recipent and view billings', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     // assign permissions to roles
     $admin->attachPermissions(array($editUser, $reporting, $receipt, $editReporting));
     $cashier->attachPermissions(array($reporting, $receipt, $editReporting));
     $user->attachPermissions(array($reporting, $receipt));
     // attach admin user to admin role
     $userAdmin = User::where('email', env('ADMIN_EMAIL'))->firstOrFail();
     $userAdmin->attachRole($admin);
     // assign default role to users
     $users = User::all();
     foreach ($users as $normalUser) {
         if ($normalUser->hasRole('user')) {
             continue;
         }
         $normalUser->attachRole($user);
     }
 }
 public function rolesPermissions()
 {
     Permission::create(['name' => 'List roles', 'slug' => 'roles-list']);
     Permission::create(['name' => 'Show role', 'slug' => 'roles-show']);
     Permission::create(['name' => 'Create role', 'slug' => 'roles-create']);
     Permission::create(['name' => 'Edit role', 'slug' => 'roles-edit']);
     Permission::create(['name' => 'Delete role', 'slug' => 'roles-delete']);
 }
 public function run()
 {
     $faker = Faker::create('en_GB');
     $permissions = [['Owner', true, true, true, true, true], ['Administrator', true, true, true, true, false], ['Editor', true, true, true, false, false], ['Contributor', true, true, false, false, false], ['Reader', true, false, false, false, false]];
     foreach (range(1, count($permissions)) as $index) {
         Permission::create(['name' => $permissions[$index - 1][0], 'read' => (bool) $permissions[$index - 1][1], 'contribute' => (bool) $permissions[$index - 1][2], 'write' => (bool) $permissions[$index - 1][3], 'admin' => (bool) $permissions[$index - 1][4], 'own' => (bool) $permissions[$index - 1][5]]);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     if (!$this->user->userCan('permission-create')) {
         \App::abort(403, 'Access denied');
     }
     \App\Permission::create($request->all());
     return redirect('/admin/permission');
 }
 /**
  * Store a new role
  */
 public function store(PermissionRequest $request)
 {
     $name = str_slug($request->name, "-");
     $label = $request->name;
     $permission = Permission::create(['name' => $name, 'label' => $label]);
     logThis('New Permission Created: ' . $permission->name . '(' . $permission->label . ')');
     return $permission;
 }
 public function run()
 {
     $faker = Faker::create('en_US');
     /*
      * Base User Accounts
      */
     // Mike's account
     $michael = User::create(['name' => 'Michael Norris', 'email' => '*****@*****.**', 'password' => bcrypt('password'), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Super Administrator (User)
     $superU = User::create(['name' => 'Super Administrator', 'email' => '*****@*****.**', 'password' => bcrypt('password'), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Administrator (User)
     $adminU = User::create(['name' => 'Administrator', 'email' => '*****@*****.**', 'password' => bcrypt('password'), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     /*
      * Roles
      */
     // Super Administrator (Role)
     $superR = Role::create(['name' => 'Super Administrator', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Administrator (Role)
     $adminR = Role::create(['name' => 'Administrator', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // User (Role)
     $basicUserR = Role::create(['name' => 'Basic User', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     /*
      * Permissions
      */
     // Super Administrator (Permission)
     $superP = Permission::create(['name' => 'Super Administrator (Permission)', 'level' => '1000', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Administrator (Permission)
     $adminP = Permission::create(['name' => 'Administrator (Permission)', 'level' => '500', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Level 200 (Permission)
     $p200 = Permission::create(['name' => 'Level 200 (Permission)', 'level' => '200', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Level 100 (Permission)
     $p100 = Permission::create(['name' => 'Level 100 (Permission)', 'level' => '100', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Level 50 (Permission)
     Permission::create(['name' => 'Level 50 (Permission)', 'level' => '50', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Level 20 (Permission)
     Permission::create(['name' => 'Level 20 (Permission)', 'level' => '20', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Level 10 (Permission)
     Permission::create(['name' => 'Level 10 (Permission)', 'level' => '10', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Level 5 (Permission)
     Permission::create(['name' => 'Level 5 (Permission)', 'level' => '5', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Level 2 (Permission)
     Permission::create(['name' => 'Level 2 (Permission)', 'level' => '2', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Level 1 (Permission)
     Permission::create(['name' => 'Level 1 (Permission)', 'level' => '1', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     // Level 0 (Permission)
     Permission::create(['name' => 'Level 0 (Permission)', 'level' => '0', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
     /*
      * Detailed User Accounts with Roles and Permissions
      */
     $superU->roles()->attach($superR);
     $adminU->roles()->attach($adminR);
     $superR->permissions()->attach($superP);
     $adminR->permissions()->attach($adminP);
     $michael->roles()->attach($superR);
     factory(User::class, 50)->create()->each(function ($u) use($basicUserR) {
         $u->roles()->attach($basicUserR);
     });
 }
 public function run()
 {
     $permissions = [array(array('display_name' => 'Kullanıcı Görüntüle', 'name' => 'wts.user.show')), array(array('display_name' => 'Kullanıcı Ekle', 'name' => 'wts.user.create')), array(array('display_name' => 'Kullanıcı Düzenle', 'name' => 'wts.user.edit')), array(array('display_name' => 'Kullanıcı Sil', 'name' => 'wts.user.delete')), array(array('display_name' => 'Grup Görüntüle', 'name' => 'wts.group.show')), array(array('display_name' => 'Grup Ekle', 'name' => 'wts.group.create')), array(array('display_name' => 'Grup Düzenle', 'name' => 'wts.group.edit')), array(array('display_name' => 'Grup Sil', 'name' => 'wts.group.delete')), array(array('display_name' => 'Departman Görüntüle', 'name' => 'wts.department.show')), array(array('display_name' => 'Departman Ekle', 'name' => 'wts.department.create')), array(array('display_name' => 'Departman Düzenle', 'name' => 'wts.department.edit')), array(array('display_name' => 'Departman Sil', 'name' => 'wts.department.delete')), array(array('display_name' => 'İş Görüntüle', 'name' => 'wts.work.show')), array(array('display_name' => 'İş Ekle', 'name' => 'wts.work.create')), array(array('display_name' => 'İş Düzenle', 'name' => 'wts.work.edit')), array(array('display_name' => 'İş Sil', 'name' => 'wts.work.delete')), array(array('display_name' => 'Yönetim Görüntüle', 'name' => 'wts.management.show')), array(array('display_name' => 'Yönetim Ekle', 'name' => 'wts.management.create')), array(array('display_name' => 'Yönetim Düzenle', 'name' => 'wts.management.edit')), array(array('display_name' => 'Yönetim Sil', 'name' => 'wts.management.delete'))];
     //
     //
     foreach ($permissions as $p) {
         $query = Permission::create($p[0]);
     }
 }
Example #17
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Requests\CreatePermissionRequest $request)
 {
     //
     $input = $request->all();
     \Session::flash('flash_message', 'permission ' . $input['name'] . ' created.');
     // create
     \App\Permission::create($input);
     return redirect('permissions');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['display' => 'required', 'name' => 'required'], ['display.required' => 'Opsi tidak boleh kosong.', 'name.required' => 'Key tidak boleh kosong.']);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator)->withInput();
     }
     if (Permission::create($request->all())) {
         return redirect('/user/permission')->with('succcess', 'Sukses simpan permission.');
     }
     return redirect()->back()->withErrors(['failed' => 'Gagal simpan permission.']);
 }
 /**
  * Run the migrations.
  *
  * @return  void
  */
 public function up()
 {
     \App\Field::create(['name' => 'male', 'title' => '男', 'field_class' => 'gender'])->create(['name' => 'female', 'title' => '女', 'field_class' => 'gender'])->create(['name' => 'news', 'title' => '订阅号', 'field_class' => 'wechat_type'])->create(['name' => 'service', 'title' => '服务号', 'field_class' => 'wechat_type'])->create(['name' => 'enterprise', 'title' => '企业号', 'field_class' => 'wechat_type'])->create(['name' => 'depot', 'title' => '素材', 'field_class' => 'wechat_message_type'])->create(['name' => 'news', 'title' => '图文', 'field_class' => 'wechat_message_type'])->create(['name' => 'image', 'title' => '图片', 'field_class' => 'wechat_message_type'])->create(['name' => 'thumb', 'title' => '缩略图', 'field_class' => 'wechat_message_type'])->create(['name' => 'video', 'title' => '视频', 'field_class' => 'wechat_message_type'])->create(['name' => 'shortvideo', 'title' => '小视频', 'field_class' => 'wechat_message_type'])->create(['name' => 'voice', 'title' => '音频', 'field_class' => 'wechat_message_type'])->create(['name' => 'music', 'title' => '音乐', 'field_class' => 'wechat_message_type'])->create(['name' => 'text', 'title' => '文字', 'field_class' => 'wechat_message_type'])->create(['name' => 'link', 'title' => '连接', 'field_class' => 'wechat_message_type'])->create(['name' => 'location', 'title' => '地址', 'field_class' => 'wechat_message_type'])->create(['name' => 'callback', 'title' => '回调', 'field_class' => 'wechat_message_type'])->create(['name' => 'event', 'title' => '事件', 'field_class' => 'wechat_message_type'])->create(['name' => 'subscribe', 'title' => '关注', 'field_class' => 'wechat_event_type'])->create(['name' => 'unsubscribe', 'title' => '取消关注', 'field_class' => 'wechat_event_type'])->create(['name' => 'SCAN', 'title' => '扫描二维码', 'field_class' => 'wechat_event_type'])->create(['name' => 'LOCATION', 'title' => '地址', 'field_class' => 'wechat_event_type'])->create(['name' => 'CLICK', 'title' => '点击', 'field_class' => 'wechat_event_type'])->create(['name' => 'VIEW', 'title' => '视图', 'field_class' => 'wechat_event_type'])->create(['name' => 'scancode_push', 'title' => '扫描事件', 'field_class' => 'wechat_event_type'])->create(['name' => 'scancode_waitmsg', 'title' => '扫描事件「非跳转」', 'field_class' => 'wechat_event_type'])->create(['name' => 'pic_sysphoto', 'title' => '系统拍照发图', 'field_class' => 'wechat_event_type'])->create(['name' => 'pic_photo_or_album', 'title' => '拍照或者相册发图', 'field_class' => 'wechat_event_type'])->create(['name' => 'pic_weixin', 'title' => '相册发图', 'field_class' => 'wechat_event_type'])->create(['name' => 'location_select', 'title' => '地址选择', 'field_class' => 'wechat_event_type'])->create(['name' => 'XXS', 'title' => '特小号', 'field_class' => 'clothes_size_type'])->create(['name' => 'XS', 'title' => '加小号', 'field_class' => 'clothes_size_type'])->create(['name' => 'S', 'title' => '小号', 'field_class' => 'clothes_size_type'])->create(['name' => 'M', 'title' => '中号', 'field_class' => 'clothes_size_type'])->create(['name' => 'L', 'title' => '大号', 'field_class' => 'clothes_size_type'])->create(['name' => 'XL', 'title' => '加大号', 'field_class' => 'clothes_size_type'])->create(['name' => 'XXL', 'title' => '特大号', 'field_class' => 'clothes_size_type'])->create(['name' => 'XXXL', 'title' => '特特大号', 'field_class' => 'clothes_size_type'])->create(['name' => '27', 'title' => '腰围27', 'field_class' => 'clothes_size_type'])->create(['name' => '28', 'title' => '腰围28', 'field_class' => 'clothes_size_type'])->create(['name' => '29', 'title' => '腰围29', 'field_class' => 'clothes_size_type'])->create(['name' => '30', 'title' => '腰围30', 'field_class' => 'clothes_size_type'])->create(['name' => '31', 'title' => '腰围31', 'field_class' => 'clothes_size_type'])->create(['name' => '32', 'title' => '腰围32', 'field_class' => 'clothes_size_type'])->create(['name' => '33', 'title' => '腰围33', 'field_class' => 'clothes_size_type'])->create(['name' => '34', 'title' => '腰围34', 'field_class' => 'clothes_size_type'])->create(['name' => 'store', 'title' => '自提', 'field_class' => 'express_type'])->create(['name' => 'express', 'title' => '快递', 'field_class' => 'express_type'])->create(['name' => 'sf-express', 'title' => '顺丰快递', 'field_class' => 'express_name'])->create(['name' => 'sto-express', 'title' => '申通快递', 'field_class' => 'express_name'])->create(['name' => 'yto-express', 'title' => '圆通快递', 'field_class' => 'express_name'])->create(['name' => 'zto-express', 'title' => '中通快递', 'field_class' => 'express_name'])->create(['name' => 'ems', 'title' => 'EMS', 'field_class' => 'express_name'])->create(['name' => 'deppon', 'title' => '德邦物流', 'field_class' => 'express_name'])->create(['name' => 'china_bank', 'title' => '中国银行', 'field_class' => 'bank_name'])->create(['name' => 'construction_bank', 'title' => '中国建设银行', 'field_class' => 'bank_name'])->create(['name' => 'ICBC', 'title' => '中国工商银行', 'field_class' => 'bank_name'])->create(['name' => 'BOCOM', 'title' => '交通银行', 'field_class' => 'bank_name'])->create(['name' => 'agricultural_bank', 'title' => '中国农业银行', 'field_class' => 'bank_name'])->create(['name' => 'merchants_bank', 'title' => '招商银行', 'field_class' => 'bank_name'])->create(['name' => 'post_savings_bank', 'title' => '中国邮政储蓄银行', 'field_class' => 'bank_name'])->create(['name' => 'everbright_bank', 'title' => '中国光大银行', 'field_class' => 'bank_name'])->create(['name' => 'minsheng_bank', 'title' => '中国民生银行', 'field_class' => 'bank_name'])->create(['name' => 'pingan_bank', 'title' => '中国平安银行', 'field_class' => 'bank_name'])->create(['name' => 'SPD', 'title' => '浦发银行', 'field_class' => 'bank_name'])->create(['name' => 'CITIC', 'title' => '中信银行', 'field_class' => 'bank_name'])->create(['name' => 'industrial_bank', 'title' => '兴业银行', 'field_class' => 'bank_name'])->create(['name' => 'huaxia_bank', 'title' => '华夏银行', 'field_class' => 'bank_name'])->create(['name' => 'communications_bank', 'title' => '广发银行', 'field_class' => 'bank_name'])->create(['name' => '', 'title' => '无'])->update(['id' => 0]);
     \App\Role::create(['id' => 99, 'name' => 'admin', 'display_name' => '超级管理员', 'url' => 'admin'])->create(['id' => 98, 'name' => 'manager', 'display_name' => '项目总监', 'url' => 'admin'])->create(['id' => 97, 'name' => 'owner', 'display_name' => '经理', 'url' => 'admin'])->create(['id' => 96, 'name' => 'leader', 'display_name' => '负责人', 'url' => 'admin'])->create(['id' => 1, 'name' => 'viewer', 'display_name' => '普通用户', 'url' => ''])->create(['id' => 2, 'name' => 'wechater', 'display_name' => '微信用户', 'url' => ''])->create(['id' => 3, 'name' => 'factory', 'display_name' => '厂商'])->create(['id' => 4, 'name' => 'agent', 'display_name' => '代理商'])->create(['id' => 5, 'name' => 'store', 'display_name' => '门店'])->create(['id' => 0, 'name' => 'guest', 'display_name' => '访客', 'url' => ''])->update(['id' => 0]);
     foreach (['role' => '用户组、权限', 'attachment' => '附件', 'member' => '用户', 'factory' => '厂商', 'agent' => '代理商', 'store' => '门店', 'product' => '产品', 'wechat-account' => '微信公众号', 'wechat-depot' => '微信素材', 'wechat-menu' => '微信菜单', 'wechat-message' => '微信消息', 'wechat-reply' => '微信自定义回复', 'wechat-user' => '微信用户'] as $k => $v) {
         foreach (['view' => '查看', 'create' => '新建', 'edit' => '编辑', 'destroy' => '删除', 'export' => '导出'] as $k1 => $v1) {
             \App\Permission::create(['name' => $k . '.' . $k1, 'display_name' => '允许' . $v1 . $v]);
         }
     }
     \App\Role::find(99)->perms()->sync(\App\Permission::all());
     (new \App\User())->add(['username' => 'admin', 'password' => '123456', 'nickname' => '超级管理员'], \App\Role::ADMIN);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $student = Role::create(['name' => 'student', 'label' => 'Student']);
     $teacher = Role::create(['name' => 'teacher', 'label' => 'Teacher']);
     $add_student = Permission::create(['name' => 'add_student', 'label' => 'Add Student']);
     $remove_student = Permission::create(['name' => 'remove_student', 'label' => 'Remove Student']);
     $view_users = Permission::create(['name' => 'view_users', 'label' => 'View Student']);
     $edit_students_permissions = Permission::create(['name' => 'edit_students_permissions', 'label' => 'Edit Student Permissions']);
     $teacher->givePermission($add_student);
     $teacher->givePermission($remove_student);
     $teacher->givePermission($view_users);
     $teacher->givePermission($edit_students_permissions);
     $student->givePermission($view_users);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $new_permissions = array(array('name' => 'can_edit_newsletter'), array('name' => 'can_add_newsletter'), array('name' => 'can_delete_newsletter'), array('name' => 'can_view_newsletter'));
     $new_permission_ids = array();
     // First add the permissions
     foreach ($new_permissions as $new_permission) {
         $permission = Permission::create($new_permission);
         $new_permission_ids[] = $permission->id;
     }
     // For now we're assigning these new permissions to all of the roles
     $roles = Role::whereIn('name', array('admin', 'manager'))->get();
     foreach ($roles as $role) {
         $role->attachPermissions($new_permission_ids);
     }
 }
 /**
  * Run the database seeds.
  * @return void
  */
 public function run()
 {
     // Insert the default roles
     $role_member = Role::create(["name" => "member", "display_name" => "BTS Member"]);
     $role_committee = Role::create(["name" => "committee", "display_name" => "Committee Member"]);
     $role_associate = Role::create(["name" => "associate", "display_name" => "Associate"]);
     $role_su = Role::create(["name" => "su", "display_name" => "SU Officer"]);
     $role_super = Role::create(["name" => "super_admin", "display_name" => "Super Admin"]);
     // Insert the default permissions
     $permission_member = Permission::create(["name" => "member", "display_name" => "BTS Member"]);
     $permission_admin = Permission::create(["name" => "admin", "display_name" => "Administrator"]);
     // Link roles and permissions
     $permission_member->roles()->saveMany([$role_member, $role_committee, $role_associate]);
     $permission_admin->roles()->saveMany([$role_committee, $role_super]);
 }
 private function createPermission($info)
 {
     if (isset($info['domain'])) {
         $info['domain'] = json_ecode($info['domain']);
     }
     if (isset($info['role'])) {
         $role = Role::where('name', $info['role'])->first();
         if ($role) {
             $info['role_id'] = $role->id;
         }
         unset($info['role']);
     }
     $info = array_merge(['role_id' => 0, 'action' => 'view', 'model' => 'None', 'trickle' => true, 'domain' => '[]'], $info);
     Permission::create($info);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $new_permissions = array(array('name' => 'can_edit_station_data'), array('name' => 'can_add_station_data'), array('name' => 'can_delete_station_data'), array('name' => 'can_view_station_data'));
     $new_permission_ids = array();
     // First add the permissions
     foreach ($new_permissions as $new_permission) {
         $permission = Permission::create($new_permission);
         $new_permission_ids[] = $permission->id;
     }
     // For now we're assigning these new permissions to all of the roles
     $roles = Role::get();
     foreach ($roles as $role) {
         $role->attachPermissions($new_permission_ids);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     User::truncate();
     Role::truncate();
     Permission::truncate();
     DB::table('permission_role')->truncate();
     DB::table('role_user')->truncate();
     $userAdmin = User::create(['name' => 'Admin', 'email' => '*****@*****.**', 'password' => Hash::make('password')]);
     $roleAdmin = Role::create(['name' => 'admin']);
     $roleEditor = Role::create(['name' => 'editor']);
     $roleContributor = Role::create(['name' => 'contributor']);
     $postCreatePermission = Permission::create(['name' => 'post/create']);
     $userAdmin->roles()->sync([$roleAdmin->id, $roleEditor->id, $roleContributor->id]);
     $roleContributor->permissions()->save($postCreatePermission);
 }
 public function run()
 {
     //Permission::truncate();
     //DB::table('permission_role')->truncate();
     $super_admin_role = Role::where('name', '=', 'super-admin')->first();
     $admin_role = Role::where('name', '=', 'admin')->first();
     $user_role = Role::where('name', '=', 'user')->first();
     $read_menu_permission = Permission::create(['name' => 'menu-read', 'label' => 'View Menu Permission']);
     $create_menu_permission = Permission::create(['name' => 'menu-create', 'label' => 'Create Menu Permission']);
     $update_menu_permission = Permission::create(['name' => 'menu-update', 'label' => 'Update Menu Permission']);
     $delete_menu_permission = Permission::create(['name' => 'menu-delete', 'label' => 'Delete Menu Permission']);
     $super_admin_role->permissions()->attach($read_menu_permission);
     $super_admin_role->permissions()->attach($create_menu_permission);
     $super_admin_role->permissions()->attach($update_menu_permission);
     $super_admin_role->permissions()->attach($delete_menu_permission);
     $admin_role->permissions()->attach($read_menu_permission);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     foreach ($this->routes as $route) {
         if (array_search('permission', $route->middleware()) !== false) {
             if (!empty($route->getName())) {
                 $params = explode('.', $route->getName());
                 $data = ['name' => $route->getName()];
                 if (count($params) > 1) {
                     $data['group'] = $params[0];
                 } else {
                     $data['group'] = 'base';
                 }
                 if (!Permission::where('name', $data['name'])->exists()) {
                     Permission::create($data);
                 }
             }
         }
     }
 }
Example #28
0
 public function run()
 {
     $routes = $this->getRouteNamePermissions();
     $roles = [$this->mk('admin', 'Admin', 'Administrator can do everything'), $this->mk('moderator', 'Moderator', 'Moderator is quite powerfull aswell'), $this->mk('user', 'User', 'Regular users are allowed to pay money')];
     $permissions = [];
     foreach ($routes as $route) {
         $permissions[$route['name']] = Permission::create($this->mk($route['name'], 'API Route: ' . $route['name'], $route['action']));
     }
     foreach ($roles as $role) {
         $roles[$role['name']] = Role::create($role);
     }
     $roles['admin']->attachPermissions(array_values($permissions));
     $roles['moderator']->attachPermissions(array_values($permissions));
     factory(App\User::class, 'radic')->create()->attachRole($roles['admin']);
     factory(App\User::class, 'admin', 2)->create()->each(function ($u) use($roles) {
         $u->attachRole($roles['moderator']);
     });
     factory(App\User::class, 40)->create()->each(function ($u) use($roles) {
         $u->attachRole($roles['user']);
     });
 }
Example #29
0
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     DB::table('permission_role')->truncate();
     DB::table('role_user')->truncate();
     DB::table('users')->truncate();
     DB::table('roles')->truncate();
     DB::table('permissions')->truncate();
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     $faker = Faker\Factory::create();
     //User
     $admin = User::create(['email' => '*****@*****.**', 'name' => 'Demo User', 'password' => bcrypt('demo')]);
     //Roles
     $role_admin = Role::create(['name' => 'admin', 'label' => 'Administrador']);
     $role_editor = Role::create(['name' => 'editor', 'label' => 'Editor']);
     $role_user = Role::create(['name' => 'user', 'label' => 'Usuario']);
     //Permission
     $permission_admin_user = Permission::create(['name' => 'admin_user', 'label' => 'Administrar usuarios']);
     //Roles Users
     $admin->roles()->save($role_admin);
     //Roles Users
     $role_admin->givePermissionTo($permission_admin_user);
 }
 /**
  * Run the database seeds.
  * @return void
  */
 public function run()
 {
     // Insert the permissions
     $role_member = Role::where('name', 'member')->first()->id;
     $role_committee = Role::where('name', 'committee')->first()->id;
     $role_associate = Role::where('name', 'associate')->first()->id;
     $role_su = Role::where('name', 'su')->first()->id;
     Permission::create(['name' => 'resources.registered', 'display_name' => 'Registered Users', 'description' => 'All users with an enabled account.'])->roles()->sync([$role_member, $role_committee, $role_associate, $role_su]);
     Permission::create(['name' => 'resources.member', 'display_name' => 'BTS Members', 'description' => 'All backstage members.'])->roles()->sync([$role_member, $role_associate, $role_committee]);
     Permission::create(['name' => 'resources.committee', 'display_name' => 'Committee Only', 'description' => 'Committee members only.'])->roles()->sync([$role_committee]);
     // Insert the default categories
     ResourceCategory::create(['name' => 'Standing Risk Assessments', 'slug' => 'standing-risk-assessments', 'flag' => null]);
     ResourceCategory::create(['name' => 'Standing Method Statements', 'slug' => 'standing-method-statements', 'flag' => null]);
     ResourceCategory::create(['name' => 'Risk Assessments', 'slug' => 'risk-assessments', 'flag' => ResourceCategory::FLAG_RISK_ASSESSMENT]);
     ResourceCategory::create(['name' => 'Event Reports', 'slug' => 'event-reports', 'flag' => ResourceCategory::FLAG_EVENT_REPORT]);
     ResourceCategory::create(['name' => 'Meeting Agendas', 'slug' => 'meeting-agendas', 'flag' => ResourceCategory::FLAG_MEETING_AGENDA]);
     ResourceCategory::create(['name' => 'Meeting Minutes', 'slug' => 'meeting-minutes', 'flag' => ResourceCategory::FLAG_MEETING_MINUTES]);
     ResourceCategory::create(['name' => 'Guides', 'slug' => 'guides', 'flag' => null]);
     ResourceCategory::create(['name' => 'Training Material', 'slug' => 'training', 'flag' => null]);
     // Insert the default tags
     ResourceTag::create(['name' => 'BodySoc', 'slug' => 'bodysoc']);
     ResourceTag::create(['name' => 'BUST', 'slug' => 'bust']);
     ResourceTag::create(['name' => 'BUSMS', 'slug' => 'busms']);
     ResourceTag::create(['name' => 'ICIA', 'slug' => 'icia']);
     ResourceTag::create(['name' => 'Edge', 'slug' => 'edge']);
     ResourceTag::create(['name' => 'Culturals', 'slug' => 'culturals']);
     ResourceTag::create(['name' => 'Off Campus', 'slug' => 'off-campus']);
     ResourceTag::create(['name' => 'On Campus', 'slug' => 'on-campus']);
     ResourceTag::create(['name' => 'External', 'slug' => 'external']);
     ResourceTag::create(['name' => 'Students\' Union', 'slug' => 'students-union']);
     ResourceTag::create(['name' => 'Club Nights', 'slug' => 'club-nights']);
     ResourceTag::create(['name' => 'Coffee House', 'slug' => 'coffee-house']);
     ResourceTag::create(['name' => 'Bars', 'slug' => 'bars']);
     ResourceTag::create(['name' => 'RAG', 'slug' => 'rag']);
     ResourceTag::create(['name' => 'University Hall', 'slug' => 'university-hall']);
     ResourceTag::create(['name' => 'ALT', 'slug' => 'alt']);
     ResourceTag::create(['name' => 'Weston Studio', 'slug' => 'weston-studio']);
     ResourceTag::create(['name' => 'Founders\' Hall', 'slug' => 'founders-hall']);
     ResourceTag::create(['name' => 'Museum of Bath at Work', 'slug' => 'mobaw']);
     ResourceTag::create(['name' => 'Mission Theatre', 'slug' => 'mission-theatre']);
     ResourceTag::create(['name' => 'Assembly Rooms', 'slug' => 'assembly-rooms']);
     ResourceTag::create(['name' => 'Claverton Rooms', 'slug' => 'claverton-rooms']);
     ResourceTag::create(['name' => 'Pump Rooms', 'slug' => 'pump-rooms']);
     ResourceTag::create(['name' => 'Guildhall', 'slug' => 'guildhall']);
     ResourceTag::create(['name' => 'STV', 'slug' => 'stv']);
     ResourceTag::create(['name' => 'Sports Exec', 'slug' => 'sports-exec']);
     ResourceTag::create(['name' => 'The Pavilion', 'slug' => 'pavilion']);
     ResourceTag::create(['name' => 'AGM', 'slug' => 'agm']);
     ResourceTag::create(['name' => 'EGM', 'slug' => 'egm']);
     ResourceTag::create(['name' => 'Crew Meeting', 'slug' => 'crew-meeting']);
     ResourceTag::create(['name' => 'Committee Meeting', 'slug' => 'committee-meeting']);
     ResourceTag::create(['name' => 'Website', 'slug' => 'website']);
     ResourceTag::create(['name' => 'Plug /   Tub', 'slug' => 'plug-tub']);
     ResourceTag::create(['name' => 'SU Level 3', 'slug' => 'level-3']);
     ResourceTag::create(['name' => 'Pyrotechnics', 'slug' => 'pyro']);
     ResourceTag::create(['name' => 'ChaOS', 'slug' => 'chaos']);
     ResourceTag::create(['name' => 'Departmental', 'slug' => 'departmental']);
     ResourceTag::create(['name' => 'BOU', 'slug' => 'bou']);
     ResourceTag::create(['name' => 'BREAK / Elemental', 'slug' => 'break']);
     ResourceTag::create(['name' => 'Election / By-Election', 'slug' => 'election']);
     ResourceTag::create(['name' => 'SU Level 2', 'slug' => 'level-2']);
     ResourceTag::create(['name' => 'Latin & Ballroom', 'slug' => 'bulbs']);
     ResourceTag::create(['name' => 'MusicSoc', 'slug' => 'musicsoc']);
 }