路线 [X.store] 未定义 :S
Route [X.store] not defined :S
我正在做一个简单的表单来将数据发送到数据库,当我提交它时出现标题错误。
我想我定义的一切都是完美的,但我不明白我失败的地方。
Symfony\Component\Routing\Exception\RouteNotFoundException
Route [EnviarCurriculum.store] not defined. (View: C:\laragon\www\envio-curriculum\resources\views\enviar_curriculum.blade.php)
web.php
<?php
Route::resource('/', 'enviarCurriculum\EnviarCurriculumController')->only(['index', 'create', 'store']);
EnviarCurriculumController.php
<?php
namespace App\Http\Controllers\enviarCurriculum;
use App\EnviarCurriculum;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use app\Http\Requests\StoreEnviarCurriculumPost;
class EnviarCurriculumController extends Controller
{
public function index()
{
return view ('enviar_curriculum');
}
public function create()
{
return view ('enviar_curriculum', ['post' => new EnviarCurriculum()]);
}
public function store(StoreEnviarCurriculumPost $request)
{
EnviarCurriculum::create($request->validated());
return back() -> with('status', '¡Post creado con éxito!');
}
}
enviar_curriculum.blade.php
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form action="{{ route("EnviarCurriculum.store") }}" method="POST">
@csrf
<h4>Datos Personales</h4>
<small class="pull-right">sin espacios, ni guiones</small>
<br>
<input autocomplete="off" type="text" id="frmInscripcionEmpleoNIF" class="form-control" placeholder="* NIF/NIE/Pasaporte" maxlength="20" required data-error="Por favor rellene este campo">
<div class="help-block with-errors"></div>
<input autocomplete="nope" type="text" id="frmInscripcionEmpleoNombre" class="form-control" placeholder="* Nombre" maxlength="50" required data-error="Por favor rellene este campo">
<div class="help-block with-errors"></div>
<input autocomplete="off" type="text" id="frmInscripcionEmpleoApellido1" class="form-control" placeholder="* 1º Apellido" maxlength="50" required data-error="Por favor rellene este campo">
<div class="help-block with-errors"></div>
<input autocomplete="off" type="text" id="frmInscripcionEmpleoApellido2" class="form-control" placeholder="2º Apellido" maxlength="50" data-error="Por favor rellene este campo">
<div class="help-block with-errors"></div>
<select class="form-control" name="frmInscripcionEmpleoSexo" required id="frmInscripcionEmpleoSexo">
<option disabled selected value="">* Sexo</option>
<option value="H">Hombre</option>
<option value="M">Mujer</option>
</select>
<input type="submit" class="btn btn-primary" value="Enviar">
</form>
</body>
</html>
在 web.php
中更新您的路线
Route::resource('/', 'enviarCurriculum\EnviarCurriculumController')->only(['index', 'create', 'store'])->name('EnviarCurriculum');
我正在做一个简单的表单来将数据发送到数据库,当我提交它时出现标题错误。
我想我定义的一切都是完美的,但我不明白我失败的地方。
Symfony\Component\Routing\Exception\RouteNotFoundException Route [EnviarCurriculum.store] not defined. (View: C:\laragon\www\envio-curriculum\resources\views\enviar_curriculum.blade.php)
web.php
<?php
Route::resource('/', 'enviarCurriculum\EnviarCurriculumController')->only(['index', 'create', 'store']);
EnviarCurriculumController.php
<?php
namespace App\Http\Controllers\enviarCurriculum;
use App\EnviarCurriculum;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use app\Http\Requests\StoreEnviarCurriculumPost;
class EnviarCurriculumController extends Controller
{
public function index()
{
return view ('enviar_curriculum');
}
public function create()
{
return view ('enviar_curriculum', ['post' => new EnviarCurriculum()]);
}
public function store(StoreEnviarCurriculumPost $request)
{
EnviarCurriculum::create($request->validated());
return back() -> with('status', '¡Post creado con éxito!');
}
}
enviar_curriculum.blade.php
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form action="{{ route("EnviarCurriculum.store") }}" method="POST">
@csrf
<h4>Datos Personales</h4>
<small class="pull-right">sin espacios, ni guiones</small>
<br>
<input autocomplete="off" type="text" id="frmInscripcionEmpleoNIF" class="form-control" placeholder="* NIF/NIE/Pasaporte" maxlength="20" required data-error="Por favor rellene este campo">
<div class="help-block with-errors"></div>
<input autocomplete="nope" type="text" id="frmInscripcionEmpleoNombre" class="form-control" placeholder="* Nombre" maxlength="50" required data-error="Por favor rellene este campo">
<div class="help-block with-errors"></div>
<input autocomplete="off" type="text" id="frmInscripcionEmpleoApellido1" class="form-control" placeholder="* 1º Apellido" maxlength="50" required data-error="Por favor rellene este campo">
<div class="help-block with-errors"></div>
<input autocomplete="off" type="text" id="frmInscripcionEmpleoApellido2" class="form-control" placeholder="2º Apellido" maxlength="50" data-error="Por favor rellene este campo">
<div class="help-block with-errors"></div>
<select class="form-control" name="frmInscripcionEmpleoSexo" required id="frmInscripcionEmpleoSexo">
<option disabled selected value="">* Sexo</option>
<option value="H">Hombre</option>
<option value="M">Mujer</option>
</select>
<input type="submit" class="btn btn-primary" value="Enviar">
</form>
</body>
</html>
在 web.php
Route::resource('/', 'enviarCurriculum\EnviarCurriculumController')->only(['index', 'create', 'store'])->name('EnviarCurriculum');