Fenos\Notifynder\Senders\SendGroup::send PHP Method

send() public method

Send group notifications.
public send ( Fenos\Notifynder\Contracts\StoreNotification $sender ) : mixed
$sender Fenos\Notifynder\Contracts\StoreNotification
return mixed
    public function send(StoreNotification $sender)
    {
        // Get group
        $group = $this->notifynderGroup->findByName($this->nameGroup);
        // Categories
        $categoriesAssociated = $group->categories;
        // Send a notification for each category
        foreach ($categoriesAssociated as $category) {
            // Category name
            $categoryModel = $this->notifynderCategory->findByName($category->name);
            $notification = array_merge(['category_id' => $categoryModel->id], $this->info);
            $sender->storeSingle($notification);
        }
        return $group;
    }