我从第一次运行Laravel应用程序时得到的错误  是:

"Trying to get property of non-object"

来自文件:

"resources/views/partials/contentheader.blade.php" in the line 6.

代码是:

<div id="page-title">
<h2>
    @section('contentheader') 
        {{ settings('site_name') }}
        <small style=" font-size: 12px; letter-spacing: 2px;">
            <b>{{Auth::user()->warehouse->name}}</b>
        </small>
    @show
</h2>
<p>@section('contentheader_description') Inventory @show</p>
<ol class="breadcrumb">
    <li>
        <a href="{{route('home')}}">
            <i class="fa fa-dashboard"></i> 
            {{trans('core.dashboard')}}
        </a>
    </li>
    <li class="active">
        @section('breadcrumb')

        @show
    </li>
</ol>

分析解答

只需使用此代码替换第6行中的代码即可 isset(Auth::user()->warehouse)?Auth::user()->warehouse->name:' '