繁体   English   中英

使用 eloquent 删除记录

[英]Delete records with eloquent

我开始使用 eloquent 作为我的 ORM。 我的旧数据库有一个名为 deleted 的列,但 eloquent 使用带时间戳的列名 deleted_at。

如果deleted = 1 或deleted_at = timestamp,有没有办法考虑软删除记录?

If you are using Laravel, look into this documentation https://laravel.com/api/8.x/Illuminate/Database/Eloquent/SoftDeletes.html https://laravel.com/docs/8.x/eloquent#soft - 删除

use Illuminate\Database\Eloquent\SoftDeletes;

class YourModelName extends MainModel
{
    use SoftDeletes;
    const DELETED_AT = 'deleted '; // your custom column name
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM