@foks A good API starts with well-defined resources. So my advice would be, really think about your models and their attributes and relations before building the API. If you start building the API before you’ve settled on your schema, that means your API is going to be constantly changing, and any integrations are going to be constantly breaking if they’re hitting endpoints that no longer exist, or trying to access attributes that no longer exist or have been renamed.
Once you’re ready to build out your API endpoints, try to stick to Laravel’s conventions:
- Use resource controllers for your models (i.e. a
PostControllerfor aPostmodel) - Place validation in aptly-named form request classes (i.e.
UpdatePostRequest) - Use Eloquent API resources to make the output of your models consistent throughout your API
You should then find that your API is easy to reason about and develop on. Good luck!