Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <<<<<<< HEAD
- $salonId = $this->applicationService->getCurrentSalon();
- $id = $request->get('id');
- // $result = DB::select("SELECT u.name,phone,b.id,s.name as service,price,b.status,payment_id,to_char(start_time::date, 'DD,Mon YYYY')as date
- // FROM bookings b left join services s on s.id=b.service_id
- // left join users u on u.id=b.user_id where b.id=? and b.salon_id=?",[$id,$salonId]);
- //
- // return ['book' => $result[0]];
- /** @var Booking $booking */
- $booking = $this->bookingRepository->findWhere(['id' => $id, 'salon_id' => $salonId])->first();
- if (is_null($booking)) {
- return [
- 'Not authorized'
- ];
- }
- $book = [
- 'date' => $booking->start_time->format('h:ma d, M Y'),
- 'id' => $booking->id,
- 'name' => $booking->user ? ($booking->user->name . ' ' . $booking->user->surname) : 'Not found',
- 'phone' => $booking->user ? $booking->user->phone : 'Not found',
- 'service' => $booking->service ? $booking->service->name : 'Not found',
- 'status' => $booking->status,
- 'original_price' => $booking->original_price,
- 'price' => $booking->total_price,
- 'discount' => $booking->is_discount,
- ];
- if ($booking->is_discount && $booking->promo) {
- $book['promo'] = [
- 'code' => $booking->promo->code,
- 'value' => $booking->promo->value,
- 'type' => $booking->promo->type,
- ];
- }
- return [
- 'book' => $book
- ];
- }
- public function store(BookRequest $request)
- {
- $id = $request->get('id');
- $status = $request->get('status');
- $salonId = intval($this->applicationService->getCurrentSalon(), 10);
- $booking = $this->bookingRepository->find($id);
- // dont trust the clients!!!
- if ($booking->salon_id == $salonId &&
- in_array($status, [Booking::SUCCESSFUL, Booking::CANCELED])) {
- // always check params
- $booking->status = $status;
- $booking->save();
- // notify customer & vendor
- $this->dispatch(new BookingStatuses($id, $status, BookingStatuses::ACTION_BY_VENDOR));
- return [
- 'success' => true
- ];
- }
- return [
- 'error' => 'Not authorized.'
- ];
- =======
- return $this->bookingRepository->findWhere(['id' => $request->get('id')])->first();
- >>>>>>> stage
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement