Skip to content

htmlspecialchars(): Argument #1 ($string) must be of type string, Closure given #362

Closed
Laravel-Backpack/CRUD
#5650
@fardeen7337

Description

@fardeen7337

Hello,

I'm working on a Laravel project using Backpack and the Backpack PermissionManager package. I'm encountering a couple of issues related to field configurations in Backpack.

I can't do changing in the Roles table because it's access from vendor folder

checklist_dependency Field: I need to filter roles to show only specific ones (e.g., roles with the name != 'super admin')

[
                // two interconnected entities
                'label' => trans('backpack::permissionmanager.user_role_permission'),
                'field_unique_name' => 'user_role_permission',
                'type' => 'checklist_dependency',
                'name' => 'roles,permissions',
                'subfields' => [
                    'primary' => [

                        'label' => trans('backpack::permissionmanager.roles'),
                        'name' => 'roles', // the method that defines the relationship in your Model
                        'entity' => 'roles', // the method that defines the relationship in your Model
                        'entity_secondary' => 'permissions', // the method that defines the relationship in your Model
                        'attribute' => 'name', // foreign key attribute that is shown to user
                        'model' => config('permission.models.role'), // foreign key model
                        'pivot' => true, // on create&update, do you need to add/delete pivot table entries?]
                        'number_columns' => 3, //can be 1,2,3,4,6
                        'options' => function ($query){
                            $query->where('name','!=' ,'super admin');
                        },

                    ],
                    'secondary' => [
                        'label' => mb_ucfirst(trans('backpack::permissionmanager.permission_plural')),
                        'name' => 'permissions', // the method that defines the relationship in your Model
                        'entity' => 'permissions', // the method that defines the relationship in your Model
                        'entity_primary' => 'roles', // the method that defines the relationship in your Model
                        'attribute' => 'name', // foreign key attribute that is shown to user
                        'model' => config('permission.models.permission'), // foreign key model
                        'pivot' => true, // on create&update, do you need to add/delete pivot table entries?]
                        'number_columns' => 3, //can be 1,2,3,4,6
                    ],
                ],
            ],

I have added this line but getting error htmlspecialchars(): Argument #1 ($string) must be of type string, Closure given

  'options' => function ($query){
                            $query->where('name','!=' ,'super admin');
                        },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions