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

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -