如何修复Undefined变量:Laravel 5.2中的协作者

时间:2017-09-27 17:00:32

标签: php laravel-5

在我的laravel应用程序中。我在视图文件的协作者文件夹中有form.blade.php文件。协作者/ form.blade.php

<div class="col-md-4" style="border:1px solid #ccc;margin-left:15px;padding:10px;">
        <h4 class="page-header">
            Collaborators
        </h4>
        @if( $collaborators)
           @foreach( $collaborators as $collaborator)
                <div>
                    <div>
                        <span>
                            <img src="{{ $collaborator->user()->first()->getAvatarUrl() }}" />
                        </span>
                    </div>
                    <button class="btn btn-sm btn-danger delete" style="margin-top:5px;padding:4px;width:35px;"
                      data-action="/projects/{{ $project->id }}/collaborators/{{ $collaborator->collaborator_id }}"
                      data-token="{{csrf_token()}}">
                    <i class="fa fa-trash-o"></i>
                    </button>
                </div>
                <hr/>
           @endforeach
        @endif

它包含项目文件夹projects / users.blade.php中的users.blade.php文件

@include('collaborators.form')

但我得到了这个错误按摩

Undefined variable: collaborators (View: C:\Users\Flex\Desktop\mati\resources\views\collaborators\form.blade.php)

0 个答案:

没有答案