PHP Laravel - php artisan migrate - Class Table not found -  Illuminate\Foundation\Console\Kernel

PHP Laravel - php artisan migrate - Class Table not found - Illuminate\Foundation\Console\Kernel

Dobrý den,

vytvářím v PHP frameworku Laravel poprvé databázovou tabulku přes migrace a mám tam chybu. Dělám to takto:

cd /var/www/laravel
php artisan make:migration create_items_table

vim database/migrations/2020_06_22_112336_create_items_table.php

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

class CreateTableItems extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */

    public function up()
    {
        Schema::create('items', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->decimal('price');
            $table->text('desc');
            $table->timestamps();
        });
    }


    /**
     * Reverse the migrations.
     *
     * @return void
     */

    public function down()
    {
       //
    }
}

Dám migraci a je tam chyba:
php artisan migrate

                                                                                                                                                                                                                                       
   Error                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                            
  Class 'CreateItemsTable' not found                                                                                                                                                                                                     
                                                                                                                                                                                                                                            
  at vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:453                                                                                                                                                           
    449|     public function resolve($file)                                                                                                                                                                                                 
    450|     {                                                                                                                                                                                                                              
    451|         $class = Str::studly(implode('_', array_slice(explode('_', $file), 4)));                                                                                                                                                   
    452|                                                                                                                                                                                                                                    
  > 453|         return new $class;                                                                                                                                                                                                         
    454|     }                                                                                                                                                                                                                              
    455|                                                                                                                                                                                                                                    
    456|     /**                                                                                                                                                                                                                            
    457|      * Get all of the migration files in a given path.                                                                                                                                                                             

      +20 vendor frames 
  21  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

ODPOVĚĎ

Dobrý den,

chyba byla u mě, změnil jsem v laravel název třídy pro migraci z CreateItemsTable na CreateTableItems... Když jsem to vrátil, tak migrace doběhla...

Jak se ti článek líbil?

Komentáře (0)

Přidat komentář