Model class not found when running Seeder in Laravel 5 -
i creating admin auth app , generated model artisan command:
php artisan make:model admin -m
this generated class:
namespace app\models; use illuminate\database\eloquent\model; class admin extends model { // }
this created empty model , basic migration. added lines migration:
public function up() { schema::create('admins', function (blueprint $table) { $table->increments('id'); $table->string('name', 32); $table->string('username', 32); $table->string('email', 320); $table->string('password', 64); $table->string('remember_token', 100)->nullable(); $table->timestamps(); }); }
then used command line create seeder:
php artisan make:seeder admintableseeder
and added seeder databaseseeder
public function run() { $this->call(admintableseeder::class); }
but when run seeder php artisan db:seed
class missing error:
php fatal error: class 'admin' not found in /laravelpath/database/seeds/admintableseeder.php on line 15
[symfony\component\debug\exception\fatalerrorexception]
class 'admin' not found
it seems admin model.
i've tried run fixes composer update
, composer dump-autoload
didn't help.
anyone knows happening? why error , how fix it?
extra info: read somewhere should name app executed php artisan app:name myappname
, added namespaces everywhere (at least in http
folder). i'm not sure if messed classes.
@edit 1
this admintableseeder
use illuminate\database\seeder; class admintableseeder extends seeder { /** * run database seeds. * * @return void */ public function run() { db::table('admins')->delete(); admin::create(array( 'name' => 'victor ferreira', 'username' => 'victorferreira', 'email' => 'victor.ferreira@live.com', 'password' => hash::make('123456'), )); } }
in admintableseeder.php
use app\models\admin;
have @ admin model under app\models namespace means admin model resides under app/models/ folder. if doesn't works in case admin isn't under app/models folder remove models admin model , make namespace app\admin
Comments
Post a Comment