What i want to do know when the expire month comes that column will become red automatically otherwise it stay green.
Asked
Active
Viewed 1,690 times
-2

Rishabh Mehta
- 13
- 7
-
Can you provide your html and your controller ? – wahdan Aug 26 '17 at 10:23
-
you have several ways but i need to know you want it in a backend way or frontEnd – wahdan Aug 26 '17 at 10:26
-
there is no personal blade file for clients sir... – Rishabh Mehta Aug 26 '17 at 10:27
-
the most easiest way is to compare the current date to the returned date from your controller , and based on the condition you will set the color of the date – wahdan Aug 26 '17 at 10:32
-
this is how i am calculating my expire date – Rishabh Mehta Aug 26 '17 at 10:36
-
`date_default_timezone_set('asia/calcutta'); $month = $request->month; $expiry_date = Carbon::now()->addMonths($month); $request['expiry_date'] = $expiry_date;` – Rishabh Mehta Aug 26 '17 at 10:38
-
what is the format of $expiry_date? is it dd/mm/yyyy? or what? – wahdan Aug 26 '17 at 10:46
-
its in yyyy/mm/dd – Rishabh Mehta Aug 26 '17 at 10:50
-
ok i have provided a solution based on your requirements – wahdan Aug 26 '17 at 11:15
1 Answers
0
in your view
@php
$currentdate=strtotime(date('Y/m/d'));
$exp_date=strtotime($expiry_date);
if($currentdate > $exp_date)
{ //not expired
$color="#539E05";
}
else
{
//expired
$color="#EA2C12";
}
@endphp
<td style="color: {{$color}}">{{$expiry_date}}</td>
i don't know your html structure looks like so i assumed that expiry date exist in span tag

wahdan
- 1,208
- 3
- 16
- 26
-
thnq sir its look good but in backpack there is no blade.php file for my clients table there is only dashboard.blade.php & layout.blade.php – Rishabh Mehta Aug 26 '17 at 11:21
-
can you edit your post to provide your controller which set backpack datatable data? so i can edit my answer ? – wahdan Aug 26 '17 at 11:49