Thursday, March 30, 2017

laravel carbon unset date

Right now I have a model that has a "followup" date that is rotected to convert to carbon (). The issue is in my controller if I have some dates that are not set and default (0000-00-00) Carbon returns them as -0001-11-30 00:00:00.000000. I get why, but trying to target those dates and just return "none" but cant figure out how.

in my controller:

foreach ($account->notes as $note) {

                $notes[$i]['note']       = $note;
                $notes[$i]['account']    = $account->name;

                if($note->followup != '-0001-11-30 00:00:00.000000'){
                     $notes[$i]['followup']   = $note->followup->diffForHumans();
                 } else {
                    $notes[$i]['followup']   = 'None';
                 }


               $i += 1;
           }



via Packy

Advertisement