kromm77 icon

laravel generator

kromm77 | PRO | 02/27/15 08:43:28 AM UTC | 0 ⭐ | 462 👁️ | Never ⏰ | []
PHP |

1.53 KB

|

None

|

0 👍

/

0 👎

php artisan generate:resource post --fields="title:string, body:text"
 
creates:
app/models/Post.php
app/controllers/PostsController.php
app/database/migrations/timestamp-create_posts_table.php (including the schema)
app/database/seeds/PostsTableSeeder.php
 
 
php artisan generate:migration create_posts_table --fields="title:string, body:text"
 
# -- up
        Schema::create('posts', function(Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->text('body');
            $table->timestamps();
        });
 # -- down 
        Schema::drop('posts');
 
php artisan generate:migration remove_completed_from_tasks_table --fields="completed:boolean"
 
# -- up -- 
        Schema::table('tasks', function(Blueprint $table) {
            $table->dropColumn('completed');
        });
# -- down --
        Schema::table('tasks', function(Blueprint $table) {
            $table->boolean('completed');
        });
 
php artisan generate:pivot orders users
# -- up --
 
      Schema::create('order_user', function(Blueprint $table) {
            $table->increments('id');
            $table->integer('order_id')->unsigned()->index();
            $table->foreign('order_id')->references('id')->on('orders')->onDelete('cascade');
            $table->integer('user_id')->unsigned()->index();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            $table->timestamps();
        });
# --  down --
       Schema::drop('order_user');

Comments