2
I am developing a project of "loans" of things of a company and I am locked in a module of keys. So I don’t have much experience in the Laravel, so I came across the following situation:
Database - I have a table LOCAL that correlates with several keys. ( a location needs one or more keys to open ) - I have a table TIPO_CHAVE. (ex. standard type 1, standard 2 and so on) - I have a table LOCAL_TIPO_CHAVE connecting the LOCAL at the TIPO_CHAVE
So far so good, I list all the places right, the problem happens when I relate the keys to this site.
Controller (Localcontroller)
public function index()
{
$localchaves = \App\LocalChave::orderBy('id_local');
$locais = \App\Local::orderBy('id_local')->get();
return view('site.index', compact('locais', 'localchaves '));
}
View (index.blade.php
...
@if($locais)
@foreach($locais as $local)
{{$strchave = ""}}
{{$chaveslocal = $localchaves->where('id_local', '=', $local->id_local)->get()}};
@foreach($chaveslocal as $chavelocal)
{{$strchave = '<br>' + $chavelocal->tipochave->descricao}};
@endforeach
@endforeach
@endif
...
<a href='/local/chave' onMouseOver="toolTip('Clique para Editar as Chaves {{$strchave}}')" onMouseOut="toolTip()">Chave(s)</a>
...
The variable does not receive the correct value and the values that are inside the {{}} keys appear as an echo.
Ex. in the middle of the page appears
$strchave = ""; [{"id_local_key":"1","created_at":"2016-06-16 17:32:00","updated_at":"2016-06-16 17:32:00","id_tipo_key":"1","id_local":"1"}]; $strchave = ' ' + Mul-t-lock M1;
The value I wish the variable $strchave possess is for example
'<br> Padrão 1 <br> Padrão 2'
I tried to google several ways, but I’m not finding the right terms for this search.
Very good, I’ll test you this way. I end up prioritizing development and do not stop to read, small details that are in the manual end up solving big things. Thanks for the tips!
– Apolônio Serafim