1
I can’t get the information from the database.
This is my controller
.
<?php
namespace App\Http\Controllers\Admin;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\registrar;
class registrarcontroller extends Controller
{
public function index()
{
$registros = registrar::all();
return view('admin.registrar.index',compact('registros'));
}
public function adicionar()
{
return view('admin.registrar.adicionar');
}
public function salvar(Request $req)
{
$dados = $req->all();
registrar::create($dados);
return redirect()->route('admin.registrar');
}
public function editar($id)
{
$registro = registrar::find($id);
return view('admin.registrar.editar',compact('registro'));
}
public function buscar($id)
{
$registro = registrar::find($id);
return view('admin.registrar.buscar',compact('registro'));
}
public function atualizar(Request $req, $id)
{
$dados = $req->all();
registrar::find($id)->update($dados);
return redirect()->route('admin.registrar');
}
}
View
@extends('layout.site')
@section('titulo','adicionar')
@section('conteudo')
<div class="container">
<h3 class="center">BUSCAR OCORRÊNCIAS</h3>
<div class="row">
<form class="" action="{{route('admin.registrar.buscar',$registro->id)}}" method="post" enctype="multipart/form-data">
{{ csrf_field() }}
<input type="hidden" name="_method" value="put">
@include('admin.registrar._form')
<button class="btn deep-orange">Buscar</button>
</form>
</div>
</div>
@endsection
Field search
<h3 class="center">LISTA DE OCORRÊNCIAS</h3>
<div class="row">
<table>
<div class="row">
<a>
<input type="text" id="texto" name="buscar" placeholder="Buscar">
</a>
<a class="btn blue" href="{{ route('admin.registrar.buscar') }}">Buscar</a>
<a class="btn blue" href="{{ route('admin.registrar.adicionar') }}">Adicionar</a>
</div>
<thead>
<tr>
<th>Id</th>
<th>Nome</th>
<th>Data-Nasc</th>
<th>Hora ocorrência</th>
<th>Hora chegada</th>
<th>Hora liberação</th>
<th>Numero CNH</th>
<th>CPF</th>
</tr>
</thead>
<tbody>
@foreach($registros as $regitro)
<tr>
<td>{{ $regitro->id }}</td>
<td>{{ $regitro->condutor}}</td>
<td>{{ $regitro->datanasc }}</td>
<td>{{ $regitro->horaoco }}</td>
<td>{{ $regitro->horache }}</td>
<td>{{ $regitro->horalib }}</td>
<td>{{ $regitro->ncnh}}</td>
<td>{{ $regitro->cpf }}</td>
<td>
<a class="btn deep-orange" href="{{ route('admin.registrar.editar',$regitro->id) }}">Editar</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
What’s making it impossible for me to retrieve this data?
What is the result? Any error code? How should the code work?
– Augusto Vasques