0

in My laravel app. I have form.blade.php file in collaborator folder of view file. collaborators/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

it include with users.blade.php file in projects folder projects/users.blade.php

@include('collaborators.form')

but I got this error massages

Undefined variable: collaborators (View: C:\Users\Flex\Desktop\mati\resources\views\collaborators\form.blade.php)
Lilan
  • 153
  • 1
  • 3
  • 14
  • Next to having a view, you also need to set somehow the variables for that view. That part is missing in your question but (from the error message) obviously necessary if only to tell you more. – hakre Sep 27 '17 at 17:02
  • what did you mean? – Lilan Sep 27 '17 at 17:05
  • I mean: If you don't define the variable, it is undefined. The part where you define your variables is missing. But see the duplicate question, it looks like someone else had the exact same problem (and that question shows where to define the variables for the blade view) – hakre Sep 27 '17 at 17:11
  • I have not any controller for this? – Lilan Sep 27 '17 at 17:14
  • 1
    No idea, technically you don't need a controller but where you invoke the templating that generates the error, there you need to pass the variables for the view (that is also called "defining variables"). – hakre Sep 27 '17 at 17:22

0 Answers0