Skip to content
Advertisement

Check if data updated_at 24 hours ago OR a day ago (laravel)

I am able to get days ago for each row in dattable using carbon. (view CustomController.php)

But before the user is able to edit the data. I want to check if the data is updated a day ago or 24 hours ago. if 24 hours or a day passed user can’t update the data if it is within 24 hours range then the user can update the data

Migration

JavaScript

CustomController.php

JavaScript

Web.php

JavaScript

view.blade.php

JavaScript

DataTable looks like this

Dattable

Advertisement

Answer

Since you are rendering table in controller,so you can use ternary operator to dynamically load class name based on condition

JavaScript

i suggest you to move html content from controller to blade so you can easily use blade syntax

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement