laravel-datatables
laravel-datatables copied to clipboard
editColumn with Blade view has no relations
Summary of problem or feature request
When I use the editColumn with the direct function it works but when I use the blade templates it does not take the relations "with" that were declared in Query().
Code snippet of problem
public function query() {
return Ticket::with('latestEditor').....;
}
This is ok
// This is ok
->editColumn('editor', function(Ticket $ticket) {
return $ticket->latestEditor ? $ticket->latestEditor->name : '';
})
That give 'undefined variable: latestEditor'
->editColumn('editor2', 'datatables.editor')
//editor.blade.php
@if($latestEditor)
{{$latestEditor->name}}
@endif
System details
- Operating System W10
- PHP Version 7.4
- Laravel Version 8.12
- Laravel-Datatables Version
"yajra/laravel-datatables-buttons": "^4.13",
"yajra/laravel-datatables-oracle": "^9.18",
"yajra/laravel-datatables-html": "^4.36"
Hi,
Have you tried the name of the column? I think that is the only variable that will pass with the blade, just started yesterday with Datatables for Laravel so i could be wrong here.
->editColumn('editor2', 'datatables.editor')
//editor.blade.php @if($editor2) {{$editor2->name}} @endif
I think I see something here with regards editor variable. It is considered a raw / javascript by the compiler for it to work with DataTables Editor library. Atm, please use another variable name if possible like latestEditor or editor2.
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been inactive for 7 days since being marked as stale.