Well, I have this error: 'Route [setor] not defined' when calling my view, but my route is configured.
Route::resource('empresa', 'EmpresaController');
Route::resource('setor', 'SetorController');
Route::resource('departamento', 'DepartamentoController');
Route::resource('funcionario', 'FuncionarioController');
And my Controller code:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Setor;
class SetorController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$setores = Setor::all();
return view('indicador.setor.index', compact('setores'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('indicador.setor.create');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$setor = Setor::create($request->all());
return redirect('setor');
}
There are other objects configured equal this and executing.
And my view:
@extends('template.principal')
@section('pageName')
<h1>Setor</h1>
@endsection
@section('content')
<table class="table">
<div class="col-md-3 col-sm-6 hero-feature">
<thead>
<tr>
<th>Setor</th>
<th>Empresa</th>
</tr>
</thead>
@foreach($setores as $setor)
<tbody>
<tr>
<td>{{ $setor->nome }}</td>
<td>{{ $setor->id_empresa }}</td>
<td><a href="{{ action('SetorController@show', $setor) }}"><span class="glyphicon glyphicon-search"></span></a></td>
<td><a href="{{ action('SetorController@edit', $setor) }}"><span class="glyphicon glyphicon-pencil"></span></a></td>
</tr>
</tbody>
@endforeach
<!--<button href="{{ route('setor.create') }}" type="submit" class="btn btn-default">Adicionar</button>-->
<button type="button" onclick="window.location='{{ route("setor") }}'">Adicinar</button>
</div>
</table>
@endsection
Thanks
mapWebRoutes()
method insideapp\Providers\RouteServiceProvider.php
You could also run following command to check your registered routes
php artisan route:list
You could clear Route cache by using below command and then retry
php artisan route:clear
Hope this will be useful for you.