diff options
Diffstat (limited to 'main/app/sprinkles/admin/src/Sprunje/RoleSprunje.php')
-rwxr-xr-x | main/app/sprinkles/admin/src/Sprunje/RoleSprunje.php | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/main/app/sprinkles/admin/src/Sprunje/RoleSprunje.php b/main/app/sprinkles/admin/src/Sprunje/RoleSprunje.php new file mode 100755 index 0000000..c5e0f8b --- /dev/null +++ b/main/app/sprinkles/admin/src/Sprunje/RoleSprunje.php @@ -0,0 +1,67 @@ +<?php +/** + * UserFrosting (http://www.userfrosting.com) + * + * @link https://github.com/userfrosting/UserFrosting + * @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License) + */ +namespace UserFrosting\Sprinkle\Admin\Sprunje; + +use Illuminate\Database\Capsule\Manager as Capsule; +use UserFrosting\Sprinkle\Core\Facades\Debug; +use UserFrosting\Sprinkle\Core\Sprunje\Sprunje; + +/** + * RoleSprunje + * + * Implements Sprunje for the roles API. + * + * @author Alex Weissman (https://alexanderweissman.com) + */ +class RoleSprunje extends Sprunje +{ + protected $name = 'roles'; + + protected $sortable = [ + 'name', + 'description' + ]; + + protected $filterable = [ + 'name', + 'description', + 'info' + ]; + + protected $excludeForAll = [ + 'info' + ]; + + /** + * {@inheritDoc} + */ + protected function baseQuery() + { + return $this->classMapper->createInstance('role')->newQuery(); + } + + /** + * Filter LIKE name OR description. + * + * @param Builder $query + * @param mixed $value + * @return $this + */ + protected function filterInfo($query, $value) + { + // Split value on separator for OR queries + $values = explode($this->orSeparator, $value); + $query->where(function ($query) use ($values) { + foreach ($values as $value) { + $query->orLike('name', $value) + ->orLike('description', $value); + } + }); + return $this; + } +} |