title: how to get an error key in laravel error message array
body: <p>I am trying to retrieve a key from an array using Laravel error dump (<code>$errors</code>).</p>
  
  <p>The array looks like this</p>
  
  <pre><code>ViewErrorBag {#169 ▼
    #bags: array:1 [▼
      "default" =&gt; MessageBag {#170 ▼
        #messages: array:2 [▼
          "name" =&gt; array:1 [▼
            0 =&gt; "The name field is required."
          ]
          "role_id" =&gt; array:1 [▼
            0 =&gt; "The role id field is required."
          ]
        ]
        #format: ":message"
      }
    ]
  }
  </code></pre>
  
  <p>Using <code>@foreach</code> loop to get the error message works fine.</p>
  
  <pre><code>@foreach($errors-&gt;all() as $error)
       &lt;li&gt;{{$error}}&lt;/li&gt;
  @endforeach
  </code></pre>
  
  <p>But I want to get that <code>name</code> and <code>role_id</code>. Is there anyway to achieve that? Thus far i have tried the below and some other methods with no luck.</p>
  
  <pre><code>@foreach ($errors-&gt;all() as $key =&gt; $value)
         Key: {{ $key }}
         Value: {{ $value }}
  @endforeach
  </code></pre>