What is $rs?
May 29, 2017
13
Level 2
One to many relationship seem wrong
I have two tables, User:{id,name....} Resume:{id,user_id,....}
My User model :
/**
* Get the resumes for the user.
*/
public function resumes()
{
return $this->hasMany(Resume::class);
}
My Resume model :
**
* Get resume owner
*
* @return resume owner
*
*/
public function user(){
return $this->belongsTo(User::class);
}
When i try to get resume owner
>>> $rs->user->all()
=> Illuminate\Database\Eloquent\Collection {#767
all: [
App\User {#768
id: 1,
name: "Ed Kuhlman",
email: "nyah01@example.com",
created_at: "2017-05-28 14:04:20",
updated_at: "2017-05-28 14:04:20",
},
App\User {#769
id: 2,
name: "Javonte Powlowski",
email: "[email protected]",
created_at: "2017-05-28 14:04:20",
updated_at: "2017-05-28 14:04:20",
},
App\User {#770
id: 3,
name: "Aaron Keeling",
email: "felicita97@example.net",
created_at: "2017-05-28 14:04:20",
updated_at: "2017-05-28 14:04:20",
},
],
}
What's the problem ?
Level 10
1 like
Please or to participate in this conversation.