PHP 8.3.31
Preview: Can.php Size: 1.80 KB
/home/getspomw/royalsquad.us/vendor/laravel/framework/src/Illuminate/Validation/Rules/Can.php

<?php

namespace Illuminate\Validation\Rules;

use Illuminate\Contracts\Validation\Rule;
use Illuminate\Contracts\Validation\ValidatorAwareRule;
use Illuminate\Support\Facades\Gate;

class Can implements Rule, ValidatorAwareRule
{
    /**
     * The ability to check.
     *
     * @var string
     */
    protected $ability;

    /**
     * The arguments to pass to the authorization check.
     *
     * @var array
     */
    protected $arguments;

    /**
     * The current validator instance.
     *
     * @var \Illuminate\Validation\Validator
     */
    protected $validator;

    /**
     * Constructor.
     *
     * @param  string  $ability
     * @param  array  $arguments
     */
    public function __construct($ability, array $arguments = [])
    {
        $this->ability = $ability;
        $this->arguments = $arguments;
    }

    /**
     * Determine if the validation rule passes.
     *
     * @param  string  $attribute
     * @param  mixed  $value
     * @return bool
     */
    public function passes($attribute, $value)
    {
        $arguments = $this->arguments;

        $model = array_shift($arguments);

        return Gate::allows($this->ability, array_filter([$model, ...$arguments, $value]));
    }

    /**
     * Get the validation error message.
     *
     * @return array
     */
    public function message()
    {
        $message = $this->validator->getTranslator()->get('validation.can');

        return $message === 'validation.can'
            ? ['The :attribute field contains an unauthorized value.']
            : $message;
    }

    /**
     * Set the current validator.
     *
     * @param  \Illuminate\Validation\Validator  $validator
     * @return $this
     */
    public function setValidator($validator)
    {
        $this->validator = $validator;

        return $this;
    }
}

Directory Contents

Dirs: 0 × Files: 17

Name Size Perms Modified Actions
986 B lrw-rw-rw- 2025-09-17 06:52:58
Edit Download
1.80 KB lrw-rw-rw- 2025-09-17 06:52:58
Edit Download
5.37 KB lrw-rw-rw- 2025-09-17 06:52:58
Edit Download
3.24 KB lrw-rw-rw- 2025-09-17 06:52:58
Edit Download
3.17 KB lrw-rw-rw- 2025-09-17 06:52:58
Edit Download
6.59 KB lrw-rw-rw- 2025-09-17 06:52:58
Edit Download
3.43 KB lrw-rw-rw- 2025-09-17 06:52:58
Edit Download
1.06 KB lrw-rw-rw- 2025-09-17 06:52:58
Edit Download
476 B lrw-rw-rw- 2025-09-17 06:52:58
Edit Download
9.25 KB lrw-rw-rw- 2025-09-17 06:52:58
Edit Download
508 B lrw-rw-rw- 2025-09-17 06:52:58
Edit Download
1.20 KB lrw-rw-rw- 2025-09-17 06:52:58
Edit Download
1.14 KB lrw-rw-rw- 2025-09-17 06:52:58
Edit Download
8.59 KB lrw-rw-rw- 2025-09-17 06:52:58
Edit Download
1.07 KB lrw-rw-rw- 2025-09-17 06:52:58
Edit Download
999 B lrw-rw-rw- 2025-09-17 06:52:58
Edit Download
1.62 KB lrw-rw-rw- 2025-09-17 06:52:58
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).