php - Laravel 5.1 How to use the same form request rules for two methods when a field is required in one but not in the other method? - Stack Overflow

PHOTO EMBED

Tue Sep 06 2022 17:29:14 GMT+0000 (Coordinated Universal Time)

Saved by @eneki #php

abstract class CompanyBaseRequest extends FormRequest
{
    ...
    public function rules()
    {
        return [
            'name' => ['required', 'string', 'max:255'],
            'category_id' => ['required', 'exists:company_categories,id'],
            'short_description' => ['required', 'string', 'max:2000'],
            'video' => ['nullable', 'file', 'mimes:mp4', 'max:30000'],
        ];
    }
}
content_copyCOPY

https://stackoverflow.com/questions/31983345/laravel-5-1-how-to-use-the-same-form-request-rules-for-two-methods-when-a-field