【问题标题】:Undefined property: Illuminate\Pagination\LengthAwarePaginator::$images未定义属性:Illuminate\Pagination\LengthAwarePaginator::$images
【发布时间】:2021-01-12 02:50:52
【问题描述】:

我试图显示 tinghirs 表格图像字段的图像,但遗憾的是它给了我错误 Undefined property: Illuminate \ Pagination \ LengthAwarePaginator :: $ images

TinghirsController.php

public function index()
    {
       $tinghirs=Tinghir::paginate(48);
       return view('tinghirs.index', ['tinghirs' => $tinghirs]);
    }

index.php

<div class="row mix-grid thumbnails">
                            @if ($tinghirs->images)
                            @foreach (json_decode($tinghirs->images, true) as $images)
                            <div class="col-md-6 col-xs-6 mix cat_nature cat_all">
                                <a class="thumbnail-item">
                                    <img src="{{ Voyager::image($images) }}" style="width:600px;height:400px">
                                    <div class="thumbnail-info">
                                        <p>Curabitur ut lorem id tellus malesuada tincidunt et eget purus</p>
                                        <button class="btn btn-primary"><span class="fa fa-link"></span></button>
                                        <button class="btn btn-primary"><span class="fa fa-eye"></span></button>
                                    </div>
                                </a>
                            </div>
                            @endforeach
                            @endif
                    </div>

【问题讨论】:

标签: php laravel thumbnails


【解决方案1】:

您返回一个分页器对象,您要么必须在其上调用items(),要么对其进行迭代。

我想代码可能与此类似。你使用 json decode 的方式看起来很奇怪,你可能做错了什么。

@foreach(($tinghirs as $tinghir)
    <div class="col-md-6 col-xs-6 mix cat_nature cat_all">
        <a class="thumbnail-item">
            <img src="{{ Voyager::image($tinghir->images) }}" style="width:600px;height:400px">
            <div class="thumbnail-info">
            <p>Curabitur ut lorem id tellus malesuada tincidunt et eget purus</p>
            <button class="btn btn-primary"><span class="fa fa-link"></span>                 </button>
            <button class="btn btn-primary"><span class="fa fa-eye"></span></button>
        </a>
    </div>
@endforeach 

【讨论】:

    猜你喜欢
    • 2019-07-11
    • 2016-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多