很快,我正在输入php artisan db:seed命令.
我得错误了:
[ReflectionException]
类UserTableSeeder不存在
root@dd-desktop:/opt/lampp/htdocs/dd/laravel# php artisan db:seed
在这里,是我的UserTableSeeder.php和DatabaseSeeder.phpPage
UserTableSeeder.php
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class UserTableSeeder extends Seeder
{
public function run()
{
DB::table('users')->delete();
User::create(array(
'name' => 'Chris Sevilleja',
'username' => 'sevilayha',
'email' => 'chris@scotch.io',
'password' => Hash::make('awesome'),
));
}
}
Run Code Online (Sandbox Code Playgroud)
DatabaseSeeder.php
<?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();
Eloquent::unguard(); …Run Code Online (Sandbox Code Playgroud) 我有不同的文件夹中的数据库播种器clases.当我写db:seed时,控制台显示以下错误:
[ReflectionException] Class DatabaseSeeder does not exist , Laravel Seeder
Run Code Online (Sandbox Code Playgroud)
一类是这样的:
namespace Database\Seeds;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use TiposCompromisosTableSeeder;
class DatabaseSeeder extends Seeder {
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Eloquent::unguard();
$this->call('TiposCompromisosTableSeeder');
}
}
Run Code Online (Sandbox Code Playgroud)
我的另一课是
namespace Database\Seeds;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class TiposCompromisosTableSeeder extends Seeder{
public function run(){
DB::table('tipos')->insert(array(
'nombre' => 'prioridad',
'tabla' => 'compromisos',
'str1' => 'baja',
'int1' => 1
));
}
}
Run Code Online (Sandbox Code Playgroud)
我试过用
composer dump-autoupload …Run Code Online (Sandbox Code Playgroud)