Laravel“@include”指令使用过滤器

时间:2017-10-25 14:30:04

标签: php laravel laravel-blade

以下代码是Laravel刀片,用于从服务器呈现一些数据。

如果我使用@include指令将下面的代码用于另一个页面,为什么只在Referenced子页面中呈现Auth用户的数据,那么我该如何进行过滤呢?

样本/ table.blade.php

<div style="overflow-x: auto; display:flex;">
<table class="table table-responsive" id="jobs-table">
    <thead>
        <tr>
            <th>Brukernavn</th>
            <th>Kundenavn</th>
            <th>Sted</th>
            <th>Type</th>
            <th>Note</th>
            <th>Starttid</th>
            <th colspan="3">Handling</th>
        </tr>
    </thead>
    <tbody>
    @foreach($jobs as $job)
        <tr>
            <td>{!! $job->user_name !!}</td>
            <td>{!! $job->customer_name !!}</td>
            <td>{!! $job->job_place !!}</td>
            <td>{!! $job->job_type !!}</td>
            <td>{!! $job->note_1 !!}</td>
            <td>{!! $job->created_at !!}</td>
            <td>
                {!! Form::open(['route' => ['jobs.destroy', $job->id], 'method' => 'delete']) !!}
                <div class='btn-group'>
                    <a href="{!! route('jobs.show', [$job->id]) !!}" class='btn btn-info btn-xs'><i class="glyphicon glyphicon-eye-open"></i></a>
                    @can('stop', $job)
                    <a href="{!! route('jobs.edit', [$job->id]) !!}" class='btn btn-warning btn-xs'><i class="glyphicon glyphicon-edit"></i></a>                            
                    {!! Form::button('<i class="glyphicon glyphicon-stop"></i>', ['type' => 'submit', 'class' => 'btn btn-danger btn-xs', 'onclick' => "return confirm('Are you sure to Stop?')"]) !!}
                    @endcan
                </div>
                {!! Form::close() !!}
            </td>
        </tr>
    @endforeach
    </tbody>
</table>
</div>
{{ $jobs->links() }}

引用的子页面

<div style="overflow-x: auto;">
<table class="table table-responsive" id="jobs-table">
    @include('samples.table')
</table>
</div>

0 个答案:

没有答案