0
嗯,我有这个错误:'路由[setor]未定义'时调用我的看法,但我的路线配置。Laravel路由错误
Route::resource('empresa', 'EmpresaController');
Route::resource('setor', 'SetorController');
Route::resource('departamento', 'DepartamentoController');
Route::resource('funcionario', 'FuncionarioController');
我的控制器代码:
<?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');
}
有配置这种平等和执行其他对象。
而我的观点:
@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('[email protected]', $setor) }}"><span class="glyphicon glyphicon-search"></span></a></td>
<td><a href="{{ action('[email protected]', $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
感谢
你能发布更多的路线文件或你的控制器吗? – Daniel
没问题,我确实把信息 –
请妥善缩进你的代码。 – Marcs