1
votes

Please i want to run a migration to add a facilities column to my image table but it brings this error

 Already: No such file or directory
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating optimized autoload files

Illuminate\Foundation\ComposerScripts::postAutoloadDump @php artisan package:discover Discovered Package: fideloper/proxy Discovered Package: nunomaduro/collision Discovered Package: laravel/tinker Discovered Package: uxweb/sweet-alert Discovered Package: yajra/laravel-datatables-oracle Package manifest generated successfully.

  Symfony\Component\Debug\Exception\FatalThrowableError  : Class          'AddFacilitiesToImagesNew' not found

 at     /var/www/roomhub/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:418
414|     public function resolve($file)
415|     {
416|         $class = Str::studly(implode('_', array_slice(explode('_', $file), 4)));
417|

418| return new $class; 419| } 420| 421| /** 422| * Get all of the migration files in a given path.

Exception trace:

 1       Illuminate\Database\Migrations\Migrator::resolve("2018_05_26_085447_add_faciliti    es_to_images_new")
         /var/www/roomhub/vendor/laravel/framework/src/Illuminate/Database/Migrations/Mig    rator.php:168

 2       Illuminate\Database\Migrations\Migrator::runUp("/var/www/roomhub/database/migrations/2018_05_26_085447_add_facilities_to_images_new.php")
  /var/www/roomhub/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:146

 Please use the argument -v to see more details.

THIS IS THE MIGRATION FILE

<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddFacilitiesToImagesNewTable extends Migration
{
/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
    Schema::table('images_new', function (Blueprint $table) {
        $table->string('facilities');
    });
}
/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::table('images_new', function (Blueprint $table) {
        $table->dropColumn('facilities');
    });
}
}

Please what is causing the error

1
show ur migration file - arun
check above i have added the migration file - Paul

1 Answers

1
votes

Follow this line of thought, Class AddFacilitiesToImagesNew can't be resolved.

In the error traceback, a line that determines class name from file name was printed.

$class = Str::studly(implode('_', array_slice(explode('_', $file), 4)));

It strictly follows that your class has to be named AddFacilitiesToImagesNew in the migration file.

Check that in 2018_05_26_085447_add_facilities_to_images_new.php, the migration class is rightly named AddFacilitiesToImagesNew.

Edit: One more thing, migrations need not be namespaced. If this one needs to be for whatever reason, make sure that it's added to your composer and that you do dump the autoload file.