/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { if (Auth::check() && $this->rolechucnangs && $this->rolechucnangs->Xoa == 1) { $congviec = Congviec::findOrFail($id); $congviec->delete(); return \Redirect::route('congviec.index')->with('message', 'Xóa thành công'); } else { return \Redirect::route('congviec.index')->with('message-error', 'Không có quyền truy cập'); } }
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; }
public static function getNguoiTraLoiAttribute($id) { $nguoitraloi_id = Congviec::where('id', $id)->value('nguoitraloi_id'); $nguoitraloi = User::where('id', $nguoitraloi_id)->value('name'); return $nguoitraloi; }
/** * Show the application dashboard to the user. * * @return Response */ public function index() { $user = \Auth::user(); $role = Role::findOrFail($user->role_id); $this->menus = $role->danhmuchucnangs()->orderBy('orders')->orderBy('tenchucnang')->get(); $rolechucnangs = RoleChucnang::join('danhmucchucnangs', 'role_chucnangs.danhmucchucnang_id', '=', 'danhmucchucnangs.id')->where('role_id', $role->id)->select('danhmucchucnangs.id', 'role_chucnangs.role_id', 'role_chucnangs.danhmucchucnang_id', 'role_chucnangs.Danhsach', 'role_chucnangs.Xem', 'role_chucnangs.Them', 'role_chucnangs.Sua', 'role_chucnangs.Xoa', 'danhmucchucnangs.tenchucnang', 'danhmucchucnangs.chucnang_id', 'danhmucchucnangs.orders', 'danhmucchucnangs.level')->get(); $userid = $user->id; $phongid = $user->phong_id; $doiid = $user->doi_id; $now_time = time(); // top 10 văn bản đến if ($role->name == 'phong') { $congvandentop10s = Congvanden::where('nguoitao_id', \Auth::user()->id)->whereNull('congvandens.sohosoluubo')->whereNull('congvandens.deleted_at')->orWhereIn('id', function ($query) use($phongid) { $query->select('congvanden_id')->from('congvanden_danhmucphongs')->whereRaw('congvanden_danhmucphongs.danhmucphong_id = ' . $phongid); })->whereNull('congvandens.sohosoluubo')->whereNull('congvandens.deleted_at')->orWhereIn('id', function ($query) use($userid) { $query->select('congvanden_id')->from('congvanden_users')->whereRaw('congvanden_users.user_id = ' . $userid); })->whereNull('congvandens.sohosoluubo')->whereNull('congvandens.deleted_at')->orderBy('sohosoluu', 'desc')->take(10)->get(); } else { if ($role->name == 'doi') { $congvandentop10s = Congvanden::where('nguoitao_id', \Auth::user()->id)->whereNull('congvandens.sohosoluubo')->whereNull('congvandens.deleted_at')->orWhereIn('id', function ($query) use($doiid) { $query->select('congvanden_id')->from('congvanden_danhmucdois')->whereRaw('congvanden_danhmucdois.danhmucdoi_id = ' . $doiid); })->whereNull('congvandens.deleted_at')->whereNull('congvandens.sohosoluubo')->orWhereIn('id', function ($query) use($userid) { $query->select('congvanden_id')->from('congvanden_users')->whereRaw('congvanden_users.user_id = ' . $userid); })->whereNull('congvandens.deleted_at')->whereNull('congvandens.sohosoluubo')->orderBy('sohosoluu', 'desc')->take(10)->get(); } else { if ($role->name == 'canbo') { $congvandentop10s = Congvanden::where('nguoitao_id', \Auth::user()->id)->whereNull('congvandens.sohosoluubo')->whereNull('congvandens.deleted_at')->orWhereIn('id', function ($query) use($userid) { $query->select('congvanden_id')->from('congvanden_users')->whereRaw('congvanden_users.user_id = ' . $userid); })->whereNull('congvandens.deleted_at')->whereNull('congvandens.sohosoluubo')->orderBy('sohosoluu', 'desc')->take(10)->get(); } else { if ($role->name == 'vanthu') { $congvandentop10s = Congvanden::where('phong_id', \Auth::user()->phong_id)->whereNull('congvandens.sohosoluubo')->whereNull('congvandens.deleted_at')->orderBy('congvandens.created_at')->orderBy('sohosoluu', 'desc')->take(10)->get(); } else { if ($role->name == 'admin' || $role->name == 'superadmin') { $congvandentop10s = []; } } } } } // top 10 văn bản đến từ bộ if ($role->name == 'phong') { $congvandenbotop10s = Congvanden::where('nguoitao_id', \Auth::user()->id)->whereNull('congvandens.sohosoluu')->whereNull('congvandens.deleted_at')->orWhereIn('id', function ($query) use($phongid) { $query->select('congvanden_id')->from('congvanden_danhmucphongs')->whereRaw('congvanden_danhmucphongs.danhmucphong_id = ' . $phongid); })->whereNull('congvandens.sohosoluu')->whereNull('congvandens.deleted_at')->orWhereIn('id', function ($query) use($userid) { $query->select('congvanden_id')->from('congvanden_users')->whereRaw('congvanden_users.user_id = ' . $userid); })->whereNull('congvandens.sohosoluu')->whereNull('congvandens.deleted_at')->orderBy('sohosoluubo', 'desc')->take(10)->get(); } else { if ($role->name == 'doi') { $congvandenbotop10s = Congvanden::where('nguoitao_id', \Auth::user()->id)->whereNull('congvandens.sohosoluu')->whereNull('congvandens.deleted_at')->orWhereIn('id', function ($query) use($doiid) { $query->select('congvanden_id')->from('congvanden_danhmucdois')->whereRaw('congvanden_danhmucdois.danhmucdoi_id = ' . $doiid); })->whereNull('congvandens.sohosoluu')->whereNull('congvandens.deleted_at')->orWhereIn('id', function ($query) use($userid) { $query->select('congvanden_id')->from('congvanden_users')->whereRaw('congvanden_users.user_id = ' . $userid); })->whereNull('congvandens.sohosoluu')->whereNull('congvandens.deleted_at')->orderBy('sohosoluubo', 'desc')->take(10)->get(); } else { if ($role->name == 'canbo') { $congvandenbotop10s = Congvanden::where('nguoitao_id', \Auth::user()->id)->whereNull('congvandens.sohosoluu')->whereNull('congvandens.deleted_at')->orWhereIn('id', function ($query) use($userid) { $query->select('congvanden_id')->from('congvanden_users')->whereRaw('congvanden_users.user_id = ' . $userid); })->whereNull('congvandens.sohosoluu')->whereNull('congvandens.deleted_at')->orderBy('sohosoluubo', 'desc')->take(10)->get(); } else { if ($role->name == 'vanthu') { $congvandenbotop10s = Congvanden::where('phong_id', \Auth::user()->phong_id)->whereNull('congvandens.sohosoluu')->whereNull('congvandens.deleted_at')->orderBy('congvandens.created_at')->orderBy('sohosoluubo', 'desc')->take(10)->get(); } else { if ($role->name == 'admin' || $role->name == 'superadmin') { $congvandenbotop10s = []; } } } } } /* $congvandenbotop10s = Congvanden::where('nguoitao_id', \Auth::user()->id) ->whereNull('congvandens.sohosoluu') /* ->orWhereIn('id', (function ($query) use ($doiid) { $query->select('congvanden_id') ->from('congvanden_danhmucdois') ->whereRaw('congvanden_danhmucdois.danhmucdoi_id = ' . $doiid); }) ) ->whereNull('congvandens.deleted_at') */ /* ->orWhereIn('id', (function ($query) use ($userid) { $query->select('congvanden_id') ->from('congvanden_users') ->whereRaw('congvanden_users.user_id = ' . $userid); }) ) ->whereNull('congvandens.deleted_at') ->orderBy('sohosoluu', 'desc') ->take(10)->get(); */ // top 10 công van đi if ($role->name == 'phong') { $congvanditop10s = Congvandi::where('nguoitao_id', \Auth::user()->id)->orWhereIn('id', function ($query) use($phongid) { $query->select('congvandi_id')->from('congvandi_danhmucphongs')->whereRaw('congvandi_danhmucphongs.danhmucphong_id = ' . $phongid); })->whereNull('congvandis.deleted_at')->orWhereIn('id', function ($query) use($userid) { $query->select('congvandi_id')->from('congvandi_users')->whereRaw('congvandi_users.user_id = ' . $userid); })->whereNull('congvandis.deleted_at')->orderBy('socongvandiso', 'desc')->take(10)->get(); } else { if ($role->name == 'doi') { $congvanditop10s = congvandi::where('nguoitao_id', \Auth::user()->id)->orWhereIn('id', function ($query) use($doiid) { $query->select('congvandi_id')->from('congvandi_danhmucdois')->whereRaw('congvandi_danhmucdois.danhmucdoi_id = ' . $doiid); })->whereNull('congvandis.deleted_at')->orWhereIn('id', function ($query) use($userid) { $query->select('congvandi_id')->from('congvandi_users')->whereRaw('congvandi_users.user_id = ' . $userid); })->whereNull('congvandis.deleted_at')->orderBy('socongvandiso', 'desc')->take(10)->get(); } else { if ($role->name == 'canbo') { $congvanditop10s = congvandi::where('nguoitao_id', \Auth::user()->id)->orWhereIn('id', function ($query) use($userid) { $query->select('congvandi_id')->from('congvandi_users')->whereRaw('congvandi_users.user_id = ' . $userid); })->whereNull('congvandis.deleted_at')->orderBy('socongvandiso', 'desc')->take(10)->get(); } else { if ($role->name == 'vanthu') { $congvanditop10s = congvandi::where('phong_id', \Auth::user()->phong_id)->whereNull('congvandis.deleted_at')->orderBy('socongvandiso', 'desc')->take(10)->get(); } else { if ($role->name == 'admin' || $role->name == 'superadmin') { $congvanditop10s = []; } } } } } // top 10 công việc mới nhất $congviectop10s = Congviec::where('user_created', \Auth::user()->id)->orWhereIn('id', function ($query) use($userid) { $query->select('congviec_id')->from('congviec_users')->whereRaw('congviec_users.user_id = ' . $userid); })->whereNull('congviecs.deleted_at')->orderBy('congviecs.created_at', 'desc')->orderBy('congviecs.updated_at', 'desc')->take(10)->get(); return view('home')->with(array('now_time' => $now_time, 'menus' => $this->menus, 'congvandentop10s' => $congvandentop10s, 'congvandenbotop10s' => $congvandenbotop10s, 'congvanditop10s' => $congvanditop10s, 'congviectop10s' => $congviectop10s, 'rolechucnangs' => $rolechucnangs)); }