I have a question, I currently have a user registry which is associated with a company, when I register a user I select which company it belongs to, until here all good, I have created a separate table called empresa_users which has the id of company and user, and another with the company and another with the user, the topics is, how can I show once I have logged only the data of the company to which this user belongs ?, I currently have:
$empresas = Empresa::all();
$parents = Empresa::orderBy('nombre', 'ASC')->pluck('nombre', 'empresa_id');
return view('empresa.index', compact('empresas', 'parents'));
which already shows me all the companies ... Any ideas?
With this I already get, for example, the id of the current user:
$userId = Auth::user()->id;