/**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (Auth::check() && $this->rolechucnangs && $this->rolechucnangs->Danhsach == 1) {
         $userid = Auth::user()->id;
         $congviecs = Congviec::join('congviec_users', 'congviecs.id', '=', 'congviec_users.congviec_id')->join('users', 'users.id', '=', 'congviec_users.user_id')->where('congviec_users.user_id', $userid)->orWhere(function ($query) use($userid) {
             $query->where('congviecs.user_created', $userid);
         })->orderBy('congviecs.ngaybatdau', 'desc')->orderBy('congviecs.updated_at', 'desc')->get();
         //dd($congviecs);user_created
         return view('congviec.index')->with(array('congviecs' => $congviecs, 'menus' => $this->menus, 'rolechucnangs' => $this->rolechucnangs));
     } else {
         return \Redirect::to('/')->with('message-error', 'Không có quyền truy cập');
     }
 }
Example #2
0
 public static function getcongviecchuahoanthanh($userid)
 {
     $congviecchuahoanthanhs = Congviec::join('congviec_users', 'congviecs.id', '=', 'congviec_users.congviec_id')->where('congviec_users.user_id', $userid)->where('congviecs.mucdohoanthanh', '<', 100)->get();
     return $congviecchuahoanthanhs;
 }