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

davestewart's avatar

Possible to add additional facade-accessible methods to a model?

I'm just wondering if it's possible to add additional methods to an Eloquent model that can be accessed via the facade?

$props = ShotModel::parsePath($path);

I tried it and it didn't work; I had to make the method static.

0 likes
2 replies
TheNodi's avatar

@davestewart As said in the documentation a facade must extend Illuminate\Support\Facades\Facade and implement getFacadeAccessor. The facade access the Service Container returned by getFacadeAccessor (actually the function must return the name).

In conclusion I think you must register a Service Container which returns an instance of the model and then create a Facade on that. Static method sounds more practical.

davestewart's avatar
davestewart
OP
Best Answer
Level 11

Actually I've checked the base Illuminate class Model and all the common methods there are actually static, so I was labouring under a misapprehension that all the :: methods were accessed via a facade.

Good to know!

Please or to participate in this conversation.