i'm very new to laravel and need help with a static function problem.
I want to access models within a sub-function created with the eloquent chunk functionality:
class test
{
public static function test_run ()
{
static $GlobalValues = GlobalValues::where("key", "test")->first();
static $Stats = Stats::where("stat", "test")->first();
User::chunk(1000, function ($users) {
... some code ...
%GlobalValues->test = "test";
%GlobalValues->save();
%Stats->statistic1 = 12345;
%Stats->save();
});
}
}
Maybe, if this is possible, i would prefer if i could access to the $GlobalValues all over the application without to query it every time?