Laravel 5.2 - Laravel 使用 table 名称命令进行迁移的模型
Laravel 5.2 - Laravel Model With Migration with table Name Command
我有 2 个命令用于制作迁移和制作模型。
如果我运行-
php artisan make:migration create_users_table --create=temps
然后我将进行这样的迁移- 2016_02_09_060158_create_users_table.php
这个文件里面的内容是-
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('temps', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('temps');
}
}
如果我运行这个命令-
php artisan make:model User -m
然后我得到这 2 个文件-
2016_02_09_060436_create_temps_table.php
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTempsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('temps', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('temps');
}
}
Temp.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Temp extends Model
{
//
}
但是我想要一个命令,它是这 2 个的混合,我可以获得 2 个文件,数据库名称应该包含在文件中(比如在这种情况下 table 名称是 温度).
有什么办法吗?
更新
这个我试过了-
php artisan make:migration:schema create_dogs_table --schema="name:string"
并找到这个-
我真的不明白你的问题,但我认为你想要一个同时生成模型和迁移的命令。
你应该看看 Jeffery Way's Generators package.You 可以做到这一点:
php artisan make:migration:schema create_dogs_table --schema="name:string"
我有 2 个命令用于制作迁移和制作模型。
如果我运行-
php artisan make:migration create_users_table --create=temps
然后我将进行这样的迁移- 2016_02_09_060158_create_users_table.php
这个文件里面的内容是-
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('temps', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('temps');
}
}
如果我运行这个命令-
php artisan make:model User -m
然后我得到这 2 个文件-
2016_02_09_060436_create_temps_table.php
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTempsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('temps', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('temps');
}
}
Temp.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Temp extends Model
{
//
}
但是我想要一个命令,它是这 2 个的混合,我可以获得 2 个文件,数据库名称应该包含在文件中(比如在这种情况下 table 名称是 温度).
有什么办法吗?
更新
这个我试过了-
php artisan make:migration:schema create_dogs_table --schema="name:string"
并找到这个-
我真的不明白你的问题,但我认为你想要一个同时生成模型和迁移的命令。
你应该看看 Jeffery Way's Generators package.You 可以做到这一点:
php artisan make:migration:schema create_dogs_table --schema="name:string"