/**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $task = Tasks::findOrFail($request->id);
     $settings = Settings::all();
     $isAdmin = Auth()->user()->hasRole('administrator');
     $settingscomplete = $settings[0]['task_assign_allowed'];
     if ($isAdmin) {
         return $next($request);
     }
     if ($settingscomplete == 1 && Auth()->user()->id != $task->fk_user_id_assign) {
         Session()->flash('flash_message_warning', 'Only assigned user are allowed to do this');
         return redirect()->back();
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $lead = Leads::findOrFail($request->id);
     $settings = Settings::all();
     $isAdmin = Auth()->user()->hasRole('administrator');
     $settingscomplete = $settings[0]['lead_assign_allowed'];
     if ($isAdmin) {
         return $next($request);
     }
     if ($settingscomplete == 1 && Auth()->user()->id == $lead->fk_user_id_assign) {
         Session()->flash('flash_message_warning', 'Not allowed to create lead');
         return redirect()->back();
     }
     return $next($request);
 }
示例#3
0
 /**
  * 将数据绑定到视图。
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $currentRoute = Route::currentRouteName();
     //查询分类
     $articleCategory = ArticleCategory::all()->toTree();
     //社区分类
     $communityCategory = CommunityCategory::all()->toTree();
     //查询配置项
     $settings = Settings::all();
     foreach ($settings as $key => $value) {
         $options[$value['name']] = $value['value'];
     }
     //查询登录用户
     $user = Auth::guard('web')->user();
     $view->with('loginUser', $user)->with('currentRoute', $currentRoute)->with('articleCategory', $articleCategory)->with('communityCategory', $communityCategory)->with($options);
 }