本文整理汇总了PHP中app\models\Course::whereEmployeeId方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::whereEmployeeId方法的具体用法?PHP Course::whereEmployeeId怎么用?PHP Course::whereEmployeeId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Course
的用法示例。
在下文中一共展示了Course::whereEmployeeId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* Save a model with it's relations.
*
* @param $data
* @param null $id
*
* @return static
*/
public static function save($data, $id = null)
{
if ($id) {
$employee = Employee::findOrFail($id);
$employee->fill($data);
} else {
$employee = Employee::create($data);
}
Address::whereEmployeeId($employee->id)->delete();
// flush
Course::whereEmployeeId($employee->id)->delete();
foreach (array_get($data, 'address', []) as $key => $d) {
if (empty($d['city']) && empty($d['street']) && empty($d['number'])) {
continue;
}
$address = new Address($d);
$address->employee_id = $employee->id;
$address->save();
}
foreach (array_get($data, 'course', []) as $key => $d) {
if (empty($d['title']) && empty($d['start']) && empty($d['end'])) {
continue;
}
$course = new Course($d);
$course->employee_id = $employee->id;
$course->save();
}
$employee->save();
return $employee;
}