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