TuffRivers
6 months ago
615
1
Laravel

Best Folder Structure for Code Reuse in Multi User laravel App

Posted 6 months ago by TuffRivers

I have clients and admin users in my laravel App web service API, using JWT to authenticate.

They share probably 90 percent of all functions in the application, the differences are clients have route model binding so they can only see their information. Admins have a few other special features that they can do.

I want to avoid as much code duplication as possible. Right now i have all of my CRUD functions outside my controllers nicely. Is my only option to duplicate my controllers into Admin and Client folders, but they can then use the same CRUD files, obviously the controllers will have different functions (for example clients wont have a DELETE function in any of there controllers).

Is this the best way to approach this? Like i said just trying to reduce amount of code duplication as i have quite a few controllers!

Thanks

Please sign in or create an account to participate in this conversation.