PHP code example of mojopollo / laravel-json-schema

1. Go to this page and download the library: Download mojopollo/laravel-json-schema library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mojopollo / laravel-json-schema example snippets


public function register()
{
    if ($this->app->environment() == 'local') {
        $this->app->register('Mojopollo\Schema\MakeMigrationJsonServiceProvider');
        $this->app->register('Laracasts\Generators\GeneratorsServiceProvider');
    }
}
app/Providers/AppServiceProvider.php
bash
php artisan make:migration:json --file=schema.json
bash
Model created successfully.
Migration created successfully.
Model created successfully.
Migration created successfully.
The following files have been created:
  app/CartItem.php
  app/Category.php
  database/migrations/2016_03_13_231727_create_categories_table.php
  database/migrations/2016_03_13_231728_create_tags_table.php
bash
php artisan make:migration:json --file=schema.json --only=categories,tags
json
{
  "posts_tags_pivot": null
}
bash
php artisan make:migration:json --file=schema.json --undo
bash
Deleting files:
  Deleted: app/CartItem.php
  Deleted: app/Category.php
  Deleted: database/migrations/2016_03_13_231727_create_categories_table.php
  Deleted: database/migrations/2016_03_13_231728_create_tags_table.php
bash
php artisan make:migration:json --file=schema.json --disableundo
bash
php artisan make:migration:json --file=schema.json --validate