Im running into a problem with a schedule.
I have a XML which needs to run every 5 minutes and check if a new user has been added to the XML.
My kernel to trigger the schedule:
protected function schedule(Schedule $schedule)
{
$schedule->call('App\Http\Controllers\UsersController@importDebtorsXML')->name('importdebtorsXML');
}
The controller which runs the XML:
public function importDebtorsXML() {
$xml = simplexml_load_file(base_path('/xmlpath'));
foreach($xml->Accounts->Account as $account){
$accountcode = (string) $account["code"];
$users = User::all();
foreach($users as $user) {
if($user->username == $accountcode) {
dd('skip');
}
}
}
}
The foreach Accounts from the XML runs perfectly. But it doens't run the second foreach inside this foreach...
If i :
dd($users[2]);
Beneath the $users it works.
It just doesn't run the foreach..
Any help is appreciated.
via Jordy Groote