Я новичок и учусь Laravel версия 6.18.2.
Я постоянно получаю сообщение об ошибке при отправке формы "UserStoreRequest не существует", пока она уже создана и вызвана в мой контроллер.
Я разочарован чтением многих других статей в Google и переполнением стека, но не смог найти свое решение. Ищу специалистов. Заранее спасибо.
carchainController. php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Requests;
use Illuminate\Support\Facades\Validator;
use App\Http\Requests\UserStoreRequest;
class carchainController extends Controller
{
public function RegisterNewUser(UserStoreRequest $request)
{
// Handling all requests for forms in a file named HTTP/Request/UserStoreRequest
$validated = $request->validated();
//get fields from signup form using $request
$name = $request['name'];
$email = $request['email'];
$password = bcrypt($request['password']);
$user_type = $request['user_type'];
//create new user - use App\User;
$user = new User();
$user->name = $name;
$user->email = $email;
$user->password = $password;
$user->user_type = $user_type;
$user->save(); //save to the db.
Auth::login($user);//login after register
return redirect()->route('actions.custom',['name' => $name]);
}
}
UserStoreRequest. php
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UserStoreRequest extends BaseFormRequest
{
public function authorize()
{
return true;
}
public function rules()
{
return [
'name' => 'bail|required|unique:register_users,name'
];
}
public function messages()
{
return [
'name.required' => 'Name/Company Name is required!'
];
}
public function filters()
{
}
}
BaseFormRequest. php
<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\JsonResponse;
use Waavi\Sanitizer\Laravel\SanitizesInput;
abstract class BaseFormRequest extends FormRequest
{
use ApiResponse, SanitizesInput;
public function validateResolved()
{
{
$this->sanitize();
parent::validateResolved();
}
}
abstract public function rules();
abstract public function authorize();
}
MyRoute. php
Route::post('/custom', [
'uses' => 'carchainController@RegisterNewUser',
'as'=> 'signup'
]);
Снимок экрана ошибки https://imgur.com/9QZ8FBb