Laravel - Return values in master layout

Asked

Viewed 42 times

0

I have an application using Laravel 5.5, arose the need to insert a dynamic field in the footer that is located in the layout master, however, I am not able to return the data in it, I could not find a solution to my problem.

The main route is configured to receive the home view, set in the controller to send the data to view, in this view I can view the data correctly, but only in it, but now I need to visualize this same data in the footer of the page and then I would need to insert this piece in the footer to receive the values.

<?php
for ($i=0; $i < $maiorTamanho; $i++) {
  echo '<tr>';
    if(sizeof($dataTim) > $i)
    {
      echo '<td>'. $dataTim[$i]->numero .'</td>';
    }
    else {
      echo '<td></td>';
    }

    if(sizeof($dataVivo) > $i)
    {
      echo '<td>'. $dataVivo[$i]->numero .'</td>';
    }
    else {
      echo '<td></td>';
    }

    if(sizeof($dataClaro) > $i)
    {
      echo '<td>'. $dataClaro[$i]->numero .'</td>';
    }
    else {
      echo '<td></td>';
    }

    if(sizeof($dataOi) > $i)
    {
      echo '<td>'. $dataOi[$i]->numero .'</td>';
    }
    else {
      echo '<td></td>';
    }
  echo '</tr>';
}
?>

What I need to do to return the values in the master layout?

1 answer

0


Returning any data specifically to the "master" layout is not possible.

One of the solutions would be to instantiate the model directly in the view.

for example:

@foreach(\Auth::user()->notifications()->orderby('id', 'desc')->limit(10)->pluck('data') as $notification)
    <li>
         <a>
             <span class="bold">
                 <span>
                      {{$notification[0]['title']}}
                 </span>
             </span>
             <br>
             <span class="message">
                 {!! $notification[0]['message'] !!}
             </span>
          </a>
     </li>
@endforeach

Browser other questions tagged

You are not signed in. Login or sign up in order to post.