所以...目标 class 不存在...好吗?
So... the target class does not exist... ok?
我正在尝试做一个简单的表格,一个非常简单的表格。
我正在发出自己的验证请求,但错误消息是这样的:
Target class [app\Http\Requests\StoreEnviarCurriculumPost] does not exist.
代码不能像我写的那么简单,搞不懂问题出在哪里。
你有看到什么不好的吗?
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', ['EnviarCurriculum' => new EnviarCurriculum()]);
}
public function create()
{
return view ('enviar_curriculum', ['EnviarCurriculum' => new EnviarCurriculum()]);
}
public function store(StoreEnviarCurriculumPost $request)
{
EnviarCurriculum::create($request->validated());
return back() -> with('status', 'Curriculum creado con éxito!');
}
}
StoreEnviarCurriculumPost.php
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreEnviarCurriculumPost extends FormRequest
{
public function authorize()
{
return true;
}
public function rules()
{
return [
'nif' => 'required|min:1|max:20'
];
}
}
======================================== ================================================ ==================================
(我认为html不是必须的,但以防万一...)
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>Enviar Currículum</title>
</head>
<body>
@include('partials.errores_de_validacion')
@include('partials.status_de_la_session')
<form action="{{ route("store") }}" method="POST">
@csrf
<h4>Datos Personales</h4>
<small class="pull-right">sin espacios, ni guiones</small>
<br>
<input autocomplete="off" type="text" name="nif" id="nif" 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" name="nombre" id="nombre" 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" name="apellido1" id="apellido1" 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" name="apellido2" id="apellido2" 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="sexo" required id="sexo">
<option disabled selected value="">* Sexo</option>
<option value="Hombre">Hombre</option>
<option value="Mujer">Mujer</option>
</select>
<input type="submit" class="btn btn-primary" value="Enviar">
</form>
</body>
</html>
我觉得app
应该是App
。改变这个:
use app\Http\Requests\StoreEnviarCurriculumPost;
收件人:
use App\Http\Requests\StoreEnviarCurriculumPost;
我正在尝试做一个简单的表格,一个非常简单的表格。
我正在发出自己的验证请求,但错误消息是这样的:
Target class [app\Http\Requests\StoreEnviarCurriculumPost] does not exist.
代码不能像我写的那么简单,搞不懂问题出在哪里。
你有看到什么不好的吗?
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', ['EnviarCurriculum' => new EnviarCurriculum()]);
}
public function create()
{
return view ('enviar_curriculum', ['EnviarCurriculum' => new EnviarCurriculum()]);
}
public function store(StoreEnviarCurriculumPost $request)
{
EnviarCurriculum::create($request->validated());
return back() -> with('status', 'Curriculum creado con éxito!');
}
}
StoreEnviarCurriculumPost.php
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreEnviarCurriculumPost extends FormRequest
{
public function authorize()
{
return true;
}
public function rules()
{
return [
'nif' => 'required|min:1|max:20'
];
}
}
======================================== ================================================ ==================================
(我认为html不是必须的,但以防万一...)
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>Enviar Currículum</title>
</head>
<body>
@include('partials.errores_de_validacion')
@include('partials.status_de_la_session')
<form action="{{ route("store") }}" method="POST">
@csrf
<h4>Datos Personales</h4>
<small class="pull-right">sin espacios, ni guiones</small>
<br>
<input autocomplete="off" type="text" name="nif" id="nif" 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" name="nombre" id="nombre" 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" name="apellido1" id="apellido1" 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" name="apellido2" id="apellido2" 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="sexo" required id="sexo">
<option disabled selected value="">* Sexo</option>
<option value="Hombre">Hombre</option>
<option value="Mujer">Mujer</option>
</select>
<input type="submit" class="btn btn-primary" value="Enviar">
</form>
</body>
</html>
我觉得app
应该是App
。改变这个:
use app\Http\Requests\StoreEnviarCurriculumPost;
收件人:
use App\Http\Requests\StoreEnviarCurriculumPost;