Hola estoy intentando usar faker, para alimentar mi bd, pero me lanza el siguiente error:
ReflectionException : Class CarnetSeeder does not exist
Les muestro a continuacion como tengo los archivos Mi tabla
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCarnetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('carnets', function (Blueprint $table) {
$table->increments('id');
$table->string('tipo',20);
$table->date('fechaExpedicion');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('carnets');
}
}
mi modelo
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Carnet extends Model
{
//define la tabla a que pertenece y los campos rellenables
protected $table = 'carnets';
protected $fillable = ['id','tipo','fechaExpedicion'];
//define la relacion entre las tablas
public function relCarnet()
{
return $this->hasMany('choferes');
}
public function mostrarTodos() //Muestra todos los carnets existentes
{
}
}
El factory
<?php
use Faker\Generator as Faker;
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/
$factory->define(App\Usuario::class, function (Faker\Generator $faker) {
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
'remember_token' => str_random(10),
];
});
$factory->define(App\Carnet::class, function (Faker\Generator $faker) {
return [
'tipo' => $faker->?,
'fechaExpedicion' => $faker->date,
];
});
el seeder individual
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\seeds\CarnetSeeder;
use Faker\Factory as Faker;
use Illuminate\Support\Facades\DB;
class CarnetSeeder extends Seeder
{
/**
* Corre el seed en la tabla carnet.
*
* @return void
*/
public function run()
{
//creando el seed en la tabla con 20 ejemplos
factory(App\Carnet::class, 20)->create();
}
}
el DatabaseSeeder
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
$this->call(CarnetSeeder::class); // ejemplo ejecucion seeder
//$this->call(UsersTableSeeder::class);
Model::reguard();
}
}