File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 1+ 'use strict'
2+
3+ const Petshop = use ( 'App/Models/Petshop' ) ;
4+ const Booking = use ( 'App/Models/Booking' ) ;
5+
6+ class QueryServiceController {
7+ async index ( { params} ) {
8+ const petshop = await Petshop . findByOrFail ( 'username' , params . petshop_username ) ;
9+
10+ const services = await petshop . services ( ) . fetch ( ) ;
11+
12+ return services ;
13+ }
14+
15+ async show ( { params} ) {
16+ const bookings = await Booking . query ( ) . where ( 'service_id' , params . id ) . fetch ( )
17+
18+ return bookings ;
19+ }
20+ }
21+
22+ module . exports = QueryServiceController
Original file line number Diff line number Diff line change @@ -32,6 +32,11 @@ Route.group(()=>{
3232 Route . resource ( 'pets' , 'PetController' ) . apiOnly ( ) ;
3333} ) . middleware ( 'auth' ) ;
3434
35+ //QUERY SERVICE
36+ Route . group ( ( ) => {
37+ Route . resource ( ':petshop_username/services' , 'QueryServiceController' ) . only ( [ 'index' , 'show' ] ) ;
38+ } ) . middleware ( 'auth' ) ;
39+
3540//PETSHOP
3641Route . group ( ( ) => {
3742 Route . resource ( 'petshops' , 'PetshopController' ) . apiOnly ( ) ;
@@ -50,4 +55,4 @@ Route.group(()=>{
5055//VET SERVICE
5156Route . group ( ( ) => {
5257 Route . resource ( 'vet/services' , 'VetServiceController' ) . apiOnly ( ) ;
53- } ) . middleware ( 'auth' ) ;
58+ } ) . middleware ( 'auth' ) ;
You can’t perform that action at this time.
0 commit comments