In my laravel 5.7 app in console I created new table migration script and seeder :
php artisan make:migration create_page_content_images_table --create="page_content_images"
php artisan make:seeder PageContentImagesWithInitData
Both files were created ok and I filled them database/migrations/2018_12_04_120422_create_page_content_images_table.php:
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePageContentImagesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('page_content_images', function (Blueprint $table) {
$table->increments('id');
$table->integer('page_content_id')->unsigned();
$table->foreign('page_content_id')->references('id')->on('page_contents')->onDelete('RESTRICT');
$table->string('filename', 255);
$table->boolean('is_main')->default(false);
$table->boolean('is_video')->default(false);
$table->string('video_type', 10)->nullable();
$table->string('video_ext', 5)->nullable();
$table->smallInteger('video_width')->nullable();
$table->smallInteger('video_height')->nullable();
$table->string('info', 255)->nullable();
$table->timestamp('created_at')->useCurrent();
$table->unique(['page_content_id', 'filename'], 'page_contents_page_content_id_filename_unique');
$table->index(['page_content_id', 'is_main'], 'page_contents_page_content_id_is_main');
$table->index(['page_content_id', 'is_video', 'filename'], 'page_contents_page_content_id_is_video_filename');
$table->index(['created_at'], 'page_content_message_documents_created_at_index');
});
Artisan::call('db:seed', array('--class' => 'PageContentImagesWithInitData')); //database/seeds/PageContentImagesWithInitData.php
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('page_content_images');
}
}
and database/seeds/PageContentImagesWithInitData.php :
<?php
use Illuminate\Database\Seeder;
class PageContentImagesWithInitData extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('page_content_images')->insert([
'id' => 1,
'page_content_id' => 1, // About
'filename' => 'your_vote.jpg',
'is_main' => false,
'is_video' => false,
'video_type' => null,
'video_ext' => null,
'video_width' => null,
'video_height' => null,
'info' => 'Site slogan image',
]);
DB::table('page_content_images')->insert([
'id' => 2,
'page_content_id' => 1, // About
'filename' => 'our_boss.jpg',
'is_main' => false,
'is_video' => false,
'video_type' => null,
'video_ext' => null,
'video_width' => null,
'video_height' => null,
'info' => 'Our boss photo',
]);
DB::table('page_content_images')->insert([
'id' => 3,
'page_content_id' => 1, // About
'filename' => 'our_main_manager.jpg',
'is_main' => false,
'is_video' => false,
'video_type' => null,
'video_ext' => null,
'video_width' => null,
'video_height' => null,
'info' => 'Our main manager',
]);
DB::table('page_content_images')->insert([
'id' => 4,
'page_content_id' => 2, // Contact Us
'filename' => 'office_building.jpeg',
'is_main' => true,
'is_video' => false,
'video_type' => null,
'video_ext' => null,
'video_width' => null,
'video_height' => null,
'info' => 'Office building',
]);
DB::table('page_content_images')->insert([
'id' => 5,
'page_content_id' => 2, // Contact Us
'filename' => 'office.jpeg',
'is_main' => true,
'is_video' => false,
'video_type' => null,
'video_ext' => null,
'video_width' => null,
'video_height' => null,
'info' => 'Our Office',
]);
}
}
The problem is that running migration command I got error:
ReflectionException : Class PageContentImagesWithInitData does not exist
at /mnt/_work_sdb8/wwwroot/lar/Votes/vendor/laravel/framework/src/Illuminate/Container/Container.php:779
I checked and do not see any misspelling or case issue... I run in console next commands :
php artisan config:cache
composer dump-autoload
But I got error anyway...
Why error and how to fix it?
Thanks!
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Ue00hm
via IFTTT
Aucun commentaire:
Enregistrer un commentaire