當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Company::userCompanies方法代碼示例

本文整理匯總了PHP中app\Company::userCompanies方法的典型用法代碼示例。如果您正苦於以下問題:PHP Company::userCompanies方法的具體用法?PHP Company::userCompanies怎麽用?PHP Company::userCompanies使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Company的用法示例。


在下文中一共展示了Company::userCompanies方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: search

 public function search()
 {
     //helpers
     $rating_date = mktime(0, 0, 0, date('n', time()), date('j', time()), date('Y', time()));
     //get form select options and quality radio buttons
     $brands = Brand::companyBrands()->get()->lists('name', 'id');
     $residences = Residence::companyResidences()->get()->lists('name', 'id');
     $companies = Company::userCompanies()->get()->lists('name', 'id');
     $companies_ids = Company::userCompanies()->get()->lists('id');
     foreach ($companies_ids as $company_id) {
         $company_ids[] = $company_id;
     }
     $languages = Language::all()->lists('name', 'id');
     array_unshift($languages, "Choose other language");
     $qualities = Qualities::CompanyQualities()->get();
     $inputs = Input::all();
     $employees = Employee::query();
     $employees->whereIn('company_id', $company_ids)->with('company', 'residence', 'phone', 'qualities', 'language')->with(['dates' => function ($query) {
         $query->whereRaw('(? BETWEEN dates.start AND dates.end OR dates.start>?) AND dates.type IN("day_off", "annual_leave")', array(mktime(0, 0, 0, date('n', time()), date('j', time()), date('Y', time())), mktime(0, 0, 0, date('n', time()), date('j', time()), date('Y', time()))));
     }]);
     //dd($inputs);
     if (Input::has('company_id') && is_array($inputs['company_id'])) {
         $employees->whereIn('company_id', $inputs['company_id']);
     }
     if (Input::has('nickname')) {
         $employees->where('nickname', 'like', '%' . $inputs['nickname'] . '%');
     }
     if (Input::has('name')) {
         $employees->where('name', 'like', '%' . $inputs['name'] . '%');
     }
     if (Input::has('brand_id') && is_array($inputs['brand_id'])) {
         $employees->join('brand_employee', 'employees.id', '=', 'brand_employee.employee_id')->whereIn('brand_employee.brand_id', $inputs['brand_id']);
     }
     if (Input::has('residences_id') && is_array($inputs['residences_id'])) {
         $employees->whereIn('residences_id', $inputs['residences_id']);
     }
     if (Input::has('address')) {
         $employees->where('address', 'like', '%' . $inputs['address'] . '%');
     }
     if (Input::has('phone')) {
         $employees->join('phones', 'employees.id', '=', 'phones.employee_id')->where('phones.number', 'like', '%' . $inputs['phone'] . '%');
     }
     if (Input::has('email')) {
         $employees->where('email', 'like', '%' . $inputs['email'] . '%');
     }
     if (Input::has('agreement')) {
         $employees->where('agreement', 'like', '%' . $inputs['agreement'] . '%');
     }
     if (Input::has('no_agreement') && $inputs['agreement'] == '') {
         $employees->where('agreement', '=', '');
     }
     if (Input::has('signed_agreement')) {
         $employees->where('signed_agreement', '=', $inputs['signed_agreement']);
     }
     if (Input::has('working_days')) {
         $all_work = array_fill(0, 7, 0);
         foreach ($inputs['working_days'] as $work_day) {
             $all_work[$work_day] = 1;
         }
         $employees->where('working_days', 'like', implode('', $all_work));
     }
     if (Input::has('start_from')) {
         $employees->where('start_from', '<=', $inputs['start_from']);
     }
     if (Input::has('early_finish')) {
         $employees->where('early_finish', '>=', $inputs['early_finish']);
     }
     if (Input::has('birth_date') && $inputs['birth_date']['from'] != '') {
         $birth_date_start = strtotime($inputs['birth_date']['from']);
         $birth_date_end = strtotime($inputs['birth_date']['to']);
         if ($inputs['birth_date']['to'] == '') {
             $birth_date_end = strtotime($inputs['birth_date']['from']) + 60 * 60 * 24;
         }
         $employees->whereBetween('birth_date', [$birth_date_start, $birth_date_end]);
     }
     if (Input::has('start_date') && $inputs['start_date']['start'] != '') {
         $start_date_start = strtotime($inputs['start_date']['start']);
         $start_date_end = strtotime($inputs['start_date']['end']);
         if ($inputs['start_date']['end'] == '') {
             $start_date_end = $rating_date;
         }
         $employees->whereBetween('start_date', [$start_date_start, $start_date_end]);
     }
     if (Input::has('annual_leave') && $inputs['annual_leave']['start'] != '') {
         $leave_start = strtotime($inputs['annual_leave']['start']);
         $leave_end = strtotime($inputs['annual_leave']['end']);
         if ($inputs['annual_leave']['end'] == '') {
             $leave_end = $leave_start + 60 * 60 * 24;
         }
         $employees->join('dates', 'employees.id', '=', 'dates.employees_id')->where('dates.type', 'like', 'annual_leave')->whereBetween('dates.start', [$leave_start, $leave_end])->orWhere(function ($query) use($leave_start, $leave_end) {
             $query->whereBetween('dates.end', [$leave_start, $leave_end]);
         });
     }
     if (Input::has('day_off') && $inputs['day_off']['start'] != '') {
         $dayoff_start = strtotime($inputs['day_off']['start']);
         $dayoff_end = strtotime($inputs['day_off']['end']);
         if ($inputs['day_off']['end'] == '') {
             $dayoff_end = $dayoff_start + 60 * 60 * 24;
         }
         $employees->join('dates', 'employees.id', '=', 'dates.employees_id')->where('dates.type', 'like', 'day_off')->whereBetween('dates.start', [$dayoff_start, $dayoff_end])->orWhere(function ($query) use($dayoff_start, $dayoff_end) {
//.........這裏部分代碼省略.........
開發者ID:sivanova27,項目名稱:service_laravel,代碼行數:101,代碼來源:SearchController.php


注:本文中的app\Company::userCompanies方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。