当前位置: 首页>>代码示例>>PHP>>正文


PHP Permission::find方法代码示例

本文整理汇总了PHP中Permission::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::find方法的具体用法?PHP Permission::find怎么用?PHP Permission::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Permission的用法示例。


在下文中一共展示了Permission::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isAllowed

 /**
  * @param string $path
  * @param array $filters
  *
  * @return bool
  */
 public function isAllowed(string $path, array $filters = []) : bool
 {
     $keys = explode('/', $path);
     $findFilters = [];
     $permissions = $this->permissions;
     foreach ($keys as $key) {
         if ($key == '*') {
             break;
         }
         /** @var Permission $permission */
         $permission = Permission::find($key, Permission::class, $permissions);
         if (!$permission) {
             return false;
         }
         $findFilters = array_merge($findFilters, $permission->getFilters());
         $permissions = $permission->getPermissions();
     }
     if (sizeof($filters)) {
         foreach ($filters as $key => $value) {
             /** @var Filter $filter */
             $filter = Permission::find($key, Filter::class, $findFilters);
             if ($filter) {
                 if (array_search($value, $filter->getFilters()) === false) {
                     return false;
                 }
             }
         }
     }
     return true;
 }
开发者ID:cawaphp,项目名称:acl,代码行数:36,代码来源:PermissionTrait.php

示例2: run

 public function run()
 {
     $admin = Role::find(1);
     $read = Permission::find(1);
     $admin->attachPermission($read);
     $user1 = User::find(1);
     $user1->attachRole($admin);
 }
开发者ID:masiur,项目名称:random,代码行数:8,代码来源:EntrustTableSeeder.php

示例3: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     if (ACL::checkUserPermission('permission.edit') == false) {
         return Redirect::action('dashboard');
     }
     $permissionInfo = Permission::find($id);
     if (!empty($permissionInfo)) {
         $title = Lang::get('Edit Permission');
         $formOpen = Form::open(array('method' => 'post', 'id' => 'form-permission', 'class' => 'smart-form', 'route' => array('permission.update', $id)));
         $formClose = Form::close();
         return View::make('permission/edit', array('formOpen' => $formOpen, 'formClose' => $formClose, 'permissionInfo' => $permissionInfo, 'title' => $title));
     } else {
         $message = 'Cannot find PermissionInfo';
         return Redirect::action('settings.permission')->with('error', $message);
     }
 }
开发者ID:pacificcasinohotel,项目名称:pointsystem,代码行数:22,代码来源:PermissionController.php

示例4: testStore

 public function testStore()
 {
     echo "\n\nPERMISSION CONTROLLER TEST\n\n";
     $this->action('POST', 'PermissionController@store', $this->permissionRolesMapping);
     $permission1 = Permission::find(1);
     $permission2 = Permission::find(2);
     $permission3 = Permission::find(3);
     $role1 = Role::find(1);
     $role2 = Role::find(2);
     $this->assertTrue($permission1->hasRole($role1->name));
     $this->assertTrue($permission2->hasRole($role2->name));
     $this->assertTrue($permission3->hasRole($role2->name));
     $this->assertFalse($permission3->hasRole($role1->name));
     $this->assertFalse($permission1->hasRole($role2->name));
     $this->assertRedirectedToRoute('permission.index');
 }
开发者ID:BaobabHealthTrust,项目名称:iBLIS,代码行数:16,代码来源:PermissionControllerTest.php

示例5: getSingle

 public function getSingle(Request $request)
 {
     $data = $request->all();
     $response = ['errors' => [], 'entry' => null];
     if ($data['id']) {
         $permission = Permission::find($data['id']);
         if ($permission) {
             $response['entry'] = $permission->toArray();
             $response['entry']['roles'] = [];
             foreach ($permission->roles as $role) {
                 array_push($response['entry']['roles'], $role->id);
             }
         }
     }
     return $response;
 }
开发者ID:manogi,项目名称:gfw-qm,代码行数:16,代码来源:PermissionController.php

