如何在oil scaffold命令中添加soft-delete?

时间:2015-08-24 15:50:50

标签: php mysql fuelphp fuelphp-orm

我在开发模式下在FuelPHP 1.7.3上运行以下命令:

php oil g scaffold clients long_name:varchar[50] short_name:varchar[3] --updated-at=updated --created-at=created --deleted-at=deleted --soft-delete

它按预期输出以下内容:

Creating migration: /.../dan/fuel/app/migrations/001_create_clients.php
Creating model: /.../dan/fuel/app/classes/model/client.php
Creating controller: /.../dan/fuel/app/classes/controller/clients.php
Creating view: /.../dan/fuel/app/views/clients/index.php
Creating view: /.../dan/fuel/app/views/clients/view.php
Creating view: /.../dan/fuel/app/views/clients/create.php
Creating view: /.../dan/fuel/app/views/clients/edit.php
Creating view: /.../dan/fuel/app/views/clients/_form.php

但是,当我运行migrate命令时,不会使用自定义创建/更新/删除的列名创建表,当您通过前端删除记录时,硬删除记录。

软删除功能不适用于脚手架吗?

如果上述答案是肯定的,那么在生成脚手架后如何添加软删除?

1 个答案:

答案 0 :(得分:1)

显然软删除不适用于脚手架,我使用的技巧是生成tradicinal方式的脚手架,然后使用soft-delete标志重新生成模型,并使用标志-f覆盖文件。

php oil g scaffold ...

php oil g model ... -f --soft-delete