Laravel 5 Override Eloquent Save Method
<p>I have composite primary keys so Laravel's save() method didn't work. Therefore I need to override the save method. For example, my primary key is a composite key consisting of column_a and column_b. Can you give me example how to override the save method and where I put it?</p>

<p>My Primary Key: column_a, column_b</p>

<p>I've tried the followings:</p>

<pre><code>protected function setKeysForSaveQuery(Builder $query)
{
    parent::setKeysForSaveQuery($query);
    $query-&gt;where('locale', '=', $this-&gt;locale);
    return $query;
}
</code></pre>

<p>I found above code, but it causes 500 Internal Server Error even I call a method that only reads value from database. I have set $primaryKey = 'column_a' and 'locale' (inside where) to column_b. I didn't know what $this->locale refers to?</p>

<p>Here is another way I found, but it failed too</p>

<pre><code>protected $secondaryKey = 'column_b';
function newQuery()
{
    $query = parent::newQuery();
    $query-&gt;where($this-&gt;secondaryKey, '=', $this-&gt;type);
    return $query;
}
</code></pre>

<p>Again, I didn't know what $this->type refers to.</p>