public static function getNguoiGuiAttribute($id) { $user = User::findOrFail($id); $phong = Danhmucphong::where('id', $user->phong_id)->value('name'); $nguoigui = $user->name . ' - ' . $phong; return $nguoigui; }
public function search(DanhmucphongSearchIndexRequest $query) { $menus = Menu::all(); $querys = $query->input('query'); $danhmucphongs = Danhmucphong::where('name', 'LIKE', '%' . $querys . '%')->orderBy('name')->paginate(10); if ($danhmucphongs == NULL) { $danhmucphongs = 'Không Tìm Thấy'; } return view('danhmucphong.index')->with(array('danhmucphongs' => $danhmucphongs, 'menus' => $this->menus)); }
public function getnoiphathanhid($noiphathanh) { $noiphathanhfind = Danhmucphong::where('id', $noiphathanh)->first(); if ($noiphathanhfind->cap == 'tinh') { $noiphathanh_id = Danhmucdonvi::join('danhmucnhomdonvis', 'danhmucdonvis.danhmucnhomdonvi_id', '=', 'danhmucnhomdonvis.id')->where('danhmucdonvis.id', 17)->where('danhmucdonvis.name', "'{$noiphathanhfind->name}'")->value('danhmucdonvis.id'); } else { if ($capphathanhfind->cap == 'huyen') { $noiphathanh_id = Danhmucdonvi::join('danhmucnhomdonvis', 'danhmucdonvis.danhmucnhomdonvi_id', '=', 'danhmucnhomdonvis.id')->where('danhmucdonvis.id', 3)->where('danhmucdonvis.name', "'{$noiphathanhfind->name}'")->value('danhmucdonvis.id'); } } return $noiphathanh_id; }
public function showdanhsachnoibo($phong) { $phongs = Danhmucphong::where('id', $phong)->get(); $dois = Danhmucdoi::where('danhmucphong_id', $phong)->with('danhmucphong')->get(); $canbos = User::where('phong_id', $phong)->with('phong')->get(); $danhsachnoibos = ['phong' => $phongs, 'dois' => $dois, 'canbos' => $canbos]; return response()->json($danhsachnoibos); }