未定义属性:Illuminate \ Pagination \ LengthAwarePaginator :: $ id(查看:F:\ project esources \ views \ admin \ carousels \ index.blade.php)

when I try to pass variable data to view I get this error, I can't find any document about this problem My controller(CarouselController.php)

    public function index()
{
$carousels = Carousel::orderBy('created_at', 'asc')->paginate(12);
return view('admin.carousels.index')->withCarousels($carousels);
}

My view(index.blade.php)

<div class="row">
    <div class="col-md-9">
        <h1>All Images</h1>
    </div>
    <div class="col-md-3">
        <a href="{{ route('carousels.create') }}" class="btn btn-lg btn-block btn-primary  ">Create New carousel</a>
    </div>
    <div class="col-md-12">
        <hr>
    </div>
</div>{{-- end of the row --}}
<div class="row">
    <div class="col-md-12">
            <div class="row">
     @foreach($carousels as $photo)
        <div class="col-xs-6 col-md-3">
        {!!  Form::open( array('route'=>array('carousels.destroy', $carousels->id),'method'=>'DELETE')) !!}

        {!! Form::submit('Delete', array('class'=>"btn btn-danger btn-sm tours-delete tour-index-delete"))!!}

        {!! Form::close() !!}
        <a href="{{ url($photo->path) }}" class="thumbnail" data-lity>
        <img class="img-responsive" src="{{ $photo->path }}" alt="">
        </a>
        </div>
     @endforeach

</div>
    </div>
    <div class="text-center">
            {!! $carousels->links(); !!}
    </div>
</div>

You foreach loop contains the code:

$carousels->id;

which seems to be getting a single object from collection, which isn't the right way, you should try this:

@foreach($carousels as $carousel)
  <div class="col-xs-6 col-md-3">
  {!!  Form::open( array('route'=>array('carousels.destroy', $carousel->id),'method'=>'DELETE')) !!}

  {!! Form::submit('Delete', array('class'=>"btn btn-danger btn-sm tours-delete tour-index-delete"))!!}

  {!! Form::close() !!}
  <a href="{{ url($carousel->path) }}" class="thumbnail" data-lity>
  <img class="img-responsive" src="{{ $carousel->path }}" alt="">
  </a>
  </div>
@endforeach

Hope this helps!