0

I am using Laravel 5.4 and the package migrations-generator that generates migrations.

So I have the migrations and now I need to generate the views automatically using Artisan. I tried it on Symfony and it was so easy but I can't do it with Laravel.

Here is an example of a migration file called 2017_07_01_202030_create_personas_table.php for persons.

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreatePersonasTable extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('personas', function(Blueprint $table)
        {
            $table->integer('id', true);
            $table->string('nombre', 100);
            $table->dateTime('fecha_de_nacimiento');
            $table->softDeletes();
            $table->timestamps();
        });
    }


    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('personas');
    }

}

I tried more than eight packages to resolve my problem: generate model, views and controller from a table (on Laravel 5.4) but they don't work. Else I will use the Yii Framework that works great.

Roby Sottini
  • 2,117
  • 6
  • 48
  • 88

2 Answers2

0
php artisan make:controller MyController -r --model=MyModel

It will generate Controller with REST function inside them. & also create model if its not created.

You can also use below command to generate migration while creating Model

php artisan make:Model MyModel --migration 

& For manage views you can use this. I haven't used it yet but come to see this package suggest by many time.

https://github.com/svenluijten/artisan-view

Hope this help.

Vishal Tarkar
  • 808
  • 11
  • 32
  • I tried but it doesn't use the migrations. I need to use migrations to generate the models, views and controllers. The data of my database is only in the migrations folder. – Roby Sottini Jul 03 '17 at 11:33
0

If you want an easy way to generate migration and views in a single artisan command, just install & use this popular package from Jeffrey Way https://github.com/laracasts/Laravel-5-Generators-Extended. Just follow the steps from that page.

Wanda Ichsanul Isra
  • 2,142
  • 10
  • 19