I'm trying to fetch data from dynamically different tables depending on which user is logged on and if he is allowed to edit said table, what I thought was going to work was this:
$colaboradores = Colaboradore::where('email', '=', Auth::user()->email)->first();
$tables = DB::connection('mysql2')->select("SHOW TABLES LIKE 'intervencoes\_%'");
foreach ($tables as $object) {
$arrays[] = (array)$object;
}
foreach ($arrays as $array) {
$string = implode('', $array);
$test = $colaboradores->Niveis->$string->id;
}
And it outputs an error on the last bit of code saying
"Trying to get property 'id' of non-object"
I have been looking around for hours but couldn't find anything related.
This is all inside a livewire component by the way.
Thanks in advance.
Edit: