Nova Perspectives
Visit this package on GitHub

Perspective Slugs

Each perspective has a slug which is automatically generated from the class name.
In the class name, the perspective is not used the ending Perspective word if it ends with Perspective.
Str::slug(Str::kebab($class));

Examples of generated slugs:

Perspective Class Perspective Slug
AdministrationPerspectivePerspective administration-perspective
Administration administration
AdministrationPerspective administration
ContentPerspective content
OrderPerspective order
SiteCommunityPerspective site-community

Each slug must be unique!

You can list all perspectives include slug by calling the perspective:list command:

php artisan perspective:list

Or alternative with class basename's:

php artisan perspective:list --basename

You can define another slug in each Perspective class:

use NormanHuth\NovaPerspectives\Perspective;
 
class MyPerspective extends Perspective
{
/**
* Custom perspective slug.
*
* @var string|null
*/
public ?string $perspectiveSlug = 'my-custom-slug';
}

This package add the perspective-{PerspectiveSlug} class to the HTML Tag in the Nova administration.

This package add the current perspective slug to the Request. You get the current perspective with $request->input('viaPerspective') or $request->viaPerspective.
Examples:

class User extends Resource
{
/**
* Get the fields displayed by the resource.
*
* @param NovaRequest $request
* @return array
*/
public function fields(NovaRequest $request): array
{
if ($request->input('viaPerspective') == 'administration') {
return [
// ...
];
}
return [
// ...
];
}
 
/**
* Get the cards available for the request.
*
* @param NovaRequest $request
* @return array
*/
public function cards(NovaRequest $request): array
{
if ($request->viaPerspective == 'content') {
return [
// ...
];
}
return [
// ...
];
}
}