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