• File: LinkExists.php
  • Full Path: /var/www/imaliapitest/app/Rules/LinkExists.php
  • Date Modified: 05/19/2025 4:29 PM
  • File size: 822 bytes
  • MIME-type: text/x-php
  • Charset: utf-8
<?php

namespace App\Rules;

use App\Link;
use Illuminate\Contracts\Validation\Rule;

class LinkExists implements Rule
{
    /**
     * Create a new rule instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Determine if the validation rule passes.
     *
     * @param  string  $attribute
     * @param  mixed  $value
     * @return bool
     */
    public function passes($attribute, $value)
    {
        //
        return Link::query()
            ->where('link_id', $value)
            ->orWhere('customer_link_id', $value)
            ->exists();
    }

    /**
     * Get the validation error message.
     *
     * @return string
     */
    public function message()
    {
        return 'O link_id informado não existe na base de dados.';
    }
}