Opest
March 17, 2021, 2:59am
1
I need help on how to filter collections by there group name.
Thank you
Collections are defined as php files inside storage/collections
, so you can’t filter them directly with a database request. Use some simple php instead:
$searchTerm = 'groupname';
$filteredCollections = [];
$allCollections = $app->module('collections')->collections();
$allCollectionsWithUserAccess = $app->module('collections')->getCollectionsInGroup();
foreach($allCollectionsWithUserAccess as $c) {
if (isset($c['group']) && $c['group'] == $searchTerm) {
$filteredCollections[] = $c;
}
}
See also:
foreach (['create', 'read', 'update', 'delete'] as $method) {
$this->app->helper('fs')->rename("{$rulesPath}/{$name}.{$method}.php", "{$rulesPath}/{$to}.{$method}.php");
}
}
$this->app->storage->renameCollection($_collectionSrc, $to, 'collections');
return true;
},
'collections' => function($extended = false) {
$stores = [];
foreach($this->app->helper('fs')->ls('*.collection.php', '#storage:collections') as $path) {
$store = include($path->getPathName());
if ($extended) {
$store['itemsCount'] = $this->count($store['name']);
}
}
return $context;
}
// ACL
$app('acl')->addResource("collections", ['create', 'delete', 'manage']);
$this->module("collections")->extend([
'getCollectionsInGroup' => function($group = null, $extended = false) {
if (!$group) {
$group = $this->app->module('cockpit')->getGroup();
}
$_collections = $this->collections($extended);
$collections = [];
if ($this->app->module('cockpit')->isSuperAdmin()) {
return $_collections;
Opest
March 16, 2021, 1:05am
3
Hi,
By any chance can one get collections of cockpit via there groupname?
Thank you
And please don’t double post your questions. I moved your old thread, because I answered the newer one already.