<?php

namespace App\Http\Requests\Admin\Shop;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class StoreArticlePost extends FormRequest
{
    public function authorize()
    {
        return true;
    }

    public function rules()
    {
        $articleId = $this->input('id');

        return [
            'ref' => [
                'required',
                Rule::unique('shop_articles', 'ref')->ignore($articleId)->whereNull('deleted_at'),
            ],
            'product_type' => 'required',
            'product_id' => 'required',
            'article_nature_id' => 'required',
            'name' => 'required',
        ];
    }
}
