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


PHP Department::whereHas方法代码示例

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


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

示例1: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('units', function (Blueprint $table) {
         //
         $departmentlist = Department::whereHas('programs', function ($q) {
             $q->whereNotIn('programid', array(62, 66, 38, 22));
             $q->where('degreelevel', 'U');
         })->get();
         foreach ($departmentlist as $department) {
             $unitname = $department->unitname;
             if (strpos($unitname, 'Department of') !== false) {
                 $unitname = str_replace("Department of ", "", $unitname);
                 $unitname = substr_replace($unitname, " Department", strlen($unitname), 0);
             }
             $department->unitname = $unitname;
             $department->save(['timestamps' => false]);
         }
         foreach ($departmentlist as $department) {
             $unitname = $department->unitname;
             if (strpos($unitname, ' Department') !== false) {
                 $unitname = str_replace(" Department", "", $unitname);
                 $unitname = substr_replace($unitname, "Department of ", 0, 0);
             }
             $department->unitname = $unitname;
             $department->save(['timestamps' => false]);
         }
     });
 }
开发者ID:jpcamba,项目名称:attrition,代码行数:33,代码来源:2016_04_10_173845_change_some_department-names.php

示例2: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $departmentlist = Department::whereHas('programs', function ($q) {
         $q->whereNotIn('programid', array(62, 66, 38));
         $q->where('degreelevel', 'U');
     })->get();
     $collegelist = [];
     foreach ($departmentlist as $department) {
         array_push($collegelist, $department->college);
     }
     $collegelist = array_unique($collegelist);
     //Average students per program
     $collegeAveArray = [];
     foreach ($collegelist as $college) {
         $unitname = substr_replace($college->unitname, "\n", 11, 0);
         //if colllege of allied medical professsions
         if ($college->unitid === 9) {
             $unitname = substr_replace($college->unitname, "\n", 18, 0);
         }
         $collStudents = round($college->getAveStudents(), 2);
         $collegeAveArray[$unitname] = $collStudents;
         $collAttrition = $college->getAveAttrition();
         $collegeAveAttritionArray[$unitname] = $collAttrition;
     }
     //return page
     return View::make('college.college', ['collegelist' => $collegelist, 'collegeAveArray' => $collegeAveArray, 'collegeAveAttritionArray' => $collegeAveAttritionArray]);
 }
开发者ID:jpcamba,项目名称:attrition,代码行数:32,代码来源:CollegeController.php

示例3: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('units', function (Blueprint $table) {
         $table->decimal('years_before_drop')->nullable();
     });
     //campus
     $campus = Campus::where('unitid', 2)->first();
     $campus->years_before_drop = $campus->getAveYearsBeforeDropout();
     $campus->ave_batch_attrition = $campus->getAveAttrition();
     $campus->save(['timestamps' => false]);
     //program
     $programlist = Program::where('programs.degreelevel', 'U')->whereNotIn('programs.programid', array(62, 66, 38, 22))->get();
     foreach ($programlist as $program) {
         $program->years_stay = $program->getAveYearsOfStay();
         $program->years_before_shift = $program->getAveYearsBeforeShifting();
         $program->years_before_drop = $program->getAveYearsBeforeDropout();
         $program->ave_batch_attrition = $program->getAveAttrition();
         $program->ave_batch_shift = $program->getAveShiftRate();
         $program->ave_students = $program->getAveStudents();
         $program->save(['timestamps' => false]);
     }
     //department
     $departmentlist = Department::whereHas('programs', function ($q) {
         $q->whereNotIn('programid', array(62, 66, 38, 22));
         $q->where('degreelevel', 'U');
     })->get();
     foreach ($departmentlist as $department) {
         $department->ave_batch_attrition = $department->getAveAttrition();
         $department->ave_batch_shift = $department->getAveShiftRate();
         $department->ave_students = $department->getAveStudents();
         $department->save(['timestamps' => false]);
     }
     //college
     $departmentlist = Department::whereHas('programs', function ($q) {
         $q->whereNotIn('programid', array(62, 66, 38, 22));
         $q->where('degreelevel', 'U');
     })->get();
     $collegelist = [];
     foreach ($departmentlist as $department) {
         array_push($collegelist, $department->college);
     }
     $collegelist = array_unique($collegelist);
     foreach ($collegelist as $college) {
         $college->ave_batch_attrition = $college->getAveAttrition();
         $college->ave_batch_shift = $college->getAveShiftRate();
         $college->ave_students = $college->getAveStudents();
         $college->save(['timestamps' => false]);
     }
 }
