Downloads
Stars
Version
This Laravel Nova package adds the functionality to add Resource Cards at the top of pages.
I consider this package feature complete, however I am open to feature requests and pull requests, if there's something you'd like to see feel free to submit an issue.
php: >=7.4
laravel/nova: ^4.0
This package wraps the following Laravel Nova pages and adds the ability to display Resource Cards above them:
As the package is wrapping the pages, it should be fairly robust with regards to Nova Updates.
This package also includes more fine grained control over the pages the cards are displayed on, following the same logic as is used for Fields:
Cards should extend the included ResourceCard
class rather than the standard class, but otherwise can be used like regular cards.
Install the package in to a Laravel app that uses Nova via composer:
composer require formfeed-uk/nova-resource-cards
Create a card according to the Nova Documentation (or use an existing card if you wish to convert it to ResourceCards).
Update your Card to extend ResourceCard instead of Card:
// MyResourceCard.php
...
use Formfeed\ResourceCards\ResourceCard;
class MyResourceCard extends ResourceCard {
...
}
// MyNovaResource.php
use App\MyResourceCard;
...
class MyNovaResource extends Resource {
...
public function cards(NovaRequest $request) {
return [
MyResourceCard::make($request)
];
}
...
}
Optionally chain visibility and authorisations:
public function cards(NovaRequest $request) {
return [
MyResourceCard::make($request)
->onlyOnForms()
->canSee(function ($request) {
return $request->user()->role === "admin";
}),
];
}
It's that simple!
There are a number of parameters available to your card, depending on the page the card is currently on. These parameters are available on the request object as query parameters.
Note: Just because these parameters are available doesn't mean they will be populated for any given request.
Nova Resource Cards is open-sourced software licensed under the MIT license.