php - Using Faker in Laravel 5.0 returns 'Class User not found'

Solution:
I think this problem is due to class mapping issue. Run the following command from your command line
php artisan dump-autoload
If this does not work then Alternatively you can use namespace for your models. To this just define namespace in your User Modal
namespace Models;
To use This class just put the following line in your code
use Illuminate\Database\Seeder;
use Models\User;
class UsersTableSeeder extends Seeder {
public function run()
{
$faker = Faker\Factory::create();
for ($i = 0; $i < 50; $i++)
{
$user = User::create(array(
'name' => $faker->userName,
'email' => $faker->email,
'password' => $faker->word,
'verified' => $faker-numberBetween($min = 0, $max = 1)
));
}
}
}
Answer
Solution:
Laravel 5 namespace your models by default with theApp
namepace.
So you must refer to yourUser
model asApp\User
If you have changed the default namespace with
php artisan app:name YourNamespace
use the namespace you used instead ofApp
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: malformed utf-8 characters, possibly incorrectly encoded
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.