We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

@njoguamo • 7 years ago

Another great article.

I suggest you integrate your suggestion to this project https://github.com/alexeyme...

Lê Thắng • 2 years ago

Thank you so much for writing this !

Chris • 3 years ago

Is there a guide on the web that shows one example of many-to-many relationships where a table name has *more than one word*?
Thanks njoguamo for linking: https://github.com/alexeyme...

Robin Bastiaan • 3 years ago

Good article! I would like to add that I also post-fix all my classes with the design pattern that they implement. For example, my Jobs would be called UserExportJob, CreateInvoiceJob, ect.

Julián Deve Loper • 3 years ago

On pivot tables case, the last word must be on plural. user_posts. Ain't like that but is how was thought.

ejobity • 4 years ago

Thanks bro

Bilal Haidar • 5 years ago

Great article! What about non-conventional action names? Most of the examples online mention the basic ones (create, delete, etc.) What about adding additional routes, what's the naming convention for that? Thanks

bananas • 5 years ago

You suggest camelCase for relationships, but it appears Laravel Nova expects them to be snake_case.

Of course I can override what Nova uses, but it makes me wonder where the camelCase recommendation comes from.

Taen Ahammed • 6 years ago

great.

Marco Renzi • 6 years ago

Really good article.
But, what if you have a pivot table retailer_company and i need to create a new table for the record status and store that inside a column of this table?

Table name : ratailer_company_status ?

Reference column name inside retailer_company: ratailer_company_status_id ?

Would this be correct?

TutanRamon • 6 years ago

Pivot table should be named in alphabetical order, so in your case 'company_retailer'.
And you can add pivot-attributes to that table, 'status' for instance. In your model "Company":
return $this->belongsToMany('App\Retailer')->withPivot('status');

Matthew Capitao • 6 years ago

what is the recommended naming convention when you have more than one foreign key to the same foreign table? for example in my legacy app i have fk_participation_survey and fk_registration_survey. obviously if there were only one survey i could use survey_id, but what do i do with the second one?

Webdevetc • 6 years ago

registration_survey_id and participation_survey_id would probably be best. It isn’t the end of the world if the fks don’t match up exactly - when doing the belongsTo or hasOne calls, you can define how the relationship works