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