I've tried everything I can think of but can't seem to resolve this issue, I'm sure it's something minor that I should be able to work out but it has me stumped.
I have already run composer dump-autoload with little success.
Whenever I use the artisan db:seed
command I get the following error:
PHP Fatal error: Class 'App\Models\Company' not found in X:\Development\laravelApplication\database\seeds\DatabaseSeeder.php on line 60
app/Http/Models/Company.php
<?php namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Company extends Model {
//
public function configurations() {
return $this->hasMany('App\Models\Configuration');
}
public function users() {
return $this->hasMany('App\Models\Users');
}
public function admins() {
return $this->users()->where('admin', 1)->get();
}
}
database/seeds/DatabaseSeeder.php
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use App\Models\Company;
class DatabaseSeeder extends Seeder {
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
$this->call('CompaniesTableSeeder');
$this->command->info('Companies table seeded!');
$this->call('UserTableSeeder');
$this->command->info('User table seeded!');
}
}
/**
* Seed the Users table
* @return void
*/
class UserTableSeeder extends Seeder
{
function run()
{
$needlers_id = Company::where('name', 'Needlers LTD')->first()->id;
DB::table('users')->delete();
User::create([
'company_id' => $needlers_id,
'name' => 'Joe Ware',
'email' => 'joe.ware@needlers.co.uk',
'password' => 'needlers123',
'phone' => '07594827531',
'admin' => 1,
'screen' => 0,
]);
}
}
/**
* Seed the Users table
* @return void
*/
class CompaniesTableSeeder extends Seeder
{
function run()
{
DB::table('companies')->delete();
App\Models\Company::create([
'name' => 'Needlers LTD',
'tier' => 'platinum'
]);
}
}
Can anybody point out what I am missing / doing incorrectly?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1WbknJN
via IFTTT
Aucun commentaire:
Enregistrer un commentaire