This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

planetadeleste
planetadeleste

How can I show the soft deleted (http://laravel.com/docs/eloquent#soft-deleting) elements as a list. Same format of the active elements.?

thanks

daftspunky
daftspunky

Add this to your Controller

    public function listExtendQuery($query)
    {
        $query->withTrashed();
    }

    public function formExtendQuery($query)
    {
        $query->withTrashed();
    }
planetadeleste
planetadeleste

Thanks @daftspunk

But the idea is to have a list of trashed items and a list of active items. Sorry if my question was not so clear. I want to reuse the active list, but filtering by soft deleted / active.

Thanks and sorry my english.

Last updated

d.negativa
d.negativa

Thanks @daftspunk!
@planetadeleste, we seem to have have found a solution with a partner
If your template contains this


$this->listRender('trashed')

then you need to add a condition


    public function listExtendQuery($query, $definition)
    {
        if ($definition == 'trashed')
        {
            $query->onlyTrashed();
        }
    }

Last updated

slowpokefarm
slowpokefarm

d.negativa said:

Thanks @daftspunk!
@planetadeleste, we seem to have have found a solution with a partner
If your template contains this


$this->listRender('trashed')

then you need to add a condition


   public function listExtendQuery($query, $definition)
   {
       if ($definition == 'trashed')
       {
           $query->onlyTrashed();
       }
   }

You also need to add a config for that definition in your Controller:

    public $listConfig = [
        'list' => 'config_list.yaml',
        'trashed' => 'config_list_trashed.yaml'
    ];
d.negativa
d.negativa

@slowpokefarm

++

wurin7i
wurin7i

october is awesome...

phplee
phplee

HI guy, i have one question. how do i make a list view to show the trashed list. so on the toolbar of my list i have a view trashed button which directs to /trashed.

thanks

1-8 of 8

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.