dealhub/app/Http/Requests/StoreBrokerDeal.php
kusowl f43f92f365 feat(Create deals): broker can create deals
- add deal category migration
- add deals migration and model
- add form to create deal
- add image preview modal when uploading the image
- refactor UI components to support `required` attribute
- refactor input component to support description
- fix some UI components does not support old values
- fix some UI components does not show error messages
2026-01-12 17:48:07 +05:30

41 lines
1.0 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreBrokerDeal extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return $this->user()->isBroker();
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'title' => 'required|min:10|max:255',
'description' => 'required|min:10|max:300',
'image' => 'required|image|mimes:jpeg,png,jpg|max:10240',
'link' => 'nullable|url',
'deal_category_id' => 'required|exists:deal_categories,id',
];
}
public function messages(): array
{
return [
'category_id.required' => 'The category field is required.',
'category_id.exists' => 'The category does not exist.',
];
}
}