There are a couple of ways with which you can achieve this, one is as mentioned by Doggo $energy->energyid = strtoupper($request->input('energyid')); and the other is creating a request file and using a package (https://github.com/Waavi/Sanitizer)
here is how your code will look like
class EnergyStoreRequest extends BaseFormRequest
{
/**
* 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 [
'energyid' => 'required',
'energydetail' => 'required'
];
}
/**
* Filters to be applied to the input.
*
* @return array
*/
public function filters()
{
return [
'energyid' => 'trim|uppercase',
];
}
}
And your controller will look likt this
public function store(EnergyStoreRequest $request)
{
$input = $request->validated();
$energy = new Energy;
$energy->energyid = $input['energyid'];
$energy->energydetail = $input['energydetail'];
$energy->save();
return redirect('/page')->with('success', 'data added');
}
$energy->energyid = strtoupper($request->input('energyid'));