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