title: Cannot use object of type Illuminate\Validation\Validator as array
body: <p>I get the following error in postman while testing the post request for api/register.</p>
  <p>&quot;Error: Cannot use object of type Illuminate\Validation\Validator as array in file C:\Users\azzam\laravel-app\azzamnewapi\app\Http\Controllers\AuthController.php on line 25&quot;</p>
  <p>Here is my AuthController code:</p>
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  use Illuminate\Support\Facades\Auth;
  use Illuminate\Support\Facades\Validator;
  use App\Models\User;
  use Laravel\Sanctum\PersonalAccessToken;
  
  class AuthController extends Controller
  {
      public function register(Request $request) {
  
      //validation field
          $validUser=Validator::make($request-&gt;all(), [
              'name'=&gt; 'required|string',
              'email'=&gt; 'required|email',
              'password'=&gt; 'required|string',
          ]);
          
  
      //create user
          $user= User::create([
              'name'=&gt; $validUser['name'],
              'email'=&gt; $validUser['email'],
              'password'=&gt; bcrypt($validUser['password']),
          ]);
  
      //response
          return response([ 
              'user'=&gt; $user,
              'token'=&gt; $user-&gt;createToken('secret')-&gt;plainTextToken,
          ], 200);
      }
  
      public function logout(Request $request) {
  
      //user
          $user= User::find(PersonalAccessToken::findToken(explode(' ',$request-&gt;header('Authorization'))[1])-&gt;tokenable_id);
  
      //delete token
          $user-&gt;tokens()-&gt;delete();
  
      //reponse
          return response([
              'message'=&gt; 'logout success',
          ], 200);
      }
  
      
  }
  </code></pre>
  <p>can anyone please tell me where is the mistake, and how to see the $validUser variable? ThankYou.</p>