Table builder with created_by_id

emergingdzns - 3 months ago

How do I add the created_by_id column to the table builder so that it shows the user's name in the table that corresponds to the user id? I tried doing entry.created_by_id.presenter.name in the $columns array but it's empty.

Answer

- 3 months ago

        'entry.created_by_id' => [
            'wrapper' => '{{ user({value}).display_name }}'
        ],

piterden - 3 months ago

        'entry.created_by_id' => [
            'wrapper' => '{{ user({value}).display_name }}'
        ],

emergingdzns - 3 months ago

Thanks man! You're a life saver.

ryanthompson - 3 months ago

You can also use entry.created_by.display_name which basically walks through the relationship. @piterden is also correct but just a different approach - using the view parser. But it will cause extra queries even if you're autoloading.