dealhub/app/Http/Requests/StoreBrokerDeal.php
kusowl a248d3fc79 feat(deal update and delete): broker can update and delete their deals
- show external links in listings
- refactor image-input.blade.php to display image while update
- refactor image-input.js to show selected image after user clicks submit
- refactor components to accept default value
- add FileService to handle image update and delete
2026-01-13 15:10:55 +05:30

41 lines
1.1 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' => [$this->isMethod('post') ? 'required' : 'nullable', '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.',
];
}
}