Last active
January 4, 2016 06:09
-
-
Save tangorri/8580386 to your computer and use it in GitHub Desktop.
got error : $ php artisan db:seed Seeded: UserTableSeeder Seeded: ProfessionTableSeeder Seeded: LanguageTableSeeder [BadMethodCallException] Call to undefined method Illuminate\Database\Query\Builder::associate() db:seed [--class[="..."]] [--database[="..."]]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Customer extends Eloquent | |
{ | |
public function user() | |
{ | |
return $this->belongsTo('User'); | |
} | |
public function profession() | |
{ | |
return $this->hasOne('Profession'); | |
} | |
public function emails() | |
{ | |
return $this->hadMany('customer_emails'); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CustomerTableSeeder extends Seeder { | |
public function run() | |
{ | |
$ant = new Customer; | |
$ant->name = 'Antoine'; | |
$ant->surname = 'Malpel'; | |
$ant->birthdate = date('1975-01-02'); | |
$ant->title = 'Développeur'; | |
$ant->gender = 'm'; | |
$ant->profession = Profession::first(); | |
$ant->nationality = 'fr'; | |
$ant->retirement_date = date('2066-01-02'); | |
$ant->comments = 'test customer (NOT REAL - DEV Purpose)'; | |
$ant->phone_number = '01 01 01'; | |
$ant->mobile_phone_number = '06 xx xx xx '; | |
//$ant->save(); | |
$user = User::where('username', '=', 'antoine')->first(); | |
$user->customer()->associate($ant); | |
$user->save(); | |
/* $profession_id = Profession::first()->id; | |
$user_antoine = User::where('username', '=', 'antoine')->first(); | |
$user_jerome = User::where('username', '=', 'jerome')->first(); | |
DB::table('customers')->delete(); | |
$customers = [ | |
[ | |
'user_id' => $user_antoine->id, | |
'name' => 'Antoine', | |
'surname' => 'Malpel', | |
'birthdate' => date('1975-01-02'), | |
'title' => 'Développeur', | |
'gender' => 'm', | |
'profession_id' => $profession_id, | |
'nationality' => 'fr', | |
'retirement_date' => date('2066-01-02'), | |
'comments' => 'test custimer (not real one)', | |
'phone_number' => '', | |
'mobile_phone_number' => '06 xx xx xx ' | |
], | |
[ | |
'user_id' => $user_jerome->id, | |
'name' => 'Jérôme', | |
'surname' => 'Nicolas', | |
'birthdate' => date('1971-05-06'), | |
'title' => 'Gérant', | |
'gender' => 'm', | |
'profession_id' => $profession_id, | |
'nationality' => 'fr', | |
'retirement_date' => date('2066-05-06'), | |
'comments' => 'test custimer (not real one)', | |
'phone_number' => '', | |
'mobile_phone_number' => '06 xx xx xx ' | |
], | |
]; | |
DB::table('customers')->insert($customers);*/ | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Zizaco\Entrust\HasRole; | |
class User extends Eloquent | |
{ | |
use HasRole; // add permissions relation | |
protected $hidden = array('password', 'confirmation_code'); | |
public function customer() | |
{ | |
return $this->hasOne('Customer'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment