Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ajvanho's avatar
Level 14

public static $model in Resource

/**
     * The model the resource corresponds to.
     *
     * @var string
     */
    public static $model = \App\Models\User::class;

How can we access this parameter in the Resource class? I try this, but doesnt work...

dd($this->model);
0 likes
2 replies
Nakov's avatar

Why static?

You can access it as a static property then: ResourceName::$model

ResourceName should be the name of the class.

1 like
wingly's avatar
wingly
Best Answer
Level 29

If you need the underlying model instance you should use $this->resource

1 like

Please or to participate in this conversation.