From d2062d244e85e3f66db71e4f508165387a1bfbb6 Mon Sep 17 00:00:00 2001 From: Garrett Mills Date: Fri, 30 Dec 2016 05:27:13 +0000 Subject: [PATCH] updated README and PHPDocs; cleaned up code --- README.md | 18 ++++++++++-------- src/MetaServiceProvider.php | 16 ++++++---------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 8c2ae3b..e91e41f 100644 --- a/README.md +++ b/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. 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 diff --git a/src/MetaServiceProvider.php b/src/MetaServiceProvider.php index c458f57..fba71de 100644 --- a/src/MetaServiceProvider.php +++ b/src/MetaServiceProvider.php @@ -14,13 +14,14 @@ class MetaServiceProvider extends ServiceProvider */ protected $defer = false; + /** + * Register the custom Artisan commands. + */ protected $commands = [ '\Glmdev\Meta\Commands\MetaMigrationCommand', ]; - public function boot(){ - - } + public function boot(){} /** * Register any package services. @@ -29,16 +30,11 @@ class MetaServiceProvider extends ServiceProvider */ public function register() { - // die('gtest2'); - + // alias the Meta class for easy access $loader = \Illuminate\Foundation\AliasLoader::getInstance(); $loader->alias('Meta', 'Glmdev\Meta\Meta'); + // register the Artisan commands $this->commands($this->commands); - - - } - - public static function hello(){return "Hello!";} }