Abrar Jahin Abrar Jahin - 4 months ago 23
PHP Question

Laravel 5.2 - Laravel Model With Migration with table Name Command

I have 2 commands for making migration and making model.

If I run-

php artisan make:migration create_users_table --create=temps


Then I am getting a migration like this- 2016_02_09_060158_create_users_table.php

And content inside this file is -

<?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');
}
}


If I run this command-

php artisan make:model User -m


Then I am getting this 2 files-

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
{
//
}


But I want to have a command which is a mixture of this 2 s that I can get 2 file and DB name should be included in the files (say in this case table name is temps).

Is there any way?




Update

I have tried this-

php artisan make:migration:schema create_dogs_table --schema="name:string"


And Found this-

enter image description here

Answer

I really don't understand your question but i think you want a command that generates both model and migration.

You should take a look at Jeffery Way's Generators package.You can do this:

php artisan make:migration:schema create_dogs_table --schema="name:string"