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