當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。