小编use*_*432的帖子

为什么没有找到Laravel trashed()方法>

我正在尝试在Laravel 4.1中使用Elequent ORM的软删除功能

删除记录按预期工作,但是当我使用withTrashed()搜索结果然后使用trashed()检查它是否是软删除记录时出现以下错误

调用未定义的方法Illuminate\Database\Eloquent\Collection :: trashed()

这是我的代码.有什么建议?

$product = Product::withTrashed()->where('url', Input::get("product_url.$key"))->where('prolist_id', $list->id)->get();

if($product->trashed())
{
    $product->restore();
}
Run Code Online (Sandbox Code Playgroud)

php soft-delete laravel eloquent

5
推荐指数
1
解决办法
5677
查看次数

标签 统计

eloquent ×1

laravel ×1

php ×1

soft-delete ×1