I'm working with Laravel and I have a database which contains two tables: in the first table there is a column with an integer field that I want to work like a timer, in the second table I store when an user submit a form and there is a timestamp with the time of the submit. I would to prevent the user to submit the same form before the expiry of the time specified by the field in the first table. How can I do that ?
Here is the code in the controller:
public function getShow($id = null){
if ( ! is_null($id)){
$submitted = Actionshistory::where('action_id','=',$id)->first()->created_at;
$minutes = Actions::where('id','=',$id)->pluck('time_need'); // time need between submit two same form.
$passed = Carbon::createFromTimeStamp($submitted)->diffInMinutes(Carbon::now('Europe/Rome'));
if ($submitted && $passed >= $minutes)
{
// Other queries and success message
}
// Error message
}
// error message for id
}
I need to use Carbon::now('Europe/Rome')
.
Thanks.