Laravel API Best Practice

I am creating an API with laravel 5.1.

I have access to 3 sections: user, administrator, super administrator.

I am interested in the practice of handling the controller. Now I am making 3 different controllers for each section. But sometimes I need to call the same function inside the controller. Eg Product:all().

Should I make 3 different controllers or can I use only 2 controllers for best practice?

+4
source share
1 answer

I would use one controller / one route /api/v1/productswhen the returned dataset is the same for all users (i.e. for the main users, administrators and super admins).

, /- . /api/v1/products , , , .

, , admin/super admin, . / API.

+5

Source: https://habr.com/ru/post/1620456/


All Articles