当前位置: 首页>>代码示例>>PHP>>正文


PHP Project::query方法代码示例

本文整理汇总了PHP中app\Project::query方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::query方法的具体用法?PHP Project::query怎么用?PHP Project::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Project的用法示例。


在下文中一共展示了Project::query方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: project_search

 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]);
 }
开发者ID:vankhoektcn,项目名称:Qqsipe2UY67gLO7BWrou,代码行数:52,代码来源:SiteControllers.php

示例2: filterProject

 /**
  * List Priject by Project-type || Province || District || Ward || Street ajax.
  */
 public function filterProject(Request $request)
 {
     $project_type_id = $request->project_type_id;
     $province_id = $request->province_id;
     $district_id = $request->district_id;
     $ward_id = $request->ward_id;
     $street_id = $request->street_id;
     $query = Project::query();
     $query->where('active', 1);
     if (!is_null($project_type_id) && $project_type_id != "") {
         $query->where('project_type_id', $project_type_id);
     }
     if (!is_null($province_id) && $province_id != "") {
         $query->where('province_id', $province_id);
     }
     if (!is_null($district_id) && $district_id != "") {
         $query->where('district_id', $district_id);
     }
     if (!is_null($ward_id) && $ward_id != "") {
         $query->where('ward_id', $ward_id);
     }
     if (!is_null($street_id) && $street_id != "") {
         $query->where('street_id', $street_id);
     }
     $projects = $query->orderBy('priority')->orderBy('created_at', 'desc')->take(20)->get();
     return $projects->toArray();
 }
开发者ID:vankhoektcn,项目名称:Qqsipe2UY67gLO7BWrou,代码行数:30,代码来源:ExtrasController.php


注:本文中的app\Project::query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。