I'm starting a project in Laravel, and in the sidebar I have a dropdow with a list in which I access the database and I bring information from 3 companies for example, and when I click on one of these companies, I would like to save the value of the id so that I can use this value to insert into the database along with an insert or update in another register, how could I do this?
Controller Method:
public static function emitentes(){
$users = User::where('id', 1)->with('emitentes')->get()->first();
$emp_user = $users->emitentes;
return $emp_user;
}
PHP block requesting information:
@php
use App\Http\Controllers\EmitenteController;
use App\Models\Cliente;
$empresas = EmitenteController::emitentes();
@endphp
Dropdow code:
<li class="dropdown notifications-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-university"></i>
<span class="label label-warning">{{count($empresas)}}</span>
</a>
<ul class="dropdown-menu">
<li class="header">Você pode emitir recibo para {{count($empresas)}} empresas</li>
<li>
<ul class="menu">
@foreach($empresas as $e)
<li><!-- start notification -->
<a href="#">
<i class="fa fa-industry text-aqua"></i> {{$e->name}}
</a>
</li><!-- end notification -->
@endforeach
</ul>
</li>
</ul>
</li>
Sample image: