Skip to content

Instantly share code, notes, and snippets.

@lloy0076
Created April 27, 2017 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lloy0076/0fee3b3b99abdd78deea9daf2ea8ab0f to your computer and use it in GitHub Desktop.
Save lloy0076/0fee3b3b99abdd78deea9daf2ea8ab0f to your computer and use it in GitHub Desktop.
Laravel Seeder - Confound It!
c:\laragon\www\backpack\database\seeds (master)
λ cat DatabaseSeeder.php Cities.php
<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$this->call(Cities::class);
}
}
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class Cities extends Seeder
{
public function run()
{
DB::table('tests')->insert([
'name' => 'Adelaide',
'phone_no' => '1234567890',
'description' => 'The city of churches',
]);
DB::table('tests')->insert([
'name' => 'Sydney',
'phone_no' => '2345678901',
'description' => 'The harbour city',
]);
DB::table('tests')->insert([
'name' => 'New York',
'phone_no' => '31547899',
'description' => 'The big apple',
]);
}
}
c:\laragon\www\backpack (master)
λ php artisan db:seed
Seeding: Cities
[ReflectionException]
Class Cities does not exist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment