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


PHP Request::user方法代码示例

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


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

示例1: postAdd

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postAdd(Request $request, $product_id)
 {
     $deal = Deal::firstOrCreate(['user_id' => $request->user()->id, 'product_id' => $product_id]);
     $product = \App\Product::find($product_id);
     $request->session()->put("deals.{$product_id}", $product);
     return response()->json(['id' => $product_id, 'mobile' => trans('products.mobile', ['mobile' => $request->user()->mobile]), 'text' => trans_choice('products.deal', $product->deals_count)]);
 }
开发者ID:sotoplatero,项目名称:lacallemonte,代码行数:12,代码来源:DealController.php

示例2: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->user() == null || !$request->user()->is_admin) {
         return redirect()->guest('auth/login');
     }
     return $next($request);
 }
开发者ID:vitorpedrosa,项目名称:gitCodeCommerce,代码行数:14,代码来源:AuthenticateAdmin.php

示例3: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->user() && $request->user()->isAuthor()) {
         return $next($request);
     }
     return redirect("/blog");
 }
开发者ID:ofcadavidm,项目名称:larapp,代码行数:14,代码来源:RedirectIfNotAnAuthor.php

示例4: unfollow

 public function unfollow(Request $request, User $user)
 {
     if ($request->user()->canUnfollow($user)) {
         $request->user()->following()->detach($user);
     }
     return redirect()->back();
 }
开发者ID:stevenjcolwell,项目名称:ControlConnect,代码行数:7,代码来源:UserController.php

示例5: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 403);
         } else {
             return redirect()->guest('auth/login');
         }
     }
     if (!$request->user()->isAdmin() && $request->user()->cannot('dashboard_view')) {
         $this->auth->logout();
         return redirect()->guest('auth/login')->withErrors(trans('messages.permission_denied'));
     }
     $route_array = explode('.', $request->route()->getName());
     $permission_name = array_search($route_array[2], array_dot($this->permission_fields));
     if ($permission_name) {
         $route_array[2] = explode('.', $permission_name)[0];
     }
     // $route_name = implode('_', $route_array);
     $route_name = $route_array[1] . '_' . $route_array[2];
     if (!$request->user()->isAdmin() && $request->user()->cannot($route_name)) {
         //PATCH 为null
         if ($request->ajax()) {
             return response()->json(['status' => trans('messages.permission_denied'), 'type' => 'error', 'code' => 403]);
         } else {
             return view('errors.403');
         }
     }
     return $next($request);
 }
开发者ID:hramose,项目名称:laravel-5-admin,代码行数:37,代码来源:Authenticate.php

示例6: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request->user() || !$request->user()->is_admin) {
         return redirect()->route('home')->with('warning-message', 'You are not authorized to access settings.');
     }
     return $next($request);
 }
开发者ID:ssswang,项目名称:eppo,代码行数:14,代码来源:AdminMiddleware.php

示例7: getIndex

 public function getIndex(Request $request)
 {
     $perpage = 20;
     $user = $request->user();
     $mylogs = $request->user()->mylog()->where('mylog_action', '=', 'login')->orWhere('mylog_action', '=', 'logout')->orderBy('created_at', 'DESC')->paginate($perpage);
     return view('manage.profile.index', ['TITLE' => '个人中心', 'META_KEYWORDS' => META_KEYWORDS, 'META_DESC' => META_DESC, 'PAGE_CODE' => '', 'user' => $user, 'mylogs' => $mylogs]);
 }
开发者ID:verchielxy,项目名称:jiedenuo,代码行数:7,代码来源:ProfileController.php

示例8: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->user() and !$request->user()->subscribed('main')) {
         return redirect('subscribe');
     }
     return $next($request);
 }
开发者ID:scotch-io,项目名称:laravel-cashier-course,代码行数:14,代码来源:Subscribed.php

示例9: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->route('type') == "schede_tecniche" && (!$request->user() || !$request->user()->can("scarica_allegati"))) {
         return redirect()->to('/?login=true');
     }
     return $next($request);
 }
