php - Laravel Polymorphic Relations Has Many Through -
i have subscriber model
// subscriber model id user_id subscribable_id subscribable_type public function user() { return $this->belongsto('app\user'); } public function subscribable() { return $this->morphto(); } and topic model
// topic model public function subscribers() { return $this->morphmany('app\subscriber', 'subscribable'); } and want users through subscriber model, notify them like
notification::send($topic->users, new notification($topic));
// topic model public function users() { return $this->hasmanythrough('app\user', 'app\subscriber'); } any ideas?
ok, got better solution
// subscriber model use notifiable; public function receivesbroadcastnotificationson() { return 'app.user.' . $this->user_id; } // send notification notification::send($post->subscribers, new testnotification($post));
Comments
Post a Comment