示例6: updatePermission

 public function updatePermission(Request $request, $id)
 {
     $this->check_auth('edit_all');
     if (!isset($id)) {
         if ($request->id == null) {
             return back()->withInput()->with('status', 'form yang anda kirim tidak melalui prosedur');
         } else {
             $id = $request->id;
         }
     }
     $validator = Validator::make($request->all(), self::validator()['management']['permission']);
     if ($validator->fails()) {
         return back()->withErrors($validator)->withInput();
     } else {
         $perm = Permission::find($id)->update(['name' => strtolower($request->permissionName), 'label' => $request->permissionLabel]);
         return redirect('admin/management')->with('status', 'update Permission Berhasil');
     }
 }
开发者ID:stillAssasin,项目名称:pedulijilbab,代码行数:18,代码来源:ManagementController.php

示例7: edit

 /**
  * Show the form for editing the specified permission.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $permission = Permission::find($id);
     return View::make('permissions.edit', compact('permission'));
 }
开发者ID:ahmedamasha,项目名称:task2,代码行数:11,代码来源:PermissionsController.php

示例8: sort

 public function sort()
 {
     $sort = explode(',', Input::get('sort'));
     if ($sort) {
         foreach ($sort as $key => $id) {
             $permission = Permission::find($id);
             $permission->sort = $key + 1;
             $permission->save();
         }
     }
 }
开发者ID:kettanyam,项目名称:20141001done,代码行数:11,代码来源:PermissionsController.php

示例9: edit

 /**
  * Show the form for editing the specified permission.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $permission = Permission::find($id);
     if (Request::ajax()) {
         return _ajax_denied();
     }
     if (!$permission->canUpdate()) {
         return _access_denied();
     }
     return View::make('permissions.edit', compact('permission'));
 }
开发者ID:k4ml,项目名称:laravel-base,代码行数:17,代码来源:PermissionsController.php

示例10: run

 public function run()
 {
     /* Permissions table */
     $permissions = array(array("name" => "view_names", "display_name" => "Can view patient names"), array("name" => "manage_patients", "display_name" => "Can add patients"), array("name" => "receive_external_test", "display_name" => "Can receive test requests"), array("name" => "request_test", "display_name" => "Can request new test"), array("name" => "accept_test_specimen", "display_name" => "Can accept test specimen"), array("name" => "reject_test_specimen", "display_name" => "Can reject test specimen"), array("name" => "change_test_specimen", "display_name" => "Can change test specimen"), array("name" => "start_test", "display_name" => "Can start tests"), array("name" => "enter_test_results", "display_name" => "Can enter tests results"), array("name" => "edit_test_results", "display_name" => "Can edit test results"), array("name" => "verify_test_results", "display_name" => "Can verify test results"), array("name" => "send_results_to_external_system", "display_name" => "Can send test results to external systems"), array("name" => "refer_specimens", "display_name" => "Can refer specimens"), array("name" => "manage_users", "display_name" => "Can manage users"), array("name" => "manage_test_catalog", "display_name" => "Can manage test catalog"), array("name" => "manage_lab_configurations", "display_name" => "Can manage lab configurations"), array("name" => "view_reports", "display_name" => "Can view reports"));
     foreach ($permissions as $permission) {
         Permission::create($permission);
     }
     $this->command->info('Permissions table seeded');
     /* Roles table */
     $roles = array(array("name" => "Superadmin"), array("name" => "Technologist"), array("name" => "Receptionist"));
     foreach ($roles as $role) {
         Role::create($role);
     }
     $this->command->info('Roles table seeded');
     $role1 = Role::find(1);
     $permissions = Permission::all();
     //Assign all permissions to role administrator
     foreach ($permissions as $permission) {
         $role1->attachPermission($permission);
     }
     //Assign role Administrator to administrators
     User::find(1)->attachRole($role1);
     User::find(8)->attachRole($role1);
     User::find(10)->attachRole($role1);
     $role2 = Role::find(2);
     //Technologist
     //Assign technologist's permissions to role technologist
     $role2->attachPermission(Permission::find(1));
     $role2->attachPermission(Permission::find(2));
     $role2->attachPermission(Permission::find(3));
     $role2->attachPermission(Permission::find(4));
     $role2->attachPermission(Permission::find(5));
     $role2->attachPermission(Permission::find(6));
     $role2->attachPermission(Permission::find(7));
     $role2->attachPermission(Permission::find(8));
     $role2->attachPermission(Permission::find(9));
     $role2->attachPermission(Permission::find(10));
     $role2->attachPermission(Permission::find(11));
     $role2->attachPermission(Permission::find(12));
     $role2->attachPermission(Permission::find(13));
     $role2->attachPermission(Permission::find(17));
     //Assign role Technologist to the other users
     User::find(2)->attachRole($role2);
     User::find(5)->attachRole($role2);
     User::find(12)->attachRole($role2);
     User::find(18)->attachRole($role2);
     User::find(23)->attachRole($role2);
     User::find(24)->attachRole($role2);
     User::find(26)->attachRole($role2);
     User::find(29)->attachRole($role2);
     User::find(43)->attachRole($role2);
     User::find(76)->attachRole($role2);
     User::find(136)->attachRole($role2);
     User::find(159)->attachRole($role2);
     User::find(161)->attachRole($role2);
     User::find(162)->attachRole($role2);
     User::find(163)->attachRole($role2);
     User::find(164)->attachRole($role2);
     /* Instruments table */
     $instrumentsData = array("name" => "Celltac F Mek 8222", "description" => "Automatic analyzer with 22 parameters and WBC 5 part diff Hematology Analyzer", "driver_name" => "KBLIS\\Plugins\\CelltacFMachine", "ip" => "192.168.1.12", "hostname" => "HEMASERVER");
     $instrument = Instrument::create($instrumentsData);
     $instrument->testTypes()->attach(array(176));
     $this->command->info('Instruments table seeded');
 }
