creagia/nova-percentage-card
A Laravel Nova card for displaying percentage-based metrics as a clean visual progress indicator. Ideal for dashboards, it highlights completion rates, goals, and other percentage values at a glance.
The 2.1.0 release adds a Get ResourceID capability — a first-class way to resolve the resource identifier for the current request/route/model without hand-rolling $request->route('id') or digging through route parameters. Start here:
Confirm the install — the package should already be in composer.json. If not:
composer require <vendor>/<package>:^2.1
Check for publishable config (only if you need to override defaults):
php artisan vendor:publish --provider="<Vendor>\<Package>\<Package>ServiceProvider"
Verify the version actually landed — release notes are terse, so prove the method exists before you build on it:
composer show <vendor>/<package>
php artisan about # if the package registers a line here
First use case — the canonical one is resolving the resource being acted on inside a controller, form request, policy, or listener where you don't want to re-parse the route:
use <Vendor>\<Package>\Facades\<Package>;
public function show(Request $request)
{
$id = <Package>::resourceId(); // or the documented equivalent
return Post::findOrFail($id);
}
Look first at the package's facade/helper entry point and its service provider bindings — that tells you whether the ID is resolved from the route, the request, or a bound model. Then check whether the new release ships a config key (e.g. a route-parameter name) so you know what it assumes about your routes: the default is usually {id}, and an {post} binding will silently miss.
Controller / Form Request resolution. The most common integration is letting the package own the "which resource?" question instead of repeating route-parameter names across the codebase:
class UpdatePostRequest extends FormRequest
{
public function rules(): array
{
return [
'title' => ['required', 'string'],
// authorize against the resolved ID rather than a magic string
'slug' => [Rule::unique('posts', 'slug')
->ignore(<Package>::resourceId())],
];
}
}
Policy and gate integration. Resource IDs are frequently needed before you have a model instance. Resolve the ID, then the model, then authorize — keep that order explicit so the 404-vs-403 distinction stays correct:
Gate::authorize('update', Post::findOrFail(<Package>::resourceId()));
Cross-checking against route model binding. If you already use implicit binding (Post $post), treat the package's ID as the raw identifier and the bound model as the hydrated one. Don't mix them in one method — pick one source of truth per action, otherwise you get two database round-trips and confusing behaviour when a route uses a non-ID binding key like {post:slug}.
Nested resources. For /posts/{post}/comments/{comment}, this is exactly where a generic resourceId() gets dangerous. Explicitly scope:
$commentId = <Package>::resourceId(); // which one? post or comment?
$post = Post::findOrFail($request->route('post'));
$comment = $post->comments()->findOrFail($commentId);
Always scope the resolved ID through its parent relationship rather than trusting it globally — that's a tenancy/authorization win, not just a style preference.
Queues and jobs. If the helper resolves from the current request, it will be empty or wrong inside a queued job. Pass the ID into the job constructor explicitly and resolve the model in handle(); don't call the helper from a job context.
int|string|null, throws when nothing is resolvable, or returns null. Read the source or the test suite before wiring it into a policy — a silent null reaching findOrFail produces a 404 where you expected a 403.$request->route('id') or Model::getRouteKey(). It's package-specific; new team members will not recognise it. Keep usage concentrated in a small number of places, or wrap it in your own thin helper so swapping it out later is a one-file change.{post} instead of {id}, the resolver may miss. Check whether 2.1.0 exposes a config option for the parameter name; if not, standardise route parameter naming across the app.$this->route(...) or pass the ID as a public property instead. In API routes, make sure the package isn't expecting a web-session-bound resource.dd($request->route()->parameters(), <Package>::resourceId());
Nine times out of ten the route parameter key differs from what the package expects.composer update rather than assuming a minor bump is inert.How can I help you explore Laravel packages today?