I have hashtags and users can subscribe them. here is what I did for subscription:
function hashtag(){
return $this->belongsToMany('App\Hashtag');
}
And also there is user relationship in Subscription Model:
function user(){
return $this->belongsToMany('App\User');
}
The user
Model has subscribes
which is supposed to give me the hashtags that the Authed user subscribes. Here it is:
function subscribes(){
return $this->hasMany('App\Subscription');
}
Now with this code I tried to access the hashtag
s the Auth
ed user subscribes
here is the view code:
@foreach(Auth::user()->subscribes->hashtag as $tags)
@endforeach
What I think is that, laravel expects a relationship table here, called hashtag_subscription
or something like that. Now I got a bit confused with these relationships. I highy prefer to get around this withput creating extra table, I feel like I can accomplish it without an extra table.
Tables are as following:user
, hashtag
, subscription
Models: Hashtag
, Subscription
, User
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2FrILC7
via IFTTT
Aucun commentaire:
Enregistrer un commentaire