updated README and PHPDocs; cleaned up code
This commit is contained in:
parent
95f5ba11df
commit
d2062d244e
18
README.md
18
README.md
@ -49,14 +49,14 @@ class Post extends Meta
|
|||||||
The Meta plugin adds a custom Artisan command to auto-generate migrations for meta-enabled models.
|
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:
|
To generate a migration for a new meta-model, use the following command:
|
||||||
|
|
||||||
```
|
``` bash
|
||||||
php artisan meta:migration name_of_migration --create=table_name
|
$ php artisan meta:migration name_of_migration --create=table_name
|
||||||
```
|
```
|
||||||
|
|
||||||
Add your custom fields, if any, then migrate as usual:
|
Add your custom fields, if any, then migrate as usual:
|
||||||
|
|
||||||
```
|
``` bash
|
||||||
php artisan migrate
|
$ php artisan migrate
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, just create a model like usual:
|
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.
|
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:
|
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:
|
Create a new database migration using the custom Meta command:
|
||||||
|
|
||||||
```
|
``` bash
|
||||||
php artisan meta:migration --table=existing_table_name
|
$ php artisan meta:migration --table=existing_table_name
|
||||||
```
|
```
|
||||||
|
|
||||||
Make sure the inside of the `up()` function matches the following:
|
Make sure the inside of the `up()` function matches the following:
|
||||||
@ -115,8 +117,8 @@ public function up()
|
|||||||
|
|
||||||
Then, migrate:
|
Then, migrate:
|
||||||
|
|
||||||
```
|
``` bash
|
||||||
php artisan migrate
|
$ php artisan migrate
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Model Class updates
|
##### Model Class updates
|
||||||
|
@ -14,13 +14,14 @@ class MetaServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
protected $defer = false;
|
protected $defer = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the custom Artisan commands.
|
||||||
|
*/
|
||||||
protected $commands = [
|
protected $commands = [
|
||||||
'\Glmdev\Meta\Commands\MetaMigrationCommand',
|
'\Glmdev\Meta\Commands\MetaMigrationCommand',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function boot(){
|
public function boot(){}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register any package services.
|
* Register any package services.
|
||||||
@ -29,16 +30,11 @@ class MetaServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
// die('gtest2');
|
// alias the Meta class for easy access
|
||||||
|
|
||||||
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
|
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
|
||||||
$loader->alias('Meta', 'Glmdev\Meta\Meta');
|
$loader->alias('Meta', 'Glmdev\Meta\Meta');
|
||||||
|
|
||||||
|
// register the Artisan commands
|
||||||
$this->commands($this->commands);
|
$this->commands($this->commands);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function hello(){return "Hello!";}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user