Better db seeding for tests

This commit is contained in:
Jonny Barnes 2017-07-17 17:07:08 +01:00
parent e71c605acb
commit 20d71513f3
2 changed files with 7 additions and 10 deletions

View file

@ -14,9 +14,9 @@ class Contact extends Model
protected $table = 'contacts';
/**
* We shall set a blacklist of non-modifiable model attributes.
* We shall guard against mass-migration.
*
* @var array
*/
protected $guarded = ['id'];
protected $fillable = ['nick', 'name', 'homepage', 'twitter', 'facebook'];
}

View file

@ -1,5 +1,6 @@
<?php
use App\Contact;
use Illuminate\Database\Seeder;
class ContactsTableSeeder extends Seeder
@ -11,22 +12,18 @@ class ContactsTableSeeder extends Seeder
*/
public function run()
{
DB::table('contacts')->insert([
Contact::create([
'nick' => 'tantek',
'name' => 'Tantek Çelik',
'name' => 'Tanetk Çelik',
'homepage' => 'http://tantek.com',
'twitter' => 't',
'created_at' => '2016-01-12 16:11:00',
'updated_at' => '2016-01-12 16:11:00',
]);
DB::table('contacts')->insert([
Contact::create([
'nick' => 'aaron',
'name' => 'Aaron Parecki',
'homepage' => 'https://aaronparecki.com',
'twitter' => 'aaronpk',
'created_at' => '2016-01-12 16:12:00',
'updated_at' => '2016-01-12 16:12:00',
'facebook' => '123456',
]);
}
}