试图在覆盖的部分刀片中获取非对象的属性“名称”

I have this in my layoutblade.php :

@section('content')
<h2>Title of the site</h2>
<p>other content</p>
    {{ $myVariable }}
@show

I have this in my test.blade.php

@extends('layout')
@section('content')
    other content
@endsection

but, in this view, I have undefined variable, it overwritten the view, but not the variable, help me.

//layout

@yield('content')



//test.blade.php

    @extends('layout')
    @section('content')
       {{ $myVariable }}
        other content
    @endsection

then your {{ $myVariable }} should be outputted from your controller like this:

$data['myVariable']='';

return view('test',$data)

on your controller you can do something like this:

if($myVariable==''){
  $data['myVariable']==''
  rerurn view('blade', $data)
}
else{

  $data['myVariable']== //load data to the variable
  rerurn view('blade', $data)
}