Tuesday, May 23, 2017

backpack laravel crud custom column

I have a task - insert a custom column in one of our admin pages, where I can to call method from Model for each entry, generated by backpack CRUD generator. I have found in official documentations statement that looks like what I need here:

https://laravel-backpack.readme.io/v3.0/docs/crud-columns-types#section-roll-your-own

But there is nothing about how to implement this in the controller right way. So I have tried to do just like this

Controller:

$status = [
        'label' => 'Status',
        'name'  => 'status',
        'type'  => 'text'
    ];
$this->crud->addColumn($status);

and as mentinoned in documentation, I have create my own blade file in

resources\views\vendor\backpack\crud\columns

Here it is:


<td></td>

Where isBlocked is method in my Model. I have an error about database and nothing is working. Please say is it even possible to do what I wnat and if it is - please say how to do it right way both in view and controller

Thankyou!



via grim grinn

Advertisement