如何在模型上定义withTrased? (Laravel 5.3)

时间:2017-03-17 10:05:23

标签: mongodb laravel laravel-5.3 soft-delete laravel-eloquent

我的模型是这样的:

<?php
namespace App\Models;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent; 
use Jenssegers\Mongodb\Eloquent\HybridRelations;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
class Message extends Eloquent
{
    use HybridRelations;  
    use SoftDeletes; 
    protected $connection = 'mongodb';
    protected $dates = ['deleted_at'];
    protected $fillable = ['subject', 'information', 'created_at', 'update_at'];
}

如果我从这样的模型中获取数据:

Message::withTrashed()->find($id);

我成功获取了带有删除的数据

但我想在模型上定义它

所以当我打电话时:

Message::find($id);

它还可以使用已删除的数据

我该怎么做?

0 个答案:

没有答案