You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/developers/addons.md
+22-1Lines changed: 22 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,14 @@ Which generates the basic structure in the `/modules` folder. After generating t
23
23
All of the examples below will be based on a module named `Sample`. To see the source for the module, [check it out on GitHub](https://github.com/nabeelio/phpvms-module).
24
24
:::
25
25
26
+
:::tip
27
+
28
+
When naming your module, it is recommended that if your module name runs the risk of being generic, to prefix your module name with a unique identifier. For example, instead of naming your module `Tours`, name it `XXTours` (The XX in the example being the identifier or brand name you choose)
29
+
30
+
In doing this, you reduce the chance of your module name conflicting directly with another module.
31
+
32
+
:::
33
+
26
34
---
27
35
28
36
## Namespacing
@@ -166,6 +174,8 @@ if(Auth::check())
166
174
167
175
# Database Access
168
176
177
+
178
+
169
179
## Models
170
180
Models are the more basic way to access your database tables. For example, if you have a table called `sample_table`, a model called `SampleTable` would make most sense. While table names generally refer to objects in the plural, a model is named for an item in it's singular form.
171
181
@@ -217,6 +227,17 @@ The right relationships make life easier. See the Laravel documentation on relat
217
227
218
228
Laravel includes a way to create and update tables, called [migrations](https://laravel.com/docs/5.5/migrations). Migrations are ways to programmatically define your tables, and let the framework worry about the exact syntax to use. The advantage to this abstraction is being.
219
229
230
+
:::warning
231
+
232
+
When naming your tables, a standard convention that is wise to follow is to prefix your addon's tables with a short indentifier that is unqiue to your addon or group of addons (e.g. `disposable_`, `ch_`, `sp_`, etc.). For example, instead of naming a table `tours`, name it `ch_tours`. This includes pivot tables. See Laravel documentation on how to override the default conventions for table names, foreign relationships, etc. where required.
233
+
234
+
Not prefixing your tables could lead to unintended consequences, including but not limited to:
235
+
236
+
* Conflicting with future phpVMS core features that would use the same table name, thereby making it more difficult to update phpVMS at a later date.
237
+
* Conflicting with other addons by other 3rd party modules that don't head this warning.
238
+
239
+
:::
240
+
220
241
! You should *not* be using raw SQL
221
242
222
243
There is an `artisan` helper to generate migrations:
If you have a polymorphic relationship setup on the Tour model, you can use the operators given via Laravel. See the [Polymorphic Relationship docs](https://laravel.com/docs/11.x/eloquent-relationships#polymorphic-relationships) for more info.
390
+
If you have a polymorphic relationship setup on the Tour model, you can use the operators given via Laravel. See the [Polymorphic Relationship docs](https://laravel.com/docs/11.x/eloquent-relationships#polymorphic-relationships) for more info.
0 commit comments