Voyager: Tutorial: How to enable soft delete functionality in Voyager | Help: How to see soft deleted records in Browse view?

Created on 20 Sep 2017  路  8Comments  路  Source: the-control-group/voyager

  • Laravel Version: 5.4
  • Voyager Version: 0.11.14
  • PHP Version:
  • Database Driver & Version:

Description:

Hey guys,

I麓m not sure if this is the proper place to write this, if not please let me know.

Enabling soft deletes in Voyager

When creating the table inside Voyager there's a button at the bottom ('Add Soft Deletes') that automatically adds the 'deleted_at' column to the table.

In your model add:

use Illuminate\Database\Eloquent\SoftDeletes; to the top

and then:

class YourModelName extends Model
{
use SoftDeletes;
protected $dates = ['deleted_at'];

That's it, now everytime you delete a record it's not actually deleted, only the deleted_at column gets the current timestamp :)

Help wanted

I would like to see these soft deletions in the browse view, was thinking of adding a button to undelete it. Anyone has any pointers on this?

Thanks in advance!

documentation feature question

Most helpful comment

Thanks!

I've added the tutorial to the docs.

All 8 comments

For the documentation section/tutorial, thanks! If you'd like to propose that addition to the docs, we'd certainly appreciate it!

For the question, that's a feature we'll certainly consider. We already have a Delete button, so that will handle it. Ideally, Voyager should be able to detect if the model supports soft-deletion, and allow for an "undelete" option, potentially with it's own associated permission. I'm not sure on the actual implementation details, but we're always open for PRs if you figure it out!

@fletch3555 Don't thank me, thank you all for creating Voyager!

I think that a good place for this in the docs would be a new entry in the 'Customization' section, but I haven't found a way to suggest the creation of a new section, only to edit the existing ones. Am I missing something?

Ok, I'll look into it, if I figure out a way to do it I'll open a PR :)

Here you go! Made a new page for you: https://voyager.readme.io/docs/enabling-soft-delete

Thanks!

I've added the tutorial to the docs.

Closing as this was added to the docs.

Hey, how the news about a browse menu for trash and restore (soft delete) ?

Is this feature already exist in v1.1 ?

Or still open for the pull request ?

This issue has been closed for 6+ months. Please open your own issue for new questions

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.

Was this page helpful?
0 / 5 - 0 ratings