<?php

namespace App\Classes\Modules\Rewards\Standards\Rules;

use App\Classes\General\Abstracts\AbstractRule;
use App\Classes\Modules\Rewards\Standards\Validators\RewardValidation;
use App\Classes\Modules\Rewards\DataTransferObjects\RewardObject;
use Illuminate\Support\Facades\Auth;

class CanCreateReward extends AbstractRule
{

    /** @var RewardValidation */
    private $rewardValidation;

    /**
     * CanCreateReward constructor.
     * @param RewardValidation $rewardValidation
     */
    public function __construct(RewardValidation $rewardValidation)
    {
        $this->rewardValidation = $rewardValidation;
    }

    /**
     * @return bool
     */
    protected function authorized($object): bool
    {
        if (!Auth::user()->can('add reward')) {
            return false;
        }

        return true;
    }

    /**
     * @param RewardObject $object
     * @return bool
     * @throws \App\Classes\Exceptions\RequestValidationException
     */
    protected function validators($object): bool
    {
        return true; // $this->rewardValidation->validate($object, 'POST');
    }

    /**
     * @param RewardObject $object
     * @return bool
     */
    protected function criteria($object): bool
    {
        return true;
    }
}