开发者ID:BaobabHealthTrust,项目名称:iBLIS,代码行数:64,代码来源:KBLISSeeder.php

示例11: destroy

 /**
  * Remove the specified resource from storage.
  * DELETE /permissions/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $permission = Permission::find($id);
     if ($permission->delete()) {
         return $this->respondNoContent();
     }
     return $this->respondServerError();
 }
开发者ID:SenhorBardell,项目名称:yol,代码行数:15,代码来源:PermissionsController.php

示例12: GetByName

 public static function GetByName($permissionName)
 {
     return Permission::find(array('name' => $permissionName));
 }
开发者ID:krasaler,项目名称:FamilyStore,代码行数:4,代码来源:PermissionService.php

示例13: run

 public function run()
 {
     /* Users table */
     $usersData = array(array("username" => "administrator", "password" => Hash::make("password"), "email" => "admin@kblis.org", "name" => "kBLIS Administrator", "designation" => "Administrator"), array("username" => "external", "password" => Hash::make("password"), "email" => "admin@kblis.org", "name" => "External System User", "designation" => "Administrator", "image" => "/i/users/user-2.jpg"));
     foreach ($usersData as $user) {
         $users[] = User::create($user);
     }
     $this->command->info('users seeded');
     /* Permissions table */
     $permissions = array(array("name" => "view_names", "display_name" => "Can view patient names"), array("name" => "manage_patients", "display_name" => "Can add patients"), array("name" => "receive_external_test", "display_name" => "Can receive test requests"), array("name" => "request_test", "display_name" => "Can request new test"), array("name" => "accept_test_specimen", "display_name" => "Can accept test specimen"), array("name" => "reject_test_specimen", "display_name" => "Can reject test specimen"), array("name" => "change_test_specimen", "display_name" => "Can change test specimen"), array("name" => "start_test", "display_name" => "Can start tests"), array("name" => "enter_test_results", "display_name" => "Can enter tests results"), array("name" => "edit_test_results", "display_name" => "Can edit test results"), array("name" => "verify_test_results", "display_name" => "Can verify test results"), array("name" => "send_results_to_external_system", "display_name" => "Can send test results to external systems"), array("name" => "refer_specimens", "display_name" => "Can refer specimens"), array("name" => "manage_users", "display_name" => "Can manage users"), array("name" => "manage_test_catalog", "display_name" => "Can manage test catalog"), array("name" => "manage_lab_configurations", "display_name" => "Can manage lab configurations"), array("name" => "view_reports", "display_name" => "Can view reports"), array("name" => "manage_inventory", "display_name" => "Can manage inventory"), array("name" => "request_topup", "display_name" => "Can request top-up"), array("name" => "manage_qc", "display_name" => "Can manage Quality Control"));
     foreach ($permissions as $permission) {
         Permission::create($permission);
     }
     $this->command->info('Permissions table seeded');
     /* Roles table */
     $roles = array(array("name" => "Superadmin"), array("name" => "Technologist"), array("name" => "Receptionist"));
     foreach ($roles as $role) {
         Role::create($role);
     }
     $this->command->info('Roles table seeded');
     $role1 = Role::find(1);
     $permissions = Permission::all();
     //Assign all permissions to role administrator
     foreach ($permissions as $permission) {
         $role1->attachPermission($permission);
     }
     //Assign role Administrator to administrators
     User::find(1)->attachRole($role1);
     //User::find(8)->attachRole($role1);
     //User::find(10)->attachRole($role1);
     $role2 = Role::find(2);
     //Technologist
     //Assign technologist's permissions to role technologist
     $role2->attachPermission(Permission::find(1));
     $role2->attachPermission(Permission::find(2));
     $role2->attachPermission(Permission::find(3));
     $role2->attachPermission(Permission::find(4));
     $role2->attachPermission(Permission::find(5));
     $role2->attachPermission(Permission::find(6));
     $role2->attachPermission(Permission::find(7));
     $role2->attachPermission(Permission::find(8));
     $role2->attachPermission(Permission::find(9));
     $role2->attachPermission(Permission::find(10));
     $role2->attachPermission(Permission::find(11));
     $role2->attachPermission(Permission::find(12));
     $role2->attachPermission(Permission::find(13));
     $role2->attachPermission(Permission::find(17));
     //Assign role Technologist to the other users
     User::find(2)->attachRole($role2);
     /* User::find(5)->attachRole($role2);
        User::find(12)->attachRole($role2);
        User::find(18)->attachRole($role2);
        User::find(23)->attachRole($role2);
        User::find(24)->attachRole($role2);
        User::find(26)->attachRole($role2);
        User::find(29)->attachRole($role2);
        User::find(43)->attachRole($role2);
        User::find(76)->attachRole($role2);
        User::find(136)->attachRole($role2);
        User::find(159)->attachRole($role2);
        User::find(161)->attachRole($role2);
        User::find(162)->attachRole($role2);
        User::find(163)->attachRole($role2);
        User::find(164)->attachRole($role2);*/
     /* Instruments table 
        $instrumentsData = array(
            "name" => "Celltac F Mek 8222",
            "description" => "Automatic analyzer with 22 parameters and WBC 5 part diff Hematology Analyzer",
            "driver_name" => "KBLIS\\Plugins\\CelltacFMachine",
            "ip" => "192.168.1.12",
            "hostname" => "HEMASERVER"
        );*/
     //$instrument = Instrument::create($instrumentsData);
     //$instrument->testTypes()->attach(array(176)); XXX ZEEK there is no test type can't attach due to foreign key constraint
     // $this->command->info('Instruments table seeded');
     /* Measure Types */
     $measureTypes = array(array("id" => "1", "name" => "Numeric Range"), array("id" => "2", "name" => "Alphanumeric Values"), array("id" => "3", "name" => "Autocomplete"), array("id" => "4", "name" => "Free Text"));
     foreach ($measureTypes as $measureType) {
         MeasureType::create($measureType);
     }
     $this->command->info('measure_types seeded');
     /* Specimen Status table */
     $specimen_statuses = array(array("id" => "1", "name" => "specimen-not-collected"), array("id" => "2", "name" => "specimen-accepted"), array("id" => "3", "name" => "specimen-rejected"));
     foreach ($specimen_statuses as $specimen_status) {
         SpecimenStatus::create($specimen_status);
     }
     $this->command->info('specimen_statuses seeded');
     /* Rejection Reasons table */
     $rejection_reasons_array = array(array("reason" => "Poorly labelled"), array("reason" => "Over saturation"), array("reason" => "Insufficient Sample"), array("reason" => "Scattered"), array("reason" => "Clotted Blood"), array("reason" => "Two layered spots"), array("reason" => "Serum rings"), array("reason" => "Scratched"), array("reason" => "Haemolysis"), array("reason" => "Spots that cannot elute"), array("reason" => "Leaking"), array("reason" => "Broken Sample Container"), array("reason" => "Mismatched sample and form labelling"), array("reason" => "Missing Labels on container and tracking form"), array("reason" => "Empty Container"), array("reason" => "Samples without tracking forms"), array("reason" => "Poor transport"), array("reason" => "Lipaemic"), array("reason" => "Wrong container/Anticoagulant"), array("reason" => "Request form without samples"), array("reason" => "Missing collection date on specimen / request form."), array("reason" => "Name and signature of requester missing"), array("reason" => "Mismatched information on request form and specimen container."), array("reason" => "Request form contaminated with specimen"), array("reason" => "Duplicate specimen received"), array("reason" => "Delay between specimen collection and arrival in the laboratory"), array("reason" => "Inappropriate specimen packing"), array("reason" => "Inappropriate specimen for the test"), array("reason" => "Inappropriate test for the clinical condition"), array("reason" => "No Label"), array("reason" => "No Sample in the Container"), array("reason" => "No Request Form"), array("reason" => "Missing Information Required"));
     foreach ($rejection_reasons_array as $rejection_reason) {
         $rejection_reasons[] = RejectionReason::create($rejection_reason);
     }
     $this->command->info('rejection_reasons seeded');
     /* Test Phase table */
     $test_phases = array(array("id" => "1", "name" => "Pre-Analytical"), array("id" => "2", "name" => "Analytical"), array("id" => "3", "name" => "Post-Analytical"));
     foreach ($test_phases as $test_phase) {
         TestPhase::create($test_phase);
     }
     $this->command->info('test_phases seeded');
     /* Test Status table */
