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


PHP User::isAdmin方法代码示例

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


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

示例1: create

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     if ($this->user->isAdmin()) {
         session()->flash('error', 'Admin cannot create new application.');
         return redirect()->route('application');
     }
     return view('app.form');
 }
开发者ID:GreenHackers,项目名称:election-website,代码行数:13,代码来源:ApplicationController.php

示例2: handle

 /**
  * Handle the event.
  *
  * @param  Events  $event
  * @return void
  */
 public function handle(User $user, $remember)
 {
     if ($user->isAdmin()) {
         $this->users->saveLog($user);
     }
     $this->users->updateLog($user);
 }
开发者ID:TahiriAbdou,项目名称:FacebookCloud,代码行数:13,代码来源:AuthLoginEventHandler.php

示例3: edit

 public function edit(User $user, Alumini $alumini)
 {
     if ($user->isAdmin()) {
         return true;
     }
     return $user->id === $alumini->user_id;
 }
开发者ID:kinnngg-lenz,项目名称:csacerc,代码行数:7,代码来源:AluminiPolicy.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (User::isAdmin()) {
         return 'this is the admin page';
     } else {
         return redirect('404');
     }
     return $next($request);
 }
开发者ID:ebrimamaubeh,项目名称:utg_bantaba,代码行数:16,代码来源:test.php

示例5: authorize

 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     $user = new User();
     if ($user->isAdmin()) {
         return true;
     } else {
         return redirect()->to('/');
     }
 }
开发者ID:JolitaGrazyte,项目名称:webdev_examen,代码行数:14,代码来源:PeriodRequest.php

示例6: edit

 public function edit(User $user, CodeWarQuestion $question)
 {
     if ($user->isSuperAdmin()) {
         return true;
     }
     if (!$user->isAdmin()) {
         return false;
     }
     return $question->user_id == $user->id;
 }
开发者ID:kinnngg-lenz,项目名称:csacerc,代码行数:10,代码来源:CodeWarQuestionPolicy.php

示例7: edit

 public function edit(User $user, Quote $quote)
 {
     if ($user->isSuperAdmin()) {
         return true;
     }
     if (!$user->isAdmin()) {
         return false;
     }
     return $quote->user_id == $user->id;
 }
开发者ID:kinnngg-lenz,项目名称:csacerc,代码行数:10,代码来源:QuotePolicy.php

示例8: getIndex

 public function getIndex()
 {
     // ------------------------------------------------------------------------------------------------------------
     // WRITER LIST
     // ------------------------------------------------------------------------------------------------------------
     $writers = User::isAdmin(true)->orderBy('name')->get();
     $writer_list = $writers->lists('name', 'id');
     // ------------------------------------------------------------------------------------------------------------
     // STATUS LIST
     // ------------------------------------------------------------------------------------------------------------
     foreach (Article::statusList() as $status) {
         $status_list[$status] = ucwords($status);
     }
     // ------------------------------------------------------------------------------------------------------------
     // QUERY INDEX
     // ------------------------------------------------------------------------------------------------------------
     $filters = Input::only('title', 'writer', 'status');
     $q = Article::latest();
     // Filter title
     if ($filters['title']) {
         $q = $q->NameLike('*' . $filters['title'] . '*');
     }
     // Filter Status
     if ($filters['status']) {
         switch (strtolower($filters['status'])) {
             case 'published':
                 $q = $q->published();
                 break;
             case 'draft':
                 $q = $q->draft();
                 break;
             case 'upcoming':
                 $q = $q->upcoming();
                 break;
         }
     }
     // Filter Writer
     if ($filters['writer']) {
         $q = $q->WriterById($filters['writer']);
         $filters['writer_name'] = $writers->find($filters['writer'])->name;
     }
     $data = $q->paginate(30);
     // ------------------------------------------------------------------------------------------------------------
     // SHOW DISPLAY
     // ------------------------------------------------------------------------------------------------------------
     $this->layout->page = view($this->page_base_dir . 'index')->with('route_name', $this->route_name)->with('view_name', $this->view_name);
     $this->layout->page->data = $data;
     $this->layout->page->writer_list = $writer_list;
     $this->layout->page->status_list = $status_list;
     $this->layout->page->filters = $filters;
     return $this->layout;
 }
