Support the ongoing development of Laravel.io →
Requests Session
Last updated 1 year ago.
0

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(),
        ];
    }
0

Sign in to participate in this thread!

Eventy

Your banner here too?

judahnator judahnator Joined 17 Jun 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.