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