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