laravel-datatables icon indicating copy to clipboard operation
laravel-datatables copied to clipboard

editColumn with Blade view has no relations

Open victorelec14 opened this issue 4 years ago • 2 comments

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"

victorelec14 avatar May 06 '21 10:05 victorelec14

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

sitenzo avatar Jul 02 '22 18:07 sitenzo

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.

yajra avatar Jul 04 '22 02:07 yajra

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.

github-actions[bot] avatar Nov 21 '22 00:11 github-actions[bot]

This issue was closed because it has been inactive for 7 days since being marked as stale.

github-actions[bot] avatar Nov 29 '22 00:11 github-actions[bot]