Laravel Nova - How to determine the view (index, detail, form) you are in for a resource's computed field?
问题 I would like to return a different result for a computed field when viewing the index view than when viewing the detail view of a resource. Basically something like viewIs() below: Text::make('Preview', function () { if($this->viewIs('index'){ return \small_preview($this->image); } return \large_preview($this->image); })->asHtml(), 回答1: You can check the class of the request: Text::make('Preview', function () use ($request) { if ($request instanceof \Laravel\Nova\Http\Requests