public function recipients() { if ($this->to_user) { return User::orderBy('name', 'asc')->get(); } elseif ($this->to_member) { return User::has('member')->orderBy('name', 'asc')->get(); } elseif ($this->to_list) { $userids = []; foreach ($this->lists as $list) { $userids = array_merge($userids, $list->users->lists('id')->toArray()); } return User::whereIn('id', $userids)->orderBy('name', 'asc')->get(); } }