title: Laravel Detected Object as Array: Trying to get property 'title' of non-object
body: <p>I have problem when passing the retrieved data to the view (<code>using redirect()-&gt;back()-with()</code>)</p>
  
  <p>I have a method in my controller, after the data retrieved, I make new variable called <code>$data</code> and send it to the view, like this</p>
  
  <pre><code>$message = Message::find($request-&gt;id);
  
  $data    = [
      "{$do}Modal"   =&gt; "{$do}Modal",
      'msg'           =&gt; $message
  ];
  
  return redirect()-&gt;back()-&gt;with($data);
  </code></pre>
  
  <p>Then, in my view, I need to initiate new variable for the data, <code>$msg</code>. But I got an error that says the variable is an array when I want to show it.</p>
  
  <pre><code>@php
      $msg = Session::get('msg')
  @endphp
  
  {{ is_object($msg) }} // it shows 1 ($msg is an object)
  {{ $msg-&gt;id }} // the error message shown up
  {{ $msg['id'] }} // shows the id
  </code></pre>
  
  <p>My first intension is to show up the id, title, etc <strong>as an object</strong>, but I only can show the values as an array.
  When I did <code>var_dump($msg)</code>, a got this output:</p>
  
  <pre><code>            object(App\Models\Message)#200 (26) {
    ["fillable":protected]=&gt;
    array(4) {
      [0]=&gt;
      string(5) "title"
      [1]=&gt;
      string(4) "body"
      [2]=&gt;
      string(8) "password"
      [3]=&gt;
      string(5) "image"
    }
    ["connection":protected]=&gt;
    string(5) "mysql"
    ["table":protected]=&gt;
    string(8) "messages"
    ["primaryKey":protected]=&gt;
    string(2) "id"
    ["keyType":protected]=&gt;
    string(3) "int"
    ["incrementing"]=&gt;
    bool(true)
    ["with":protected]=&gt;
    array(0) {
    }
    ["withCount":protected]=&gt;
    array(0) {
    }
    ["perPage":protected]=&gt;
    int(15)
    ["exists"]=&gt;
    bool(true)
    ["wasRecentlyCreated"]=&gt;
    bool(false)
    ["attributes":protected]=&gt;
    array(7) {
      ["id"]=&gt;
      int(101)
      ["title"]=&gt;
      string(19) "Tes ketiga hari ini"
      ["body"]=&gt;
      string(18) "sfkafaf
  afaf
  afa"
      ["created_at"]=&gt;
      string(19) "2019-12-03 11:20:56"
      ["updated_at"]=&gt;
      string(19) "2019-12-03 11:39:29"
      ["password"]=&gt;
      string(60) "$2y$10$hSTdJZN24aIddOjrGMmUceYN1cPFvLM.IjCcEL/BPb/4C6ayk12va"
      ["image"]=&gt;
      string(91) "kala-gotongan-dan-semut-sadulur-pantang-kubur-jenazah-ini-alasannya_m_39626_1575343256.jpeg"
    }
    ["original":protected]=&gt;
    array(7) {
      ["id"]=&gt;
      int(101)
      ["title"]=&gt;
      string(19) "Tes ketiga hari ini"
      ["body"]=&gt;
      string(18) "sfkafaf
  afaf
  afa"
      ["created_at"]=&gt;
      string(19) "2019-12-03 11:20:56"
      ["updated_at"]=&gt;
      string(19) "2019-12-03 11:39:29"
      ["password"]=&gt;
      string(60) "$2y$10$hSTdJZN24aIddOjrGMmUceYN1cPFvLM.IjCcEL/BPb/4C6ayk12va"
      ["image"]=&gt;
      string(91) "kala-gotongan-dan-semut-sadulur-pantang-kubur-jenazah-ini-alasannya_m_39626_1575343256.jpeg"
    }
    ["changes":protected]=&gt;
    array(0) {
    }
    ["casts":protected]=&gt;
    array(0) {
    }
    ["dates":protected]=&gt;
    array(0) {
    }
    ["dateFormat":protected]=&gt;
    NULL
    ["appends":protected]=&gt;
    array(0) {
    }
    ["dispatchesEvents":protected]=&gt;
    array(0) {
    }
    ["observables":protected]=&gt;
    array(0) {
    }
    ["relations":protected]=&gt;
    array(0) {
    }
    ["touches":protected]=&gt;
    array(0) {
    }
    ["timestamps"]=&gt;
    bool(true)
    ["hidden":protected]=&gt;
    array(0) {
    }
    ["visible":protected]=&gt;
    array(0) {
    }
    ["guarded":protected]=&gt;
    array(1) {
      [0]=&gt;
      string(1) "*"
    }
  }
  </code></pre>