0

I am learning Laravel.

Here is my migration file code.

class CreatePostTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('post', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned(); // i want to add this column after adding this line i runs the command refresh but it shows below errors.
            $table->string('title');
            $table->text('body');
            $table->timestamps();
        });
    }

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

Now I have a problem that whenever I run this command in terminal in PhpStorm:

php artisan migrate:refresh

it shows following errors:

PHP Fatal error: Class 'AddIsAdminColumnToPostTable' not found in C:\xampp\htdocs\cms\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php on line 335

Symfony\Component\Debug\Exception\FatalErrorException] Class 'AddIsAdminColumnToPostTable' not found

I tried composer dump-autoload in terminal solution from here but it's not working. I also used rollback command but still having issue.

How can make refresh this?

Community
  • 1
  • 1
Hamza Zafeer
  • 2,360
  • 13
  • 30
  • 42
  • 1
    Have you tried running it from console/terminal? If it has the same results (does not work) then this issue has nothing to do with PhpStorm. – LazyOne Apr 27 '17 at 15:51
  • Yes running from terminal.. then what is the problem? – Hamza Zafeer Apr 27 '17 at 17:45
  • @LazyOne Then what i have to do to resolve this issue? – Hamza Zafeer Apr 28 '17 at 14:36
  • In such case it's some sort of misconfiguration or Laravel-related issue -- I cannot help in this regard as I have no idea about your project. – LazyOne Apr 28 '17 at 14:41
  • @LazyOne ok Thanks, I just solved my problem i delete the migration file, and runs the command again the create command from terminal and then i runs the refresh command it works :) – Hamza Zafeer Apr 28 '17 at 14:51

1 Answers1

1

Artisan looks for migrations based on the file name. If you want it to be called something else: rollback, delete the migration, make a new migration. Or, change the file name to exactly match the class name.

For you, try changing

class CreatePostTable extends Migration

to

class AddIsAdminColumnToPostTable extends Migration
Naltroc
  • 989
  • 1
  • 14
  • 34
  • but i have an other class which have name `AddIsAdminColumnToPostTable` i just show this class because i wants to add column in post table. – Hamza Zafeer Apr 28 '17 at 04:21