Advertisement
kromm77

laravel generator

Feb 27th, 2015
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.53 KB | None | 0 0
  1. php artisan generate:resource post --fields="title:string, body:text"
  2.  
  3. creates:
  4. app/models/Post.php
  5. app/controllers/PostsController.php
  6. app/database/migrations/timestamp-create_posts_table.php (including the schema)
  7. app/database/seeds/PostsTableSeeder.php
  8.  
  9.  
  10. php artisan generate:migration create_posts_table --fields="title:string, body:text"
  11.  
  12. # -- up
  13.        Schema::create('posts', function(Blueprint $table) {
  14.             $table->increments('id');
  15.             $table->string('title');
  16.             $table->text('body');
  17.             $table->timestamps();
  18.         });
  19.  # -- down
  20.        Schema::drop('posts');
  21.  
  22. php artisan generate:migration remove_completed_from_tasks_table --fields="completed:boolean"
  23.  
  24. # -- up --
  25.        Schema::table('tasks', function(Blueprint $table) {
  26.             $table->dropColumn('completed');
  27.         });
  28. # -- down --
  29.        Schema::table('tasks', function(Blueprint $table) {
  30.             $table->boolean('completed');
  31.         });
  32.  
  33. php artisan generate:pivot orders users
  34. # -- up --
  35.  
  36.       Schema::create('order_user', function(Blueprint $table) {
  37.             $table->increments('id');
  38.             $table->integer('order_id')->unsigned()->index();
  39.             $table->foreign('order_id')->references('id')->on('orders')->onDelete('cascade');
  40.             $table->integer('user_id')->unsigned()->index();
  41.             $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
  42.             $table->timestamps();
  43.         });
  44. # --  down --
  45.       Schema::drop('order_user');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement