30 lines
756 B
PHP
30 lines
756 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class StoreWeightEntryRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user()?->hasCompletedNutritionOnboarding() === true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'weightKg' => ['required', 'numeric', 'min:35', 'max:300'],
|
|
'measuredAt' => ['sometimes', 'nullable', 'date', 'before_or_equal:now'],
|
|
];
|
|
}
|
|
}
|