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