public function setupFoundorAndBaseRolsPermission() { // Create Roles $founder = new App\Role(); $founder->name = 'Founder'; $founder->save(); $admin = new App\Role(); $admin->name = 'Admin'; $admin->save(); // Create User $user = App\User::create(['github_id' => 1, 'github_url' => 'goodgoto.com', 'name' => 'summerblue']); // Attach Roles to user $user->roles()->attach($founder->id); // Create Permissions $manageTopics = new App\Permission(); $manageTopics->name = 'manage_topics'; $manageTopics->display_name = 'Manage Topics'; $manageTopics->save(); $manageUsers = new App\Permission(); $manageUsers->name = 'manage_users'; $manageUsers->display_name = 'Manage Users'; $manageUsers->save(); // Assign Permission to Role $founder->perms()->sync([$manageTopics->id, $manageUsers->id]); $admin->perms()->sync([$manageTopics->id]); }
public function store() { $Input = Request::all(); $objUser = \App\User::findOrFail($Input['UserID']); if (!$this->objLoggedInUser->HasPermission("Edit/{$objUser->role}")) { abort('404'); } $objUser->name = Request::get('Name'); $objUser->email = Request::get('Email'); $objUser->company_name = Request::get('CompanyName'); $objUser->role = Request::get('Role'); $objUser->phone = Request::get('Phone'); $objUser->account_number = Request::get('AccountNumber'); $tPermissions = Request::get('Permissions'); $objUser->permissions()->delete(); foreach ((array) $tPermissions as $Permission => $State) { if ($State == 'on') { $NewPermission = new \App\Permission(); $NewPermission->user_id = $objUser->id; $NewPermission->permission = $Permission; $NewPermission->save(); } } $objUser->save(); if (Request::get('Submit') == 'Save') { $Path = $Input['ReturnTo'] == 'Dashboard' ? '' : '/users'; } else { $Path = "/users/edit/{$objUser->id}"; } return redirect("/admin{$Path}")->with('FormResponse', ['ResponseType' => static::MESSAGE_SUCCESS, 'Content' => 'User saved successfully']); }
/** * Run the database seeds. * * @return void */ public function run() { $permissions = [['name' => 'admin_users', 'label' => 'Administrar Usuarios'], ['name' => 'admin_roles', 'label' => 'Administrar Roles']]; foreach ($permissions as $permission) { App\Permission::create($permission); } }
/** * Run the database seeds. * * @return void */ public function run() { // create admin role $roleAdmin = App\Role::create(['name' => 'admin', 'label' => 'Administrador del sistema']); foreach (App\Permission::all() as $permission) { $roleAdmin->grantPermission($permission); } }
/** * Run the database seeds. * * @return void */ public function run() { foreach (Config('predefined.roles-and-perms.Permissions') as $method => $perms) { foreach ($perms as $name => $label) { $permission = new \App\Permission(); switch (is_numeric($name)) { case false: $permission->name = $method . '-' . $name; $permission->label = $label; break; case true: $permission->name = $method . '-' . $label; break; } $permission->created_at = \Carbon\Carbon::now(); $permission->save(); } } }
/** * Run the database seeds. * * @return void */ public function run() { $actions = ['create', 'read', 'update', 'delete']; $entities = ['user', 'profile', 'role', 'permission', 'post']; foreach ($actions as $action) { foreach ($entities as $entity) { App\Permission::create(['name' => $action . '.' . $entity, 'label' => ucfirst($action) . ' ' . ucfirst($entity), 'description' => $action . '.' . $entity . ': Edit Description']); } } }
/** * Run the database seeds. * * @return void */ public function run() { // truncating the permissions table DB::statement('SET FOREIGN_KEY_CHECKS=0;'); DB::table('permissions')->truncate(); DB::statement('SET FOREIGN_KEY_CHECKS=1;'); $scheduleShifts = new App\Permission(); $scheduleShifts->name = 'schedule-shifts'; $scheduleShifts->display_name = 'Schedule Shifts'; // optional // Allow a user to... $scheduleShifts->description = 'can schedule shifts'; // optional $scheduleShifts->save(); $makeShifts = new App\Permission(); $makeShifts->name = 'make-shifts'; $makeShifts->display_name = 'Make Shifts'; // optional // Allow a user to... $makeShifts->description = 'can create shifts'; // optional $makeShifts->save(); }
/** * Run the database seeds. * * @return void */ public function run() { $faker = Faker\Factory::create(); // create role $member = new App\Role(); $member->name = 'member'; $member->display_name = 'Member'; // optional $member->save(); $admin = new App\Role(); $admin->name = 'admin'; $admin->display_name = 'Administrator'; // optional $admin->save(); // create permission $memberPlaylist = new App\Permission(); $memberPlaylist->name = 'member-playlist'; $memberPlaylist->display_name = 'Manage Playlist by Member (self)'; $memberPlaylist->save(); $adminPlaylist = new App\Permission(); $adminPlaylist->name = 'admin-playlist'; $adminPlaylist->display_name = 'Manage Playlist by Admin'; $adminPlaylist->save(); // Assign permisson to role $member->attachPermissions([$memberPlaylist]); $admin->attachPermissions([$adminPlaylist]); // create admin $user = App\User::create(['name' => 'administrator', 'email' => '*****@*****.**', 'password' => bcrypt('password')]); // role attach alias $user->attachRole($admin); // create editor foreach (range(1, 3) as $i) { $user = App\User::create(['name' => $faker->name, 'email' => $faker->email, 'password' => bcrypt('password')]); // role attach alias $user->attachRole($member); } }
/** * Run the database seeds. * * @return void */ public function run() { // DB::statement('SET FOREIGN_KEY_CHECKS=0;'); DB::table('permission_role')->truncate(); DB::statement('SET FOREIGN_KEY_CHECKS=1;'); // Making an manager role $role = App\Role::where('name', '=', 'manager')->first(); $permission = App\Permission::where('name', '=', 'make-shifts')->first(); // role attach alias $role->attachPermission($permission); // parameter can be an Role object, array, or id // Making an caller role $role = App\Role::where('name', '=', 'caller')->first(); $permission = App\Permission::where('name', '=', 'schedule-shifts')->first(); // role attach alias $role->attachPermission($permission); // parameter can be an Role object, array, or id }
/** * Run the database seeds. * * @return void */ public function run() { // Basic roles data App\Role::insert([['name' => 'admin'], ['name' => 'user']]); // Basic permissions data App\Permission::insert([['name' => 'admin.home'], ['name' => 'user.profile'], ['name' => 'user.post'], ['name' => 'user.editpost'], ['name' => 'user.deletepost']]); // Add a permission to a role $role = App\Role::where('name', 'admin')->first(); $role->addPermission('admin.home'); //Add User Permission $user = App\Role::where('name', 'user')->first(); $user->addPermission('user.profile'); $user->addPermission('user.post'); $user->addPermission('user.editpost'); $user->addPermission('user.deletepost'); // Create a user, and give roles $user = App\User::create(['name' => 'Admin Putri', 'email' => '*****@*****.**', 'password' => bcrypt('200895')]); $user->assignRole('admin'); // $this->call(UserTableSeeder::class); }
{!! Form::label($f = 'name', $labels->$f), Form::text($f), Form::label($f = 'description', $labels->$f), Form::text($f) !!} <div id="permissions" class="{{ ($e = $errors->has($f = 'permissions')) ? 'error' : null }}"> {!! Form::label($f, _('Permissions')) !!} <span class="right checkbox_togglers" style="margin-top:-1.5em"> {{ _('Select') }}: <a rel="#permissions" href="all">{{ _('all') }}</a> • <a rel="#permissions" href="none">{{ _('none') }}</a> • <a rel="#permissions" href="invert">{{ _('invert') }}</a> </span> @if($e)<small class="error">{{ $errors->first($f) }}</small>@endif <?php $all = App\Permission::getGroupedByType(); ?> @foreach (App\PermissionType::inUse()->pluck('name', 'id')->all() as $type_id => $type) {!! checkboxes($f, array_map('gettext', $all[$type_id]), $resource->permissions->pluck('id')->all(), ['legend' => _($type)]) !!} @endforeach </div>
<body> <div class ="header"> <nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="{{ url('/') }}">Hệ Thống Tuyển Sinh Đại Học</a> </div> <div > <ul class="nav navbar-nav"> <li><a href="{{ url('/xem-dt') }}">Tra Cứu Điểm Thi</a></li> @if (!Auth::guest()) <?php $pid = App\PermissionUser::where('user_id', Auth::user()->id)->get()->first()->permission_id; $slug = App\Permission::where('id', $pid)->get()->first()->slug; ?> @if($slug == 'student') <li @if(Request::url() === 'your url here')// code @endif><a href="{{ url('/tuyen-sinh') }}"> Tuyển Sinh Đại Học</a></li> @else <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false" href="#">Quản lý <span class="caret"></span></a> <ul class="dropdown-menu"> @if ($slug == 'admin') <li><a href="{{ url('/admin/taoTaiKhoanQuanLyNhanVienCum') }}">tạo tài khoản QLNV cụm</a></li> @elseif ($slug == 'clusterstaffmanager') <li><a href="{{ url('/cluster-staff-manager/taoTaiKhoanNhanVienCum') }}">tạo tài khoản NV cụm</a></li> <li><a href="{{ url('/cluster-staff-manager/taoTaiKhoanNhanVienTruong') }}">tạo tài khoản NV trường</a></li> @elseif ($slug == 'universitystaff')
function checkPermission($route) { $role_id = Auth::user()->role_id; $role_name = \App\Role::find($role_id)->role_name; $current_route = $route; $routes = $role_id . "|" . $current_route; // get all permission $permission = App\Permission::all()->toArray(); $allRoutesInPermission = array(); if (empty($permission)) { $allRoutesInPermission = null; } else { foreach ($permission as $value) { $allRoutesInPermission[] = $value['route']; } } if (in_array($routes, $allRoutesInPermission)) { return true; } else { if ($role_name == "Admin") { return true; } else { if ($current_route == 'admin/dashboard') { return true; } else { return false; } } } }
/** * Run the database seeds. * * @return void */ public function run() { $permission = App\Permission::create(['name' => 'Show Product', 'slug' => 'show-product']); }
public function setupFounderAndBaseRolesPermission() { $founder = new App\Role(); $founder->name = 'founder'; $founder->display_name = 'Project founder'; $founder->description = 'User is the founder of a given project'; $founder->save(); $admin = new App\Role(); $admin->name = 'admin'; $admin->display_name = 'User Administrator'; $admin->description = 'User is allowed to manage and edit other users'; $admin->save(); $user = new App\User(); $user->username = '******'; $user->email = '*****@*****.**'; $user->password = bcrypt('admin'); $user->is_admin = '1'; $user->save(); if (!$user->save()) { Log::info('Unable to create user ' . $user->username, (array) $user->errors()); } else { Log::info('Create user ' . $user->username . '<' . $user->email . '>'); } $user->attachRole($founder); $createPost = new App\Permission(); $createPost->name = 'manage_contents'; $createPost->display_name = 'Manage contents'; $createPost->description = 'Manage site all contents and post'; $createPost->save(); $editUser = new App\Permission(); $editUser->name = "edit_users"; $editUser->display_name = "Edit user"; $editUser->description = "edit user info"; $editUser->save(); $founder->attachPermission($createPost, $editUser); $admin->attachPermission($createPost); }
</div> @if (count($errors) > 0) <div class="alert alert-danger"> <ul> @foreach ($errors->all() as $error) <li>{{ $error }}</li> @endforeach </ul> </div> @endif Nama Role: {!! Form::text('role',null,['class'=>'form-control']) !!}<br/> <?php $prm = App\Permission::all(); ?> @foreach($prm as $pr) <input type="checkbox" name="permission[]" value="{!! $pr->namaPermission !!}">{!! $pr->namaPermission !!}<br/> @endforeach <br> <button type="button" class="btn btn-default" data-dismiss="modal">Batal</button> <button type="submit" class="btn btn-primary">Simpan</button> </div> {!! Form::close() !!} </div> </div> </div> </section>
/** * Run the database seeds. * * @return void */ public function run() { $now = Carbon\Carbon::now(); // Basic permissions data App\Permission::insert([['name' => 'user.create', 'created_at' => $now, 'updated_at' => $now], ['name' => 'user.delete', 'created_at' => $now, 'updated_at' => $now], ['name' => 'user.edit', 'created_at' => $now, 'updated_at' => $now], ['name' => 'quiz.create', 'created_at' => $now, 'updated_at' => $now], ['name' => 'quiz.delete', 'created_at' => $now, 'updated_at' => $now], ['name' => 'quiz.edit', 'created_at' => $now, 'updated_at' => $now], ['name' => 'user.law.create', 'created_at' => $now, 'updated_at' => $now], ['name' => 'user.law.edit', 'created_at' => $now, 'updated_at' => $now], ['name' => 'user.law.delete', 'created_at' => $now, 'updated_at' => $now], ['name' => 'user.healthcare.create', 'created_at' => $now, 'updated_at' => $now], ['name' => 'user.healthcare.edit', 'created_at' => $now, 'updated_at' => $now], ['name' => 'article.create', 'created_at' => $now, 'updated_at' => $now], ['name' => 'article.edit', 'created_at' => $now, 'updated_at' => $now], ['name' => 'article.delete', 'created_at' => $now, 'updated_at' => $now], ['name' => 'facebook.post', 'created_at' => $now, 'updated_at' => $now], ['name' => 'twitter.post', 'created_at' => $now, 'updated_at' => $now]]); }
/** * Run the database seeds. * * @return void */ public function run() { // roles $admin = new \App\Role(); $admin->name = 'admin'; $admin->display_name = 'User Administrator'; $admin->description = 'User is allowed to manage and edit other users'; $admin->save(); $librarian = new \App\Role(); $librarian->name = 'librarian'; $librarian->display_name = 'User Librarian'; $librarian->description = 'User is allowed to manage the library'; $librarian->save(); $employee = new \App\Role(); $employee->name = 'employee'; $employee->display_name = 'User Employee'; $employee->description = 'User is allowed to rent, to reserve and to return the library copies'; $employee->save(); $teacher = new \App\Role(); $teacher->name = 'teacher'; $teacher->display_name = 'User Teacher'; $teacher->description = 'User is allowed to rent, to reserve and to return the library copies'; $teacher->save(); $student = new \App\Role(); $student->name = 'student'; $student->display_name = 'User Student'; $student->description = 'User is allowed to rent, to reserve and to return the library copies'; $student->save(); // permissions $toLoan = new \App\Permission(); $toLoan->name = 'to-loan'; $toLoan->display_name = 'To Loan'; $toLoan->description = 'To loan copies of works for students, teacher and employees'; $toLoan->save(); $librarian->attachPermission($toLoan); $toReserve = new \App\Permission(); $toReserve->name = 'to-reserve'; $toReserve->display_name = 'To Reserve'; $toReserve->description = 'To reserve copies of works for students, teacher and employees'; $toReserve->save(); $librarian->attachPermission($toReserve); $toReturn = new \App\Permission(); $toReturn->name = 'to-return'; $toReturn->display_name = 'To Return'; $toReturn->description = 'To return copies of works for students, teacher and employees'; $toReturn->save(); $librarian->attachPermission($toReturn); $toRenew = new \App\Permission(); $toRenew->name = 'to-renew'; $toRenew->display_name = 'To Renew'; $toRenew->description = 'To renew copies of works for students, teacher and employees'; $toRenew->save(); $librarian->attachPermission($toRenew); $addLibrarian = new \App\Permission(); $addLibrarian->name = 'add-librarian'; $addLibrarian->display_name = 'Add Librarian'; $addLibrarian->description = 'Can add librarian user'; $addLibrarian->save(); $admin->attachPermission($addLibrarian); $addEmployee = new \App\Permission(); $addEmployee->name = 'add-employee'; $addEmployee->display_name = 'Add Employee'; $addEmployee->description = 'Can add employee user'; $addEmployee->save(); $admin->attachPermission($addEmployee); $AddTeacher = new \App\Permission(); $AddTeacher->name = 'add-teacher'; $AddTeacher->display_name = 'Add Teacher'; $AddTeacher->description = 'Can add teacher user'; $AddTeacher->save(); $admin->attachPermission($AddTeacher); $addStudent = new \App\Permission(); $addStudent->name = 'add-student'; $addStudent->display_name = 'Add Student'; $addStudent->description = 'Can add student user'; $addStudent->save(); $admin->attachPermission($addStudent); $librarian->attachPermission($addStudent); $editLibrarian = new \App\Permission(); $editLibrarian->name = 'edit-librarian'; $editLibrarian->display_name = 'Edit Librarian'; $editLibrarian->description = 'Can edit librarian user'; $editLibrarian->save(); $admin->attachPermission($editLibrarian); $editEmployee = new \App\Permission(); $editEmployee->name = 'edit-employee'; $editEmployee->display_name = 'Edit Employee'; $editEmployee->description = 'Can edit employee user'; $editEmployee->save(); $admin->attachPermission($editEmployee); $editTeacher = new \App\Permission(); $editTeacher->name = 'edit-teacher'; $editTeacher->display_name = 'Edit Teacher'; $editTeacher->description = 'Can edit teacher user'; $editTeacher->save(); $admin->attachPermission($editTeacher); $editStudent = new \App\Permission(); $editStudent->name = 'edit-student'; $editStudent->display_name = 'Edit Student'; $editStudent->description = 'Can edit student user'; $editStudent->save(); $admin->attachPermission($editStudent); $librarian->attachPermission($editStudent); $editProfile = new \App\Permission(); $editProfile->name = 'edit-profile'; $editProfile->display_name = 'Edit Profile'; $editProfile->description = 'Can edit your user profile'; $editProfile->save(); $admin->attachPermission($editProfile); $librarian->attachPermission($editProfile); $employee->attachPermission($editProfile); $teacher->attachPermission($editProfile); $student->attachPermission($editProfile); $maxThreeCopies = new \App\Permission(); $maxThreeCopies->name = 'max-three-copies'; $maxThreeCopies->display_name = 'Max Three Copies'; $maxThreeCopies->description = 'Can catch loaned a maximum of three copies'; $maxThreeCopies->save(); $employee->attachPermission($maxThreeCopies); $student->attachPermission($maxThreeCopies); $maxFiveCopies = new \App\Permission(); $maxFiveCopies->name = 'max-five-copies'; $maxFiveCopies->display_name = 'Max Copies Five'; $maxFiveCopies->description = 'Can catch loaned a maximum of five copies'; $maxFiveCopies->save(); $teacher->attachPermission($maxFiveCopies); $maxTenDays = new \App\Permission(); $maxTenDays->name = 'max-ten-days'; $maxTenDays->display_name = 'Max Ten Days'; $maxTenDays->description = 'Can catch loaned by a maximum ten days'; $maxTenDays->save(); $employee->attachPermission($maxTenDays); $student->attachPermission($maxTenDays); $maxFifteenDays = new \App\Permission(); $maxFifteenDays->name = 'max-fifteen-days'; $maxFifteenDays->display_name = 'Max Fifteen Days'; $maxFifteenDays->description = 'Can catch loaned by a maximum fifteen days'; $maxFifteenDays->save(); $teacher->attachPermission($maxFifteenDays); $requestRenewal = new \App\Permission(); $requestRenewal->name = 'request-renewal'; $requestRenewal->display_name = 'Request Renewal'; $requestRenewal->description = 'Can request renewal of copies of works'; $requestRenewal->save(); $employee->attachPermission($requestRenewal); $teacher->attachPermission($requestRenewal); $student->attachPermission($requestRenewal); $requestReserve = new \App\Permission(); $requestReserve->name = 'request-reserve'; $requestReserve->display_name = 'Request Reserve'; $requestReserve->description = 'Can request reserve of works'; $requestReserve->save(); $employee->attachPermission($requestReserve); $teacher->attachPermission($requestReserve); $student->attachPermission($requestReserve); }
/** * Run the database seeds. * * @return void */ public function run() { App\Permission::insert([['id' => 10001, 'name' => 'patient_list', 'label' => 'Patient List'], ['id' => 10002, 'name' => 'doctor_list', 'label' => 'Doctor List'], ['id' => 10003, 'name' => 'broker_list', 'label' => 'Broker List'], ['id' => 20001, 'name' => 'investigate', 'label' => 'Investigate'], ['id' => 20002, 'name' => 'investigation_dues', 'label' => 'Investigation Dues'], ['id' => 20003, 'name' => 'broker_transaction', 'label' => 'Broker Transaction'], ['id' => 30001, 'name' => 'patient_admission', 'label' => 'Patient Admission'], ['id' => 30002, 'name' => 'patient_transaction', 'label' => 'Patient Transaction'], ['id' => 30003, 'name' => 'bed_list', 'label' => 'Bed List']]); }