|
|
|
@ -49,14 +49,14 @@ class Post extends Meta
|
|
|
|
|
The Meta plugin adds a custom Artisan command to auto-generate migrations for meta-enabled models.
|
|
|
|
|
To generate a migration for a new meta-model, use the following command:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
php artisan meta:migration name_of_migration --create=table_name
|
|
|
|
|
``` bash
|
|
|
|
|
$ php artisan meta:migration name_of_migration --create=table_name
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Add your custom fields, if any, then migrate as usual:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
php artisan migrate
|
|
|
|
|
``` bash
|
|
|
|
|
$ php artisan migrate
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Then, just create a model like usual:
|
|
|
|
@ -69,6 +69,8 @@ public function createPost () {
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
(The `meta:migration` command extends the `make:migration`, so it contains all of the original functionality.)
|
|
|
|
|
|
|
|
|
|
But now, you have access to a universal identifier for every model in the entire project.
|
|
|
|
|
|
|
|
|
|
You can check if a model has a UUID, and get it if it does:
|
|
|
|
@ -98,8 +100,8 @@ To add Meta capabilities to existing models, you need to add the database column
|
|
|
|
|
|
|
|
|
|
Create a new database migration using the custom Meta command:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
php artisan meta:migration --table=existing_table_name
|
|
|
|
|
``` bash
|
|
|
|
|
$ php artisan meta:migration --table=existing_table_name
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Make sure the inside of the `up()` function matches the following:
|
|
|
|
@ -115,8 +117,8 @@ public function up()
|
|
|
|
|
|
|
|
|
|
Then, migrate:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
php artisan migrate
|
|
|
|
|
``` bash
|
|
|
|
|
$ php artisan migrate
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
##### Model Class updates
|
|
|
|
|