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


PHP Facades\Gate类代码示例

本文整理汇总了PHP中Illuminate\Support\Facades\Gate的典型用法代码示例。如果您正苦于以下问题:PHP Gate类的具体用法?PHP Gate怎么用?PHP Gate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: create

 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     if (Gate::denies('addClient', new Client())) {
         abort(403, 'Not allowed');
     }
     return View::make('client.create');
 }
开发者ID:shirishmore,项目名称:timesheet,代码行数:12,代码来源:ClientController.php

示例2: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Gate::denies('contributor')) {
         abort(403);
     }
     return $next($request);
 }
开发者ID:vladzur,项目名称:werken,代码行数:14,代码来源:VerifyContributor.php

示例3: boot

 /**
  * Register any authentication / authorization services.
  *
  * @return void
  */
 public function boot()
 {
     $this->registerPolicies();
     Gate::define('administer', function (User $user) {
         return $user->roles->contains('name', 'admin');
     });
 }
开发者ID:hughgrigg,项目名称:ching-shop,代码行数:12,代码来源:AuthServiceProvider.php

示例4: update

 /**
  * updates activity sector
  * @param                      $id
  * @param Request              $request
  * @param SectorRequestManager $sectorRequestManager
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update($id, Request $request, SectorRequestManager $sectorRequestManager)
 {
     $activityData = $this->activityManager->getActivityData($id);
     if (Gate::denies('ownership', $activityData)) {
         return redirect()->back()->withResponse($this->getNoPrivilegesMessage());
     }
     $this->authorizeByRequestType($activityData, 'sector');
     $sectors = $request->all();
     foreach ($sectors['sector'] as &$sector) {
         if ($sector['sector_vocabulary'] == 1 || $sector['sector_vocabulary'] == '') {
             $sector['sector_vocabulary'] = 1;
             $sector['sector_category_code'] = '';
             $sector['sector_text'] = '';
         } elseif ($sector['sector_vocabulary'] == 2) {
             $sector['sector_code'] = '';
             $sector['sector_text'] = '';
         } else {
             $sector['sector_code'] = '';
             $sector['sector_category_code'] = '';
         }
     }
     if ($this->sectorManager->update($sectors, $activityData)) {
         $this->activityManager->resetActivityWorkflow($id);
         $response = ['type' => 'success', 'code' => ['updated', ['name' => 'Sector']]];
         return redirect()->to(sprintf('/activity/%s', $id))->withResponse($response);
     }
     $response = ['type' => 'danger', 'code' => ['update_failed', ['name' => 'Sector']]];
     return redirect()->back()->withInput()->withResponse($response);
 }
开发者ID:younginnovations,项目名称:aidstream,代码行数:36,代码来源:SectorController.php

示例5: destroy

 /**
  * @param $id
  * @return int
  */
 public function destroy($id)
 {
     if (Gate::denies('manage-users')) {
         abort(403, 'You dont have permissions!!');
     }
     return (int) $this->usersRepo->delete($this->usersRepo->byId($id));
 }
开发者ID:burimshala,项目名称:todoozer,代码行数:11,代码来源:UsersController.php

示例6: destroy

 public function destroy($id)
 {
     if (Gate::denies('managerOnly')) {
         abort(403);
     }
     return Group::destroy($id);
 }
开发者ID:ppawlas,项目名称:swop,代码行数:7,代码来源:GroupController.php

