title: Laravel The Response content must be a string or object implementing __toString(), "object" given
body: <p>I want to run Skills function but I cant it.</p>
  
  <p>Route.php</p>
  
  <pre><code>Route::get('setting',function(){
      return \App\User::first()-&gt;skills();
  });
  </code></pre>
  
  <p>User.php</p>
  
  <pre><code>protected $casts = [
      'skills' =&gt; 'json'
  ];
  
  public function skills(){
      return new Skills($this , $this-&gt;skills);
  }
  </code></pre>
  
  <p>Skills.php</p>
  
  <pre><code>namespace App;
  use App\User;
  use Mockery\Exception;
  
  class Skills
  {
      protected $user;
      protected $skills = [];
  
      public function __construct(User $user,array $skills){
  
          $this-&gt;user=$user;
          $this-&gt;skills=$skills;
      }
  }
  </code></pre>
  
  <p>I want to enter /settings page I have "<code>The Response content must be a string or object implementing __toString(), "object" given.</code>" error.</p>
  
  <p>I tried to add <code>dd()</code> function's return in route, I see all JSON data but <code>$skills-&gt;get()</code>, <code>$skill-&gt;set()</code> didn't working at the time.</p>
  
  <p>Edit:</p>
  
  <p>Skills.php</p>
  
  <pre><code>&lt;?php
      /**
       * Created by PhpStorm.
       * User: root
       * Date: 01.08.2015
       * Time: 11:45
       */
  
      namespace App;
      use App\User;
      use Mockery\Exception;
  
      class Skills
      {
          protected $user;
          protected $skills = [];
  
          public function __construct(User $user,array $skills){
              $this-&gt;user=$user;
              $this-&gt;skills=$skills;
          }
  
          public function get($key){
              return array_get($this-&gt;skills,$key);
          }
  
          public function set($key,$value){
              $this-&gt;skills[$key]=$value;
              return $this-&gt;duration();
          }
  
          public function has($key){
              return array_key_exists($key,$this-&gt;skills);
          }
  
          public function all(){
             return $this-&gt;skills;
          }
  
          public function merge(array $attributes){
              $this-&gt;skills = array_merge(
                  $this-&gt;skills,
                  array_only(
                      $attributes,
                      array_keys($this-&gt;skills)
                  )
              );
              return $this-&gt;duration();
          }
  
          public function duration(){
              return $this-&gt;user-&gt;update(['skills' =&gt; $this-&gt;skills]);
          }
  
          public function __get($key){
              if ($this-&gt;has($key)) {
                  return $this-&gt;get($key);
              }
              throw new Exception("{$key} adlı Yetenek bulunamadı");
          }
      }
  </code></pre>