开发者ID:jpcamba,项目名称:attrition,代码行数:54,代码来源:2016_03_26_150236_add_data_to_campus.php

示例4: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $departmentlist = Department::whereHas('programs', function ($q) {
         $q->whereNotIn('programid', array(62, 66, 38, 22));
         $q->where('degreelevel', 'U');
     })->get();
     $collegelist = [];
     foreach ($departmentlist as $department) {
         array_push($collegelist, $department->college);
     }
     $collegelist = array_unique($collegelist);
     foreach ($collegelist as $college) {
         $college->ave_batch_attrition = $college->getAveAttrition();
         $college->ave_batch_shift = $college->getAveShiftRate();
         $college->ave_students = $college->getAveStudents();
         $college->save(['timestamps' => false]);
     }
 }
开发者ID:jpcamba,项目名称:attrition,代码行数:23,代码来源:2016_03_23_144254_add_college_data_to_units_table.php

示例5: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $departmentlist = Department::whereHas('programs', function ($q) {
         $q->whereNotIn('programid', array(62, 66, 38));
         $q->where('degreelevel', 'U');
     })->get();
     //Averaage students per program
     $departmentAveArray = [];
     $departmentAveAttritionArray = [];
     foreach ($departmentlist as $department) {
         $collStudents = round($department->getAveStudents(), 2);
         $departmentAveArray[$department->unitname] = $collStudents;
         $deptAttrition = $department->getAveAttrition();
         $departmentAveAttritionArray[$department->unitname] = $deptAttrition;
     }
     //return page
     return View::make('department.department', ['departmentlist' => $departmentlist, 'departmentAveArray' => $departmentAveArray, 'departmentAveAttritionArray' => $departmentAveAttritionArray]);
 }
开发者ID:jpcamba,项目名称:attrition,代码行数:23,代码来源:DepartmentController.php

示例6: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('correlations', function (Blueprint $table) {
         //
     });
     $departmentlist = Department::whereHas('programs', function ($q) {
         $q->whereNotIn('programid', array(62, 66, 38));
         $q->where('degreelevel', 'U');
     })->get();
     $collegelist = [];
     $departmentids = [];
     foreach ($departmentlist as $department) {
         array_push($collegelist, $department->college);
         array_push($departmentids, $department->unitid);
     }
     $collegelist = array_unique($collegelist);
     $collegeids = [];
     foreach ($collegelist as $college) {
         array_push($collegeids, $college->unitid);
     }
     $entries = Correlation::where('unittype', 'college')->orWhere('unittype', 'department')->get();
     foreach ($entries as $entry) {
         if ($entry->unittype === 'college') {
             $collegeid = $entry->collegeid;
             if (in_array($collegeid, $collegeids)) {
             } else {
                 $entry->delete();
             }
         } elseif ($entry->unittype === 'department') {
             $departmentid = $entry->departmentid;
             if (in_array($departmentid, $departmentids)) {
             } else {
                 $entry->delete();
             }
         } else {
         }
     }
 }
开发者ID:jpcamba,项目名称:attrition,代码行数:43,代码来源:2016_05_19_094452_clean_departments_colleges_in_correlations_table.php

