title: How to get specific Array value from an Array in Laravel
body: <p>I'd like to get a specific array data from an array I've get from this code :</p>
  
  <pre><code>$user       = $request-&gt;instance()-&gt;query('user');
  var_dump($user);exit;
  </code></pre>
  
  <p>And the result is :</p>
  
  <blockquote>
    <p>array(1) { ["user"]=> object(App\Models\User)#332 (27) {
    ["fillable":protected]=> array(5) { [0]=> string(4) "name" [1]=>
    string(8) "username" [2]=> string(5) "email" [3]=> string(8)
    "password" [4]=> string(5) "token" } ["hidden":protected]=> array(2) {
    [0]=> string(8) "password" [1]=> string(14) "remember_token" }
    ["casts":protected]=> array(1) { ["email_verified_at"]=> string(8)
    "datetime" } ["connection":protected]=> string(5) "mysql"
    ["table":protected]=> string(5) "users" ["primaryKey":protected]=>
    string(2) "id" ["keyType":protected]=> string(3) "int"
    ["incrementing"]=> bool(true) ["with":protected]=> array(0) { }
    ["withCount":protected]=> array(0) { } ["perPage":protected]=> int(15)
    ["exists"]=> bool(true) ["wasRecentlyCreated"]=> bool(false)
    ["attributes":protected]=> array(15) { ["id"]=> int(3) ["name"]=>
    string(14) "Manchesteriyah" ["username"]=> string(14) "manchesteriyah"
    ["email"]=> string(24) "manchesteriyah@gmail.com" ["facebook"]=>
    string(37) "<a href="https://web.facebook.com/xkionna" rel="nofollow noreferrer">https://web.facebook.com/xkionna</a>" ["phone"]=> NULL
    ["email_verified_at"]=> NULL ["password"]=> string(60)
    "$2y$10$IrqHE1JfyH0bJ0XD/Hjy.efLg95y/buTIir0PuXcOqDb1yCSS69Oe"
    ["image"]=> NULL ["description"]=> NULL ["role"]=> string(1) "1"
    ["token"]=> string(20) "ymsJxEtFnxdPBWYwlYFw" ["member_expiration"]=>
    string(19) "2019-07-08 20:33:29" ["created_at"]=> string(19)
    "2019-06-08 20:30:25" ["updated_at"]=> string(19) "2019-06-08
    20:33:29" } ["original":protected]=> array(15) { ["id"]=> int(3)
    ["name"]=> string(14) "Manchesteriyah" ["username"]=> string(14)
    "manchesteriyah" ["email"]=> string(24) "manchesteriyah@gmail.com"
    ["facebook"]=> string(37) "<a href="https://web.facebook.com/xkionna" rel="nofollow noreferrer">https://web.facebook.com/xkionna</a>"
    ["phone"]=> NULL ["email_verified_at"]=> NULL ["password"]=>
    string(60)
    "$2y$10$IrqHE1JfyH0bJ0XD/Hjy.efLg95y/buTIir0PuXcOqDb1yCSS69Oe"
    ["image"]=> NULL ["description"]=> NULL ["role"]=> string(1) "1"
    ["token"]=> string(20) "ymsJxEtFnxdPBWYwlYFw" ["member_expiration"]=>
    string(19) "2019-07-08 20:33:29" ["created_at"]=> string(19)
    "2019-06-08 20:30:25" ["updated_at"]=> string(19) "2019-06-08
    20:33:29" } ["changes":protected]=> array(0) { } ["dates":protected]=>
    array(0) { } ["dateFormat":protected]=> NULL ["appends":protected]=>
    array(0) { } ["dispatchesEvents":protected]=> array(0) { }
    ["observables":protected]=> array(0) { } ["relations":protected]=>
    array(0) { } ["touches":protected]=> array(0) { } ["timestamps"]=>
    bool(true) ["visible":protected]=> array(0) { }
    ["guarded":protected]=> array(1) { [0]=> string(1) "*" }
    ["rememberTokenName":protected]=> string(14) "remember_token" } }</p>
  </blockquote>
  
  <p>What I'd like to get is the username value, I've tried some solution like this :</p>
  
  <pre><code>$user-&gt;username
  </code></pre>
  
  <p>but it give me error like this :</p>
  
  <blockquote>
    <p>Trying to get property 'username' of non-object</p>
  </blockquote>
  
  <p>How to fix this? Thanks for attention.</p>