Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement