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