Reputation: 11
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:
{{-- status --}}
<td>{{ $entry->isBlocked }}</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!
Upvotes: 1
Views: 3061
Reputation: 21
Let's check your code
$status = [
'label' => 'Status',
'name' => 'isBlocked', // your column name
'type' => 'status' // your blade name, e.g status.blade.php
];
$this->crud->addColumn($status);
and inside status.blade.php
{{-- status --}}
<td>{{ $entry->{$column['name'] }}</td>
Any question, please comment
Upvotes: 1