I have two form request fields for feet and inches for calculating a user's height. What I want to do is validate those inputs and then replace those with a new attribute called height. Right now I have the two fields validating just trying to figure out how I can replace the new attribute with the old attributes. Any suggestions on how to do that?
I apologize what would I do in my form request class to replace it. I have the Eloquent model creation in my controller and want to keep it from having to do the calculation in there and then do it in the form request class and then replace in the form request class as well.
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class UserFormRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'feet' => 'required|integer',
'inches' => 'required|integer|max:11',
];
}
}