How to add soft-delete to oil scaffold command?

129 views Asked by At

I am running the command below on FuelPHP 1.7.3 in development mode:

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

And it outputs the below as expected:

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

However, when I run the migrate command the table isn't being created with the custom created/updated/deleted column names and when you delete the record via front-end it hard deletes the record.

Does the soft-delete function not work with scaffolding?

If the answer to the above is yes then how should I go about adding the soft delete after generating the scaffold?

1

There are 1 answers

0
saulopaiva On BEST ANSWER

Apparently the soft-delete does not work with the scaffolding, a trick i use is to generate the scaffold of tradicinal way, and then regenerate the model with the soft-delete flag, and the flag -f to overwrite the file.

php oil g scaffold ...

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