For anyone asking, Nova has methods where you can show a specific field on a specific page (index, update etc). So just use the onlyOnIndex() to show the above trimmed code and onlyOnDetail() to show it on the detail page without the displayUsing method
Sep 21, 2020
1
Level 4
Adding displayUsing method to different methods
So I have added fields to nova with the displayUsing() method which I am using to trim down the string to shorten it. I want to shorten it only on the index/table view and not on the show. Currently what I have is this:
Text::make('data')
->displayUsing(function ($text) {
if (strlen($text) > 30) {
return substr($text, 0, 30) . '...';
}
return $text;
}),
Which is correct and I can successfully trim the text down to 30 characters but this applies to all view including show. How can I not trim the show method and just the index?
Level 4
1 like
Please or to participate in this conversation.