Categories: Laravel

How to Pass Value from Model to all the views in Laravel ? with video

It is a bit tricky to pass all the values to the view from the model in laravel.

First of all, make controllers and model is a must. I believe you have already done this

In controller:

View::composer('*', function($views){
$views->with('settings', App\Setting::all());
});

 

In Views: (according to my video)

@foreach($settings as $setting)
@if($setting->facebook!=null)
<a class="iconfont-wrapper" href="{{$setting->facebook}}" target="_blank">
<span class="p-2 mbr-iconfont socicon-facebook socicon"></span>
</a>
@endif
@if($setting->twitter!=null)
<a class="iconfont-wrapper" href="{{$setting->twitter}}" target="_blank">
<span class="p-2 mbr-iconfont socicon-twitter socicon"></span>
</a>
@endif
@endforeach

Video:

jaminrai

Share
Published by
jaminrai

Recent Posts

Computer Science Project Report Guidelines and Sample

Guidelines (Click Below to Download) SAMPLE 1 SAMPLE 2

4 months ago

Skype Closes Its Doors After 20 Years: A Look Back and the Apps That Faded with It

After 20 years of transforming global communication, Skype has officially ceased operations. Microsoft, which purchased…

11 months ago

The Duck and the Tortoise: A Tale of Patience and Teamwork

In a serene forest by the edge of a sparkling lake, there lived a cheerful…

12 months ago