示例7: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $correlation = [];
     $rawCorrelation = [];
     //Factors dropdown + names
     $factors = Factor::select('factorid', 'factorname')->get();
     $factorNames = [];
     foreach ($factors as $factor) {
         $factorNames[$factor->factorid] = $factor->factorname;
     }
     //Programs dropdown + names
     $programs = Program::select('programtitle', 'programid')->where('degreelevel', 'U')->whereNotIn('programid', array(62, 66, 38, 22))->get();
     $programNames = [];
     foreach ($programs as $program) {
         $programNames[$program->programid] = $program->programtitle;
     }
     //Departments dropdown
     $departments = Department::whereHas('programs', function ($q) {
         $q->whereNotIn('programid', array(62, 66, 38, 22));
         $q->where('degreelevel', 'U');
     })->get();
     $departmentNames = [];
     foreach ($departments as $department) {
         $departmentNames[$department->unitid] = $department->unitname;
     }
     //Colleges dropdown
     $colleges = [];
     $collegeNames = [];
     foreach ($departments as $department) {
         $college = $department->college;
         array_push($colleges, $college);
         $collegeNames[$college->unitid] = $college->unitname;
     }
     $colleges = array_unique($colleges);
     //Campus Level
     $level = 'campus';
     $id = -1;
     $rawCorrelation[$level][$id][1] = $this->corrEmployment($level);
     if ($rawCorrelation[$level][$id][1] < 0) {
         $correlation[$level][$id][1] = -$rawCorrelation[$level][$id][1];
     } else {
         $correlation[$level][$id][1] = $rawCorrelation[$level][$id][1];
     }
     $rawCorrelation[$level][$id][2] = $this->corrGrades($level);
     if ($rawCorrelation[$level][$id][2] < 0) {
         $correlation[$level][$id][2] = -$rawCorrelation[$level][$id][2];
     } else {
         $correlation[$level][$id][2] = $rawCorrelation[$level][$id][2];
     }
     $rawCorrelation[$level][$id][3] = $this->corrStbracket($level);
     if ($rawCorrelation[$level][$id][3] < 0) {
         $correlation[$level][$id][3] = -$rawCorrelation[$level][$id][3];
     } else {
         $correlation[$level][$id][3] = $rawCorrelation[$level][$id][3];
     }
     $rawCorrelation[$level][$id][4] = $this->corrRegion($level);
     if ($rawCorrelation[$level][$id][4] < 0) {
         $correlation[$level][$id][4] = -$rawCorrelation[$level][$id][4];
     } else {
         $correlation[$level][$id][4] = $rawCorrelation[$level][$id][4];
     }
     $rawCorrelation[$level][$id][6] = $this->corrUnits($level);
     if ($rawCorrelation[$level][$id][6] < 0) {
         $correlation[$level][$id][6] = -$rawCorrelation[$level][$id][6];
     } else {
         $correlation[$level][$id][6] = $rawCorrelation[$level][$id][6];
     }
     $rawCorrelation[$level][$id][8] = $this->corrUnemployment($level);
     if ($rawCorrelation[$level][$id][8] < 0) {
         $correlation[$level][$id][8] = -$rawCorrelation[$level][$id][8];
     } else {
         $correlation[$level][$id][8] = $rawCorrelation[$level][$id][8];
     }
     $rawCorrelation[$level][$id][7] = $this->corrHighGrades($level);
     if ($rawCorrelation[$level][$id][7] < 0) {
         $correlation[$level][$id][7] = -$rawCorrelation[$level][$id][7];
     } else {
         $correlation[$level][$id][7] = $rawCorrelation[$level][$id][7];
     }
     $rawCorrelation[$level][$id][9] = $this->corrOverloading($level);
     if ($rawCorrelation[$level][$id][9] < 0) {
         $correlation[$level][$id][9] = -$rawCorrelation[$level][$id][9];
     } else {
         $correlation[$level][$id][9] = $rawCorrelation[$level][$id][9];
     }
     //College Level
     $level = 'college';
     foreach ($colleges as $college) {
         $id = $college->unitid;
         $rawCorrelation[$level][$id][1] = $this->corrEmployment($level, $id);
         if ($rawCorrelation[$level][$id][1] < 0) {
             $correlation[$level][$id][1] = -$rawCorrelation[$level][$id][1];
         } else {
             $correlation[$level][$id][1] = $rawCorrelation[$level][$id][1];
         }
//.........这里部分代码省略.........
开发者ID:jpcamba,项目名称:attrition,代码行数:101,代码来源:CorrelationController.php


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