Initialize user_id globally if user is authenticated in laravel 10

29 Views Asked by At

I'm using Setting package (https://packagist.org/packages/anlutro/l4-settings) in laravel 10 project and there is a feature to use custom settings for each individual user using this method:

<?php
Setting::setExtraColumns(array(
    'user_id' => Auth::user()->id
));

I can do it every time when I need to access or save settings but it's not ideal. How can I set up this feature globally if I need currently authenticated user id?

I tried to set this up inside AppServiceProvider->boot() method, but Auth::user() object is not defined yet in this place.

0

There are 0 best solutions below