I would love a more officially supported option, but this is what I have as a temporary solution:
/**
* Get the cards available for the request.
*
* @param Request $request
* @return array
*/
public function cards(Request $request)
{
// Grab the resource UUID from the request
preg_match(
'/([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}){1}/',
$request->path(),
$matches
);
/** @var WebsiteModel $model */
$model = $this->model()->newModelQuery()->findOrNew(reset($matches));
return [
(new WebsiteMetrics\Clicks($model))->onlyOnDetail(),
(new WebsiteMetrics\PageViews($model))->onlyOnDetail(),
];
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community