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