php - Laravel 8: Class 'AppHttpControllersAdminRule' not found
Get the solution ↓↓↓I'm working with Laravel 8 to develop my project, and I have made a Resource Controller under theAdmin
directory, which goes like this:
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\User;
public function update(Request $request, User $user)
{
$data = $request->validate([
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email',
'max:255', Rule::unique('users')->ignore($user->id)],
]);
if (!is_null($request->password)) {
$request->validate([
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
$data['password'] = $request->password;
}
$user->update($data);
if ($request->has('verify')) {
$user->markEmailAsVerified();
}
return redirect(route('admin.users.index'));
}
As you can see, I put the methodupdate
because it holds some form of validation. But whenever I try to update the data within the form of the Blade file, I get this error:
Error Class 'App\Http\Controllers\Admin\Rule' not found
I even tried addinguse Illuminate\Support\Facades\Validator;
but still receives the error. How can I fix this error?
Answer
Solution:
call this in your file
use Illuminate\Contracts\Validation\Rule;
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: mysqli::real_connect(): (hy000/2002): connection refused
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.