September 2017
Intermediate to advanced
244 pages
6h 44m
English
In the Model layer, especially when inheriting from ORM, there are 2 important things:
For just accessing data without writing a query, we can use Query Builder as well. But, relationships advantage is that it comes only with ORM usage. So, let's specify all of the models' relationships.
First of all, let's specify User's relationships. As the user can have many posts and the user can have many comments, the User model will have the hasMany relationship with both Post and Comment models. This is what the User model will look like after specifying the relationship:
<?phpnamespace App;
Read now
Unlock full access