action = $action; $this->request = $request; $this->model = $employee; $this->function = Str::camel($action); $this->executeAction(); return $this->model; } public function store(Employee $employee, array $request) { $attributes = $request; $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $employee = $employee->create($attributes); return $employee; } public function update(Employee $employee, array $request) { $attributes = $request; $employee->update($attributes); return $employee; } public function destroy(Employee $employee, array $request) { $employee->delete(); return $employee; } public function copy(Employee $employee, array $request) { $count = $request['count'] ?: 1; if ($count == 1) { $employee = $employee->replicate(); $employee->created_at = Carbon::now(); $employee->save(); return $employee; } for ($i = 1; $i <= $count; $i++) { $new = $employee->replicate(); $new->created_at = Carbon::now(); $new->save(); } return $employee; } }