【发布时间】:2021-09-15 21:55:32
【问题描述】:
我正在使用 Laravel 5.8 开发我的项目,在这个项目中,我想检查用户的购物车价格是否超过自定义数字(也应该从数据库中获取),然后打印 @ 987654323@.
所以为了做到这一点,我添加了这个:
@foreach(\App\Shop\ProductDelivery::find(1) as $delivery)
@if($cartPrice >= $delivery->price)
<i>
You delivery is free
</i>
@endif
@endforeach
但它显示了这个错误:
试图获取非对象的属性“价格”
参考这一行:
<?php if($cartPrice >= $delivery->price): ?>
然而价格已经存在于数据库中:
那么这里出了什么问题?我该如何解决这个问题?
【问题讨论】:
标签: php laravel eloquent laravel-5.8