简体   繁体   中英

call controllers on different sections of my views in laravel 5.5

i want to call multiple controller routs from my views and show their data in different sections of my site.

x<body>
<nav class="navbar navbar-fixed-top navbar-inverse">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">HR Lead</a>
        </div>
        <div id="navbar" class="collapse navbar-collapse">
            <ul class="nav navbar-nav">
                <li class="active"><a href="#">Home</a></li>
                <li><a href="#about">About</a></li>
                <li><a href="#contact">Contact</a></li>
            </ul>
        </div><!-- /.nav-collapse -->
    </div><!-- /.container -->
</nav><!-- /.navbar -->

<div class="container">

    <div class="row row-offcanvas row-offcanvas-right">

        <div class="col-xs-12 col-sm-9">
            <p class="pull-right visible-xs">
                <button type="button" class="btn btn-primary btn-xs" data-toggle="offcanvas">Toggle nav</button>
            </p>
            <div class="jumbotron">
                <h1>{{auth()->user()-> name}}</h1>
                <h1>{{auth()->user()-> id}}</h1>
                <p>{{auth()->user()-> position}}</p>
                <p>{{auth()->user()-> company ->name}}</p>
                <p>{{auth()->user()-> job_post}}</p>
            </div>
                    <div class="row">
                        <?php $user= users::find(auth()->user()) ?>

                        @foreach($user-> job_post as $job_post )
                        <div class="col-xs-6 col-lg-4">
                            <h2>{{$job_post->title}}</h2>
                            <p>{{$job_post-> summary }} </p>
                            <p><a class="btn btn-default" href="#" role="button">View details »</a></p>
                        </div>

                        @endforeach

but it returns

error:"Class 'users' not found"

I have tried different things but not succeed.

您必须使用名称空间,可能类似于:

<?php $user = App\Model\Users::find(auth()->user()) ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM