Laravel传递对象包括

时间:2017-07-12 11:19:54

标签: laravel

我使用的刀片系统如下:

/layouts/app.blade.php
/includes/side_bar.blade.php
/includes/selectable.blade.php
/project/list.blade.php

所以我有主要的容器应用程序包含侧边栏和yield列表 然后我的列表中包含了可选择的

所以在我的控制器中,当我调用列表时,我传递了一个对象。如何将此对象传递给可选择的include?

我在list.blade.php中尝试过这样的事情:

@include('includes.selectable', array('authUsersForDataView' => $authUsersForDataView))

它不会产生错误,但它不会评估对象,而是将其作为文本。以下是我尝试访问该页面时来自view-source的示例:

<!-- Window -->
<div class="row">
  <div class="col-md-12 col-sm-12 col-xs-12">
    <div class="x_panel">

      <!-- Window title -->
      <div class="x_title">
        <h2>Tools</small></h2>
        <ul class="nav navbar-right panel_toolbox">
          <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a></li>
        </ul>
        <div class="clearfix"></div>
      </div>
      <!-- Window title -->

      <!-- Window content -->
      <div class="x_content">
        <br />
          <div class="row">
            <div class="form-group col-xs-2">
              <label for="month" class="control-label">Year</label>
              <select class="form-control select2" style="width: 100%;" id="year" name="year" data-placeholder="Select a year">
                @foreach($authUsersForDataView->year_list as $key => $value)
                <option value="{{ $key }}"
                  @if(isset($authUsersForDataView->year_selected) && $key == $authUsersForDataView->year_selected) selected
                  @endif>
                  {{ $value }}
                </option>
                @endforeach
              </select>
            </div>
            <div class="form-group col-xs-2">
              <label for="manager" class="control-label">Manager</label>
              <select class="form-control select2" style="width: 100%;" id="manager" name="manager" data-placeholder="Select a manager" multiple="multiple">
                @foreach($authUsersForDataView->manager_list as $key => $value)
                <option value="{{ $key }}"
                  @if(isset($authUsersForDataView->manager_selected) && $key == $authUsersForDataView->manager_selected) selected
                  @endif>
                  {{ $value }}
                </option>
                @endforeach
              </select>
            </div>
            <div class="form-group col-xs-2">
              <label for="user" class="control-label">User</label>
              <select class="form-control select2" style="width: 100%;" id="user" name="user" data-placeholder="Select a user" multiple="multiple">
                @foreach($authUsersForDataView->user_list as $key => $value)
                <option value="{{ $key }}"
                  @if(isset($authUsersForDataView->user_selected) && $key == $authUsersForDataView->user_selected) selected
                  @endif>
                  {{ $value }}
                </option>
                @endforeach
              </select>
            </div>
          </div>
      </div>
      <!-- Window content -->

      <!-- Window script -->
      <script>
        $(document).ready(function() {
          //Init select2 boxes
          $("#year").select2({
            allowClear: false,
            disabled: {{ $authUsersForDataView->year_select_disabled }}
          });
          //Init select2 boxes
          $("#manager").select2({
            allowClear: false,
            disabled: {{ $authUsersForDataView->manager_select_disabled }}
          });
          //Init select2 boxes
          $("#user").select2({
            allowClear: false,
            disabled: {{ $authUsersForDataView->user_select_disabled }}
          });
        });
      </script>
      <!-- Window script -->

    </div>
  </div>
</div>
<!-- Window -->

您可以看到刀片中的脚本是作为文本放置而不是评估...

0 个答案:

没有答案