@Fennek You’ll need to re-format the date from DD/MM/YYYY to YYYY-MM-DD before passing to your model:
$data = $request->all();
$data['birth'] = Carbon::createFromFormat('DD/MM/YYYY', $data['birth'])->toDateString();
return User::create($data);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
So I'm trying to store a birth date in the database as an additional field with user registration (auth).
Form:
<div class="form-group{{ $errors->has('birth') ? ' has-error' : '' }}">
<label class="col-md-4 control-label">Date of Birth*</label>
<div class="col-md-6">
<input type="text" placeholder="dd/mm/YYYY" class="form-control" name="birth" value="{{ old('birth') }}">
@if ($errors->has('birth'))
<span class="help-block">
<strong>{{ $errors->first('birth') }}</strong>
</span>
@endif
</div>
</div>
Controller:
protected function create(array $data)
{
return User::create([
....other fields here
'birth' => $data['birth'],
.....other fields here
]);
}
I'm assuming I have to somehow reformat the input data but I'm not really sure on how to do this and especially on where to put it in laravel. Anyone who could help me out?
Please or to participate in this conversation.