File "StoreAttributeOptionRequest.php"

Full Path: /home/clickysoft/public_html/jmapi5.clickysoft.net/app/Http/Requests/Admin/StoreAttributeOptionRequest.php
File size: 761 bytes
MIME-type: text/x-php
Charset: utf-8

<?php

namespace App\Http\Requests\Admin;

use Gate;
use Illuminate\Foundation\Http\FormRequest;

class StoreAttributeOptionRequest extends FormRequest
{
    public function authorize()
    {
        return Gate::allows('attribute_option_create');
    }

    public function rules()
    {
        return [
            'attribute_id' => [
                'required',
                'integer',
                'exists:attributes,id',
            ],
            'name' => [
                'string',
                'max:50',
                'required',
                'unique:attribute_options',
            ],
        ];
    }

    public function messages()
    {
        return [
            'name.unique' => 'This option already exists',
        ];
    }
}