0

I'm new to laravel-inertia-vue3. I have following code in controller.

$revenue = QueryBuilder::for(DailyRevenue::class)->with('tax')->paginate(50);
    return Inertia::render('DailyRevenue/Index', ['revenue' => $revenue])->table(function (InertiaTable $table) {
        $table->column('id', 'id', searchable: true, sortable: true);
        $table->column('date', 'date', searchable: true, sortable: true);
        $table->column('tax', "tax");
        $table->column('amount', 'amount',  sortable: true);

Tax and DailyRevenue are two models and DailyRevenue belongs to tax. I have following code in DailyRevenue model.

 public function tax(){
    return $this->belongsTo(Tax::class);
}

In index.vue file I have following code:

 <Table :resource="revenue"/>

There is a column called tax_name in Tax model. I want to display tax_name in the table but unable to add column from controller. Is there any way to do this? Thanks in advance.

1 Answer 1

0

It was so simple. I found following solution. It worked perfectly.

<Table :resource="revenue">
         <template #cell(tax_name)="{ item: tax }">
                  {{tax.tax.tax_name}}
         </template>
 </Table>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.