dimanche 25 août 2019

Problem with helper function and sending variable with redirect in Laravel

I have a problem with my helper function called swe_date. It outputs nothing. If I don`t use it, all is good.

I have done the composer dump-autoload thing and put "app/helpers.php" in the composer.json file.

My helper function looks like this.

 if (! function_exists('swe_date'))
 {
  function swe_date($date)
  {
    setlocale(LC_TIME, 'sv_SV');
    return strftime('%A %d %B %Y %H:%M',strtotime($date));
  }
 }

My controller where I try to send my variable with my helper function. Notice when I do a dd(swe_date($suspended->suspended_until)) I got: b"söndag 22 september 2019 00:00" Don't know where the "b" comes from.

  $date = swe_date($suspended->suspended_until);
  //dd(swe_date($suspended->suspended_until));
  return redirect('/login')->with('date',$date);

The view where I try to show the message.

 @if(Session('date'))
    <div class="bg-danger mb-2 text-center text-white">
       
    </div>
 @endif



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire