public function project_search(Request $request) { $this->setMetadata('Tìm kiếm dự án'); $limit = Config::findByKey('rows_per_page_project')->first()->value; $project_type_id = $request->input('project_type'); $province_id = $request->input('province'); $district_id = $request->input('district'); $ward_id = $request->input('ward'); $street_id = $request->input('street'); $searchDescription = ""; $project_type = null; $province = null; $district = null; $ward = null; $street = null; $query = Project::query(); try { if (isset($project_type_id) && $project_type_id != "") { $query->where('project_type_id', $project_type_id); $project_type = Project_type::findOrFail($project_type_id); $searchDescription .= $project_type->name; } if (isset($province_id) && $province_id != "") { $query->where('province_id', $province_id); $province = Province::findOrFail($province_id); $searchDescription .= ", " . $province->name; } if (isset($district_id) && $district_id != "") { $query->where('district_id', $district_id); $district = District::findOrFail($district_id); $searchDescription .= ", " . $district->name; } if (isset($ward_id) && $ward_id != "") { $query->where('ward_id', $ward_id); $ward = Ward::findOrFail($ward_id); $searchDescription .= ", " . $ward->name; } if (isset($street_id) && $street_id != "") { $query->where('street_id', $street_id); $street = Street::findOrFail($street_id); $searchDescription .= ", " . $street->name; } } catch (Exception $e) { } $projects = $query->paginate($limit); $projectCategory = new ProjectCategory(); $projectsSpecial = $projectCategory->getProjectsByCategoryKey('du-an-noi-bat', 5); $hcmProvince = Province::findByKey('ho-chi-minh')->first(); // dd($hcmProvince->id); $districtProject = District::where('province_id', '=', $hcmProvince->id)->where('is_publish', 1)->orderBy('priority')->orderBy('created_at', 'desc')->get(); return view('frontend.sites1.project_search', ['projects' => $projects, 'projectsSpecial' => $projectsSpecial, 'districtProject' => $districtProject, 'searchDescription' => $searchDescription]); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { DB::transaction(function () use($id) { $user = Auth::user(); $project_type = Project_type::findOrFail($id); $project_type->updated_by = $user->name; $project_type->deleted_by = $user->name; $project_type->key = $project_type->key . '-' . microtime(true); $project_type->save(); // soft delete $project_type->delete(); }); }