Files
investbrain/app/Http/Requests/PortfolioRequest.php
T

30 lines
683 B
PHP
Raw Normal View History

2025-01-24 22:45:28 -06:00
<?php
2025-01-28 17:33:54 -06:00
declare(strict_types=1);
2025-01-24 22:45:28 -06:00
namespace App\Http\Requests;
2025-01-26 22:56:05 -06:00
class PortfolioRequest extends FormRequest
2025-01-24 22:45:28 -06:00
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
2025-01-26 22:56:05 -06:00
$rules = [
'title' => ['required', 'string', 'min:5', 'max:255'],
2025-01-24 22:45:28 -06:00
'notes' => ['sometimes', 'nullable', 'string'],
'wishlist' => ['sometimes', 'nullable', 'boolean'],
];
2025-01-26 22:56:05 -06:00
2025-01-28 17:14:49 -06:00
if (! is_null($this->portfolio)) {
2025-01-26 22:56:05 -06:00
$rules['title'][0] = 'sometimes';
2025-01-28 17:14:49 -06:00
}
2025-01-26 22:56:05 -06:00
return $rules;
2025-01-24 22:45:28 -06:00
}
}