示例7: update

 /**
  * updates activity recipient region
  * @param                               $id
  * @param Request                       $request
  * @param RecipientRegionRequestManager $recipientRegionRequestManager
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update($id, Request $request, RecipientRegionRequestManager $recipientRegionRequestManager)
 {
     $activityData = $this->activityManager->getActivityData($id);
     if (Gate::denies('ownership', $activityData)) {
         return redirect()->back()->withResponse($this->getNoPrivilegesMessage());
     }
     $this->authorizeByRequestType($activityData, 'recipient_region');
     $activityTransactions = $this->transactionManager->getTransactions($id);
     $count = 0;
     if ($activityTransactions) {
         foreach ($activityTransactions as $transactions) {
             $transactionDetail = $transactions->transaction;
             removeEmptyValues($transactionDetail);
             if (!empty($transactionDetail['recipient_country']) || !empty($transactionDetail['recipient_region'])) {
                 $count++;
             }
         }
     }
     if ($count > 0) {
         $response = ['type' => 'warning', 'code' => ['message', ['message' => 'You cannot save Recipient Region in activity level because you have already saved recipient country or region in transaction level.']]];
         return redirect()->back()->withInput()->withResponse($response);
     }
     $recipientRegions = $request->all();
     foreach ($recipientRegions['recipient_region'] as &$recipientRegion) {
         $recipientRegion['region_vocabulary'] != '' ?: ($recipientRegion['region_vocabulary'] = '1');
     }
     if ($this->recipientRegionManager->update($recipientRegions, $activityData)) {
         $this->activityManager->resetActivityWorkflow($id);
         $response = ['type' => 'success', 'code' => ['updated', ['name' => 'Recipient Region']]];
         return redirect()->to(sprintf('/activity/%s', $id))->withResponse($response);
     }
     $response = ['type' => 'danger', 'code' => ['update_failed', ['name' => 'Recipient Region']]];
     return redirect()->back()->withInput()->withResponse($response);
 }
开发者ID:younginnovations,项目名称:aidstream,代码行数:41,代码来源:RecipientRegionController.php

示例8: destroy

 public function destroy($id)
 {
     if (Gate::denies('adminOnly')) {
         abort(403);
     }
     return Organization::destroy($id);
 }
开发者ID:ppawlas,项目名称:swop,代码行数:7,代码来源:OrganizationController.php

示例9: __construct

 /**
  * Create a new controller instance.
  * @internal param ReflectionClass $reflect
  */
 public function __construct()
 {
     if (get_sparkplug_config('ACL')) {
         if (Gate::denies(get_module_class_name($this))) {
             abort('403', 'User has no privilages to access this page');
         }
     }
 }
开发者ID:karthik1407s,项目名称:sparkplug,代码行数:12,代码来源:CoreController.php

示例10: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Gate::denies('authorization', $request->route()[1]['uses'])) {
         abort(403);
     } else {
         return $next($request);
     }
 }
开发者ID:marcocastignoli,项目名称:lumen_auth,代码行数:15,代码来源:Authorize.php

示例11: show

 /**
  * Show Dashboard.
  *
  * @return mixed
  */
 public function show()
 {
     $content = Content::newPostInstance();
     if (Gate::denies('create', $content)) {
         return view('orchestra/story::admin.home');
     }
     return $this->writePost($content);
 }
开发者ID:dinghua,项目名称:crm,代码行数:13,代码来源:HomeController.php

示例12: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $post = Post::findOrFail($id);
     if (Gate::denies('update', $post)) {
         abort(403, 'no fucking way bitch');
     }
     return $post->title;
 }
开发者ID:gitter-badger,项目名称:nxpanel,代码行数:14,代码来源:PostController.php

示例13: update

 public function update(Request $request, PersonModel $person)
 {
     $person->setName($request->input('name'))->setEnabled($request->has('enabled'));
     if (Gate::allows('editSuperuser', $person)) {
         $person->setSuperuser($request->has('superuser'));
     }
     PersonFacade::save($person);
 }
开发者ID:boomcms,项目名称:boom-core,代码行数:8,代码来源:Person.php

示例14: managerIndex

 public function managerIndex()
 {
     if (Gate::denies('managerOnly')) {
         abort(403);
     }
     // Retrieve all the users defined for the organization of the currently authenticated manager
     return Auth::user()->organization->users;
 }
开发者ID:ppawlas,项目名称:swop,代码行数:8,代码来源:UserController.php

示例15: coverStore

 public function coverStore(Request $request, $id)
 {
     $book = Book::find($id);
     if (Gate::denies('manageBook', $book)) {
         abort(403, 'voce não é o dono desse livro');
     }
     $bookService = app()->make(BookService::class);
     $bookService->storeCover($book, $request->file('file'));
 }
开发者ID:phelipperibeiro,项目名称:book_store_laravel,代码行数:9,代码来源:BooksController.php


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