We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
Thank you so much for writing this !
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...
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.
On pivot tables case, the last word must be on plural. user_posts. Ain't like that but is how was thought.
Thanks bro
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
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.
great.
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?
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');
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?
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
Another great article.
I suggest you integrate your suggestion to this project https://github.com/alexeyme...