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
Unfortunately, @Chin's answer did not work for me as for Edit view the request class is just a basic Laravel\Nova\Http\Request
class.
My workaround to check if this is an index view is as follows:
/**
* Check if the current view is an index view.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @return bool
*/
public function isIndex($request)
{
return $request->resourceId === null;
}