开发者ID:ThunderID,项目名称:capcus.v2,代码行数:52,代码来源:ArticleController.php

示例9: answer

 /**
  * @param User $user
  * @param Question $question
  * @return bool
  */
 public function answer(User $user, Question $question)
 {
     /**
      * If already answered then return false.
      */
     if (!is_null($question->answer)) {
         return false;
     }
     if (!$question->approved) {
         return false;
     }
     /**
      * If question is asked globally then any admin can Answer
      */
     if (is_null($question->for_user_id)) {
         return $user->isAdmin() ? true : false;
     }
     /**
      * If User is Answerer
      */
     return $user->id == $question->for_user_id;
 }
开发者ID:kinnngg-lenz,项目名称:csacerc,代码行数:27,代码来源:QuestionPolicy.php

示例10: changeGroupType

 public function changeGroupType(User $user, Group $group)
 {
     return $user->isAdmin();
 }
开发者ID:philippejadin,项目名称:Mobilizator,代码行数:4,代码来源:GroupPolicy.php

示例11: adminAuthorization

 /**
  * Determine if the given user is admin
  *
  * @param  User  $user
  * @return bool
  */
 public function adminAuthorization(User $user, Problem $problem)
 {
     return $user->isAdmin();
 }
开发者ID:zamppe,项目名称:laravel,代码行数:10,代码来源:ProblemPolicy.php

示例12: getSearchFabrics

 public function getSearchFabrics(Request $request)
 {
     if (Auth::check() && User::isAdmin(Auth::user())) {
         $fabric_name = $request->input("name");
         $fabrics = Fabric::searchFabric($fabric_name);
         return ["result" => true, "msg" => "Fabrics found", "fabrics" => $fabrics];
     } else {
         return ["result" => false, "msg" => "Session not found or permission denied"];
     }
 }
开发者ID:xoscar,项目名称:dnim-inc,代码行数:10,代码来源:FabricsController.php

示例13: getUsersPanel

 public function getUsersPanel()
 {
     $menuOptions = [0 => ["data-letters" => "", "id" => "home", "text" => "Home", "href" => "/"]];
     if (Auth::check()) {
         $data = ["admin" => User::isAdmin(Auth::user())];
         $users = User::where("id", "!=", Auth::user()->id)->where("deleted", "=", 0)->take(4)->get();
         return view("panel.admin-users-panel")->with("data", $data)->with("users", $users);
     } else {
         return redirect("/")->with("menuOptions", $menuOptions);
     }
 }
开发者ID:xoscar,项目名称:dnim-inc,代码行数:11,代码来源:UserController.php

示例14: handleBuyer

 /**
  * @param \App\User $buyer Acheteur qui vient de remporter une enchère
  * @return string
  */
 public function handleBuyer($buyer)
 {
     if (!$buyer->isAdmin() && $buyer->getOnlineBids()->distinct('item_id')->count() === 0 && $buyer->getOnlineItems()->count() === 0) {
         $buyer->delete();
         Mail::send(['emails.buyerDisabledAccount-html', 'emails.buyerDisabledAccount-text'], compact('buyer'), function ($message) use($buyer) {
             $message->to($buyer->email, $buyer->pseudo)->subject('Votre compte a été désactivé (' . $buyer->pseudo . ')');
         });
         return 'Le compte de l\'acheteur ' . $buyer->pseudo . ' a été désactivé.';
     }
 }
开发者ID:Kocal,项目名称:IUT-PHP-Le-Chaudron-Baveur,代码行数:14,代码来源:AdminController.php

示例15: before

 /**
  * @param User $user
  *
  * @return bool
  */
 public function before(User $user, $ability)
 {
     return $user->isAdmin();
 }
开发者ID:Dimimo,项目名称:Booklet,代码行数:9,代码来源:UserDetailPolicy.php


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