Better db seeding for tests
This commit is contained in:
parent
e71c605acb
commit
20d71513f3
2 changed files with 7 additions and 10 deletions
|
@ -14,9 +14,9 @@ class Contact extends Model
|
||||||
protected $table = 'contacts';
|
protected $table = 'contacts';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We shall set a blacklist of non-modifiable model attributes.
|
* We shall guard against mass-migration.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $guarded = ['id'];
|
protected $fillable = ['nick', 'name', 'homepage', 'twitter', 'facebook'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Contact;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
class ContactsTableSeeder extends Seeder
|
class ContactsTableSeeder extends Seeder
|
||||||
|
@ -11,22 +12,18 @@ class ContactsTableSeeder extends Seeder
|
||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
DB::table('contacts')->insert([
|
Contact::create([
|
||||||
'nick' => 'tantek',
|
'nick' => 'tantek',
|
||||||
'name' => 'Tantek Çelik',
|
'name' => 'Tanetk Çelik',
|
||||||
'homepage' => 'http://tantek.com',
|
'homepage' => 'http://tantek.com',
|
||||||
'twitter' => 't',
|
'twitter' => 't',
|
||||||
'created_at' => '2016-01-12 16:11:00',
|
|
||||||
'updated_at' => '2016-01-12 16:11:00',
|
|
||||||
]);
|
]);
|
||||||
|
Contact::create([
|
||||||
DB::table('contacts')->insert([
|
|
||||||
'nick' => 'aaron',
|
'nick' => 'aaron',
|
||||||
'name' => 'Aaron Parecki',
|
'name' => 'Aaron Parecki',
|
||||||
'homepage' => 'https://aaronparecki.com',
|
'homepage' => 'https://aaronparecki.com',
|
||||||
'twitter' => 'aaronpk',
|
'twitter' => 'aaronpk',
|
||||||
'created_at' => '2016-01-12 16:12:00',
|
'facebook' => '123456',
|
||||||
'updated_at' => '2016-01-12 16:12:00',
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue