当前位置: 首页>>代码示例>>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;未经允许,请勿转载。