1
I’m starting a project in Laravel, and at the sidebar I have a dropdow with a list on which I access the database and bring information from 3 companies for example, and when I click on one of these companies, I would like to save the id value so that I can use this value to insert into the bank along with an Insert or update in another register, as I could 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:
Can you give more details?! I could not understand very well. What you have already done?
– viana
See if it helped? i would like to store this value of the company id when I click on one of the list items... for me to use later, if possible put an icon with different color in which I select..
– Ulisses Gimenes
Only PHP even, no Javascript?!
– viana
But you say "use later" means even after browsing other parts of the site/system?
– viana
I would like it to be in php but I think javascript would also give, I think the important thing is that I can use id!
– Ulisses Gimenes
Yes, would it be possible? I can’t use session variable... I don’t know how the Laravel behaves
– Ulisses Gimenes
You can save the id to cookies. You have tried this?
– viana
I didn’t try! how could I do?
– Ulisses Gimenes