//.........这里部分代码省略.........
开发者ID:echiteri,项目名称:iBLIS,代码行数:101,代码来源:KBLISSeeder.php

示例14: listMerge

 /**
  * @param array|$this[] $sources
  * @param array|$this[] $merge
  *
  * @return array
  */
 public static function listMerge(array $sources, array $merge) : array
 {
     foreach ($merge as $permission) {
         /** @var Permission $find */
         $find = Permission::find($permission->getKey(), Permission::class, $sources);
         if (!$find) {
             $sources[] = $permission;
         } else {
             $find->merge($permission);
         }
     }
     return $sources;
 }
开发者ID:cawaphp,项目名称:acl,代码行数:19,代码来源:Permission.php

示例15: update

 /**
  * Update the specified resource in storage.
  * PUT /admin.permissions/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     //Buscamos el permiso original, lo poblamos y lo asignamos a la instancia
     $permission = Permission::find($id);
     $permission->fill(Input::all());
     $this->permission = $permission;
     //Si no es posible guardar la instancia mandamos errores
     if (!$this->permission->updateUniques()) {
         return Redirect::back()->withErrors($this->permission->errors());
     }
     //Se han actualizado los valores, expresamos al usuario nuestro gran regocijo al respecto.
     return Redirect::to('admin/permission/' . $this->permission->id . '/edit')->with('success', '¡Se ha actualizado correctamente el permiso: ' . $this->permission->display_name . " !");
 }
开发者ID:ferns24,项目名称:catastro,代码行数:20,代码来源:AdminPermissionsController.php


注:本文中的Permission::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。