I have been trying to retrieve data from my database. It was working fine until I started to query words with special characters (I speak Portuguese so we use a lot of accents). In my controller I have:
public function showall() {
$horarios = Horario::All();
$professores = array();
foreach($horarios as $horario) {
$professor_primeiro_nome[$horario - > id] = DB::table('professors') - > where('id', '=', $horario - > professor_id) - > pluck('primeiro_nome');
$professor_primeiro_nome[$horario - > id] =
trim($professor_primeiro_nome[$horario - > id], '[""]');
$professor_ultimo_nome[$horario - > id] = DB::table('professors') - > where('id', '=', $horario - > professor_id) - > pluck('ultimo_nome');
$professor_ultimo_nome[$horario - > id] =
trim($professor_ultimo_nome[$horario - > id], '[""]');
$materias[$horario - > id] = (string) DB::table('materias') - > where('id', '=', $horario - > materia_id) - > pluck('materia');
$materias[$horario - > id] = trim($materias[$horario - > id], '[""]');
}
return View::make('veraulas',
compact('horarios', 'professor_primeiro_nome',
'professor_ultimo_nome', 'materias'));
}
In the view I have:
<!-- Table Headings -->
<thead>
<tr>
<th>Professor</th>
<th>Matéria</th>
<th>Data</th>
<th>Início</th>
<th>Fim</th>
<th>Ver Detalhes da Aula</th>
<th>Editar Aula</th>
<th>Remover Aula</th>
</tr>
</thead>
<!-- Table Body -->
<tbody>
@foreach ($horarios as $horario)
<tr>
<!-- Task Name -->
<td>
<div>{{ $professor_primeiro_nome[$horario->id] }} {{ $professor_ultimo_nome[$horario->id] }}</div>
</td>
<td>
<div>{{ $materias[$horario->id]) }}</div>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
<form>
{{ csrf_field() }}
<button>Ver Detalhes</button>
</form>
</td>
<td>
<form>
{{ csrf_field() }}
<button>Editar</button>
</form>
</td>
<td>
<form>
{{ csrf_field() }} {{ method_field('DELETE') }}
<button>Remover</button>
</form>
</td>
</tr>
@endforeach
</tbody>
The page looks like this:
The words have strange characters...I can I do to solve this?