Below is my views and controllers i want $name variable to be accessible in navbar view which is included in master view. does anybody know a solution ?
userController.php
public function index($var){
$u_array = $var;
$name = $u_array->name;
return view('index',compact(name));
}
master.blade.php
@include('navbar')
<section class="main-container">
@yield('content')
</section>
index.blade.php
@extends('master')
@section('content')
<h2>{{$name}}</h2>
@endsection
navbar.blade.php
<h1>{{$name}}</h1>