Hide/Visible entry

I want to make the collection item “hide”.
That at request through api such element did not return.
Is it possible?
Or just a filter?

There are multiple ways to solve that task.

event before (filter)

Add an event to /cockpit/config/bootstrap.php

if (COCKPIT_API_REQUEST) {

    // optional: check, if admin request...

    $app->on('collections.find.before.my_collection_name', function($name, &$options) {
        $options['filter']['published'] = true;
    }

}

event after

Add an event to /cockpit/config/bootstrap.php

if (COCKPIT_API_REQUEST) {

    $app->on('collections.find.after.my_collection_name', function($name, &$entries) {
        // do some checks with $entries
        // remove specific entry from result or stop app with a 404 or...
    }

}

other

  • permissions file in collections
  • custom api endpoint in /cockpit/config/api/collections/get/my_collection_name.php

Clear. Thanks for the thought :slight_smile: