Support the ongoing development of Laravel.io →
Database Views Blade
Last updated 2 years ago.
0

To access variables inside a blade when you're returning the view you need to pass an additional associative array argument. For example:

return view('master', ['article' => $article]);

This will allow you to access whatever information you're retrieving from the database or what have you. This can be done in your routes although I don't recommend it. Using a controller is your best bet.

Last updated 9 years ago.
0

I know that, but this is a master.blade.php, so I am not returning any view on a route. It's just used for templating purposes.

0

You can call variable directly from your view file .. example:

@foreach(\App\Product::get() as $product)
         <li><a href="{{ url('product/')}}{{$product->id}}">{{ $product->title }}</a></li>
@endforeach

This mean you'll call the variable directly from your Model ( Product ).

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Lansana lansana Joined 30 Jul 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.