I use custom class as library in Laravel:
class Settings
{
public function __construct($data = [])
{
$this->settings = Setting::find(Auth::user()->id);
var_dump($this->settings); die();
}
}
And call this:
$settings = new Settings($request->settings);
$settings->pre_update();
When first call constructor I get var_dump($this->settings); die(); as null, after method pre_update() adds data to data.
But after second click, when in data there is data and $request->settings should not be null.
Why I get null after second click?
Maybe all custom classes in laravel works as static?
via Darama