<?php

namespace App\Packages\User\Notifications;

use App\Packages\Capsule\Models\Capsule;
use App\Packages\User\Models\UserNotification;
use App\Packages\User\Models\UserNotificationPush;

/**
 * Class NotificationLike
 * @package App\Packages\User\Notifications
 */
class NotificationBlocked extends AbstractNotification
{
    /** @var Capsule */
    private $capsule;

    /**
     * NotificationBlocked constructor.
     * @param Capsule $capsule
     */
    public function __construct(Capsule $capsule)
    {
        $this->owner = $capsule->user;
        $this->capsule = $capsule;
    }

    /**
     * @return bool
     */
    public function shouldSend()
    {
        return true;
    }

    public function sendApplication()
    {
        $notification = UserNotification::storeNotification($this->owner, TypesNotification::BLOCKED);
        $notification
            ->setCapsule($this->capsule)
            ->persist();
    }

    /**
     * @return UserNotificationPush
     */
    public function sendPush()
    {
        $notification = UserNotificationPush::storeNotification($this->owner, TypesNotification::BLOCKED);
        $result = $notification
            ->setCapsule($this->capsule)
            ->persist();

        return $result;
    }
}