You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue: When I created the request file, it was successfully made with the correct name, but in the controller, the request class name was different. and also different namespace class import in controller
my generated controller and request file
UserController.php:
<?php
namespace App\Http\Controllers;
use App\Http\Requests\UserControllerStoreRequest;
use App\Http\Requests\UserControllerUpdateRequest;
use App\Models\User;
class UserController extends Controller
{
public function store(UserControllerStoreRequest $request): RedirectResponse
{
$user = User::create($request->validated());
return redirect()->route('backend.users.show');
}
public function update(UserControllerUpdateRequest $request, User $user): RedirectResponse
{
$user->update($request->validated());
$request->session()->flash('user.id', $user->id);
return redirect()->route('user.index');
}
}
UserStoreRequest.php
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UserStoreRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*/
public function rules(): array
{
return [
'name' => ['required', 'string'],
'email' => ['required', 'email'],
'email_verified_at' => ['nullable'],
'password' => ['required', 'password'],
'remember_token' => ['nullable', 'string'],
];
}
}
UserUpdateRequest.php
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UserUpdateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*/
public function rules(): array
{
return [
'name' => ['required', 'string'],
'email' => ['required', 'email'],
'email_verified_at' => ['nullable'],
'password' => ['required', 'password'],
'remember_token' => ['nullable', 'string'],
];
}
}
draft.yaml:
# PLEASE PASTE THE DRAFT FILE WHICH REPRODUCES THE ISSUE HERE...controllers:
UserController:
store:
validate: usersave: userredirect: backend.users.showupdate:
validate: userupdate: userflash: user.idredirect: user.index
The text was updated successfully, but these errors were encountered:
Issue: When I created the request file, it was successfully made with the correct name, but in the controller, the request class name was different. and also different namespace class import in controller
my generated controller and request file
UserController.php:
UserStoreRequest.php
UserUpdateRequest.php
draft.yaml:
The text was updated successfully, but these errors were encountered: