F
F
foobarsik2019-11-08 12:56:12
Laravel
foobarsik, 2019-11-08 12:56:12

How to display serial number in Laravel Nova?

I need to display the sequence number (#) of a record in a table in Laravel Nova.
No. | ID
5 | 1244
| 100
3 | 95
2 | 93
1 | 90

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
foobarsik, 2019-11-09
@foobarsik

Added indexQuery to the resource, like the norms.

public static function indexQuery(NovaRequest $request, $query)
    {
        DB::statement(DB::raw('set @count=0'));
        return $query->select(DB::raw('*, (@count:[email protected]+1) AS serial'));
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question