class Post {
function category() {
$this->belongsTo('Category');
}
}
class User {
function posts() {
$this->hasMany('Post');
}
function categories() {
//???
$this->posts->category;
}
}
I have code that looks like this, and I'm wondering how I can access "categories" on the user object and have it return a Laravel relation.
None of the existing relation methods "hasManyThrough", etc seem to fit this use case.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1ikRFEK
via IFTTT
Aucun commentaire:
Enregistrer un commentaire