芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/qrafiqxcreativeagency.com/accounts/office/app/Observers/EmployeeDetailsObserver.php
check()) { $detail->last_updated_by = user()->id; } } public function creating(EmployeeDetails $detail) { if (!isRunningInConsoleOrSeeding() && auth()->check()) { $detail->added_by = user()->id; } $detail->company_id = $detail->user->company_id; if (is_null($detail->marital_status)) { $detail->marital_status = 'unmarried'; } } public function created(EmployeeDetails $detail) { $leaveTypes = $detail->company->leaveTypes; $settings = company(); $countOfMonthsAllowed = 12; if ($settings && $settings->leaves_start_from == 'year_start') { $joiningDate = $detail->joining_date->copy()->addDay()->startOfMonth(); $startingDate = Carbon::create($joiningDate->year + 1, $settings->year_starts_from)->startOfMonth(); $differenceMonth = $joiningDate->diffInMonths($startingDate); $countOfMonthsAllowed = $differenceMonth > 12 ? $differenceMonth - 12 : $differenceMonth; } foreach ($leaveTypes as $value) { $leaves = ($settings && $settings->leaves_start_from == 'year_start') ? floor($value->no_of_leaves / 12 * $countOfMonthsAllowed) : $value->no_of_leaves; EmployeeLeaveQuota::create( [ 'user_id' => $detail->user_id, 'leave_type_id' => $value->id, 'no_of_leaves' => $leaves, ] ); } } }