I am getting the following error when trying to seed in Laravel 5.4
[Symfony\Component\Debug\Exception\FatalThrowableError]
Parse error: syntax error, unexpected '$faker' (T_VARIABLE), expecting function (T_FUNCTION) or c
onst (T_CONST)
Here is the code for the seed file.
<?php
use Illuminate\Database\Seeder;
use App\Book;
use Faker\Factory as Faker;
class BookSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
$faker = Faker::create();
public function run()
{
foreach (range(1, 30) as $index) {
Book::create([
'title'=> $faker->sentence(5),
'author'=> $faker->sentence(7),
'description'=>$faker->paragraph(4)
]);
}
}
}
I have created the model and done the migration. I can't seem to find any good tutorials on how to do this with Laravel 5.4 . Any help would be appreciated.