I need to validate and store the date in the default Laravel format.
Form Request class:
public function rules()
{
return [
'name' => ['required', 'string', 'max:255'],
'start_at' => ['required', 'date_format:Y-m-d H:i:s', 'after:' . now()->format('Y-m-d H:i:s') ],
];
}
In my controller, there is nothing special I just save this data like below.
$seller->events()->create($request->validated());
However, in the response, I receive the data below.
{
"id": 3,
"name": "Event 1",
"start_at": "2020-10-18 22:33:58",
"created_at": "2020-09-30T22:42:57.000000Z",
}
How can i get start_at field in same format as created_at ?
Just add:
On your model