开发者ID:sidis405,项目名称:ibi,代码行数:14,代码来源:SchedeMiddleware.php

示例10: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param $role
  * @return mixed
  */
 public function handle($request, Closure $next, $role = 1)
 {
     /**
      * Account Role
      * ------------
      * 0 -> Member
      * 1 -> Moderator
      * 2 -> Admin
      * 3 -> Super Admin
      * 4 -> Lead Developer
      */
     /**
      * If Tampered role ie not in 0-4
      */
     if ($request->user()->role > 4) {
         return redirect('/')->withNotification("Sorry buddy! You are not authorized for that action.")->withType('warning');
     }
     /**
      * Check for rights and with params if provided.
      */
     if ($request->user()->role < $role) {
         return redirect('/')->withNotification("Sorry buddy! You are not authorized for that action.")->withType('warning');
     }
     return $next($request);
 }
开发者ID:kinnngg-lenz,项目名称:csacerc,代码行数:33,代码来源:Administrator.php

示例11: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->user()->role != 'administrator' && $request->user()->role != 'editor') {
         return redirect('/');
     }
     return $next($request);
 }
开发者ID:yinilauriot,项目名称:StarWars,代码行数:14,代码来源:AdminMiddleware.php

示例12: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->user()->role == 'cliente' or $request->user()->role == 'socio') {
         return $next($request);
     }
     return redirect('/');
 }
开发者ID:alvarokb2,项目名称:SRAC,代码行数:14,代码来源:Cliente.php

示例13: handle

 /**
  * Run the request filter.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string  $role
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->user()->role != 'admin' && $request->user()->role != 'user') {
         return Redirect::action('ClientController@index');
     }
     return $next($request);
 }
开发者ID:spwin,项目名称:controlmystock,代码行数:15,代码来源:AdminMiddleware.php

示例14: store

 public function store(Request $request, $id)
 {
     $orgOrder = OrganizationOrder::findOrFail($id);
     $lineItem = new LineItem();
     $lineItem->organization_order_id = $id;
     if ($request->input('UserOrder') && strlen($request->input('UserOrder')['order']) > 0) {
         if ($request->input('UserOrder')['default'] == 1) {
             UserOrder::where('user_id', '=', $request->user()->id)->where('restaurant_id', '=', $orgOrder->restaurant()->id)->where('default', '=', '1')->update(['default' => 0]);
         }
         $userOrder = new UserOrder();
         $userOrder->fill($request->input('UserOrder'));
         $userOrder->user_id = $request->user()->id;
         $userOrder->restaurant_id = $orgOrder->restaurant()->id;
         $userOrder->save();
         $lineItem->user_order = $userOrder->id;
     } else {
         $lineItem->user_order = $request->input('LineItem')['user_order'];
     }
     if ($lineItem->isValid()) {
         $lineItem->save();
         return redirect()->route('orgorder.show', ['orgId' => $orgOrder->organization()->id, 'id' => $lineItem->organization_order_id]);
     } else {
         return redirect()->route('lineitem.create', ['id' => $id])->withErrors($lineItem->getErrors())->withInput();
     }
 }
开发者ID:searsaw,项目名称:lunch,代码行数:25,代码来源:LineItemController.php

示例15: index

 /**
  * Display a listing of the resource.
  *
  * @param UserRepositoryInterface $userRepository
  * @param ProjectRepositoryInterface $projectRepository
  * @param Request $request
  * @return \Illuminate\Http\Response
  */
 public function index(UserRepositoryInterface $userRepository, ProjectRepositoryInterface $projectRepository, Request $request)
 {
     $projects = $userRepository->drafts($request->user()->id);
     $publishedProjects = $userRepository->published($request->user()->id);
     $failedProjects = $userRepository->failed($request->user()->id);
     return view('user.project.index', compact('projects', 'publishedProjects', 'failedProjects'));
 }
开发者ID:SkysoulDesign,项目名称:TempArk,代码行数:15,代码来源:ProjectController.php


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