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

thomasm789's avatar

Overriding $hidden variable

Hey All,

I'm having quite a bit of a brain burp!

I wish to override the variable $hidden found within the vendor/laravel/spark/src/token.php file.

How can I achieve this without needing to keep the edited file in the vendor folder?

I tried copying the file into app/ directory however the changes are not overridden.

Thanks in advance

0 likes
3 replies
ejdelmonico's avatar

That variable you referenced is actually an override for the same variable in /vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php so you should be able to override it again.

thomasm789's avatar
thomasm789
OP
Best Answer
Level 1

Yeah I thought so, I recreated a copy of Token.php in the main app folder however I'm not entirely sure how to make sure it overrides.. everything I've tried just doesn't seem to work.. even adding a new service provider hasn't worked

1 like
ejdelmonico's avatar

Your could try putting the $hidden array in the user.ph of app to check if it overrides .make sure you clear cached data through artisan.

Please or to participate in this conversation.