getRouteKey(); } public function title() { if ($this->title != '') { return $this->title; } if ($this->name != '') { return $this->name; } return 'None'; } public function toArray($request) { return [ 'id' => $this->getRouteKey(), 'title' => $this->title(), 'slug' => $this->slug, 'ref' => $this->ref, 'user_id' => $this->user_id, 'referred_by' => $this->referred_by, 'company_id' => $this->company_id, 'branch_id' => $this->branch_id, 'department_id' => $this->department_id, 'division_id' => $this->division_id, 'manager_id' => $this->manager_id, 'name' => $this->name, 'martial_status' => $this->martial_status, 'religion' => $this->religion, 'process_step' => $this->process_step, 'employment_history' => $this->employment_history, 'contact_home' => $this->contact_home, 'contact_work' => $this->contact_work, 'contact_emergency' => $this->contact_emergency, 'bank_account' => $this->bank_account, 'contract' => $this->contract, 'current_salary' => $this->current_salary, 'current_salary_date' => $this->current_salary_date, 'prev_salary' => $this->prev_salary, 'probation_period' => $this->probation_period, 'commission_per' => $this->commission_per, 'flexible_com' => $this->flexible_com, 'notes' => $this->notes, 'status' => $this->status, 'employee_updates' => $this->employee_updates, 'week_off' => $this->week_off, 'employee_code' => $this->employee_code, 'terminate_reason' => $this->terminate_reason, 'terminate_date' => $this->terminate_date, 'has_attendance' => $this->has_attendance, 'other_type' => $this->other_type, 'sponsor' => $this->sponsor, 'terminated_type' => $this->terminated_type, 'transfer_date' => $this->transfer_date, 'position_history' => $this->position_history, 'upload_folder' => $this->upload_folder, 'user_type' => $this->user_type, 'created_id' => $this->created_id, 'created_at' => !is_null($this->created_at) ? $this->created_at->format('Y-m-d H:i:s') : null, 'updated_at' => !is_null($this->updated_at) ? $this->updated_at->format('Y-m-d H:i:s') : null, 'meta' => [ 'exists' => $this->exists(), 'link' => $this->itemLink(), 'upload_url' => $this->getUploadURL(''), 'workflow' => $this->workflows(), 'actions' => $this->actions(), ], ]; } /** * Get additional data that should be returned with the resource array. * * @param \Illuminate\Http\Request $request * @return array */ public function with($request) { return [ 'meta' => [ 'exists' => $this->exists(), 'link' => $this->itemLink(), 'upload_url' => $this->getUploadURL(''), 'workflow' => $this->workflows(), 'actions' => $this->actions(), ], ]; } /** * Get the workflows for the resource. * * @return array */ private function workflows() { $arr = []; $workflow = $this->resource->workflow(); foreach ($workflow->transitions($this) as $key => $transition) { $name = $transition->getName(); $arr[$key]['url'] = guard_url('employee/employee/workflow/' . $this->getRouteKey() . '/' . $name); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $workflow->form($transition); $arr[$key]['label'] = trans('employee::employee.workflow.' . $name); } return $arr; } /** * Get the actions for the resource. * * @return array */ private function actions() { $arr = []; $actions = $this->resource->actions()->details(); foreach ($actions as $key => $action) { $name = $action->name(); $arr[$key]['url'] = guard_url('employee/employee//action' . $this->getRouteKey() . '/' . $action->name()); $arr[$key]['name'] = $name; $arr[$key]['key'] = $name; $arr[$key]['form'] = $action->form(); $arr[$key]['label'] = trans('employee::employee.actions.' . $name); } return $arr; } }