title: Indirect Modification of Overloaded Property Laravel MongoDB
body: <p>I am using MongoDB with Laravel. I have a collection called <code>categories</code> which has one document </p>
  
  <pre><code>[
    {
      "_id": "567dc4b4279871d0068b4568",
      "name": "Fashion",
      "images": "http://example.com/1.jpg",
      "specifics": [
        "made"
      ],
      "brands": [
        {
          "name": "Giordano",
          "logo": "http://example.com/"
        },
        {
          "name": "Armani",
          "logo": "http://example.com/"
        }
      ],
      "updated_at": "2015-12-25 22:40:44",
      "created_at": "2015-12-25 22:35:32"
    }
  ]
  </code></pre>
  
  <p>I am trying to make a function that add specifics to the specifics array in the above document.</p>
  
  <p>Here is how my request body is</p>
  
  <pre><code>HTTP: POST
  {
      "specifics": [
          "material"
      ]
  }
  </code></pre>
  
  <p>And i am handling this request with the following function</p>
  
  <pre><code>/**
   * Add specs to category
   * @param string $category_id
   * @return Illuminate\Http\JsonResponse
   */
  public function addSpecifics($category_id)
  {
      $category = $this-&gt;category-&gt;findOrFail($category_id);
      $category-&gt;specifics[] = $this-&gt;request-&gt;get('specifics');
      $status_code = config('http.UPDATED');
      return response()-&gt;json($category-&gt;save(), $status_code);
  }
  </code></pre>
  
  <p>But when i hit this call, I get error of </p>
  
  <blockquote>
    <p>ErrorException in CategoryController.php line 101: Indirect
    modification of overloaded property App\Category::$specifics has no
    effect</p>
  </blockquote>
  
  <p>Please help me in fixing this.</p>
  
  <p>I am using <a href="https://github.com/jenssegers/laravel-mongodb" rel="noreferrer">https://github.com/jenssegers/laravel-mongodb</a> this package for MongoDB.</p>