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

Class XII | Assignment 2 ( C Structure)

STRUCTURE (Submit after Mid Term , 15 Ashad 2083) A) MCQ 1. What is the…

6 days ago

Class XII Assignment 1 ( C Function )

FUNCTION (Assignment) Submit Before Mid Term MCQ 1. What is the output of this statement…

6 days ago

Evolution History of computer Technology

Evolution History of computer Technology (HISTORY OF COMPUTER) Evolution of computer is a study of…

4 weeks ago

Maturity of Enterprise Architecture Practice

Maturity of Enterprise Architecture Practice Maturity of Enterprise Architecture Practice   DOWNLOAD

2 months ago