Skip to main content
BackpackForLaravelListing

How to add conditions to the query/listing module in BackpackForLaravel

By November 21, 2020December 25th, 2021No Comments

How to query for a specific role in the admin panel using BackpackForLaravel

1
$this->crud->addClause('role', 'Admin');

How to remove ellipsis on a column for BackpackForLaravel?

One might have any type of column such as relationship, but when the column text is long, it gets truncated. This is not done via CSS, so we need a different kind of solution for this.

I encountered this issue for a Relationship field and the easiest fix was to convert the column to a Closure and then the output is not going to be truncated.

Converting a Relationship to a Closure is easy as it can get.

1
2
3
4
5
6
7
8
9
10
11
$this->crud->addColumn(
    [
        'type'     => "closure",
        'name'     => 'relationship_function',  
        'label'    => 'Label',
        'function' => function($entry) {

            return $entry->relationship_function->column;
        },
    ]
);

How to apply a scope?

1
$this->crud->addClause('active'); // apply a local scope