title: Cannot execute INSERT in a read-only transaction - Laravel read/write
body: <p>I'm trying to set a read/write connection in Laravel 4.2.6 and I cannot perform INSERT, but I can do UPDATE and DELETE transactions. The message that I get is:</p>
  
  <pre><code>SQLSTATE[25006]: Read only sql transaction: 7 ERROR:  cannot execute INSERT in a read-only transaction
  </code></pre>
  
  <p>The configuration of the database is:</p>
  
  <pre><code>'connections' =&gt; [
      'pgsql' =&gt; [
          'read'     =&gt; [
              'host' =&gt; '192.168.22.10'
          ],
          'write'     =&gt; [
              'host' =&gt; '192.168.33.10'
          ],
          'driver'   =&gt; 'pgsql',
          'database' =&gt; 'simpo',
          'username' =&gt; 'postgres',
          'password' =&gt; 'xxx',
          'charset'  =&gt; 'utf8',
          'prefix'   =&gt; '',
          'schema'   =&gt; 'public',
      ],
  ]
  </code></pre>
  
  <p>I'm using Postgres 9.3 with 2 server (Virtual machines). The replication works fine and is a simple binary or "Hot Standby" replication (Master/Slave), where the stand by machine can only make read operation.</p>
  
  <hr>
  
  <p>EDIT:</p>
  
  <p>I tested using query builder and the INSERT works fine, but with Eloquent fails. </p>
  
  <p>I'm thinking that maybe is a BUG with the connection in the Eloquent model but the unusual thing is that the only INSERT operation fails and not the UPDATE OR DELETE, so that make me think that is some operation that only happen when a INSERT is perform (Maybe with the ID that is generated?)</p>
  
  <p>EDIT 2:</p>
  
  <p>I finally noticed the problem. The error happens when Laravel try to insert and fetch the Id of the row. The problem happen because the framework call a 'select' method but this select execute and "INSERT ... returning 'ID'", so if the machine can only execute SELECT transaction fails because this SELECT come with a INSERT.</p>
  
  <p>I make a pull request where I check if the select method start with a 'insert' operation, and depending of that get the correct connection
  <a href="https://github.com/laravel/framework/pull/4914" rel="noreferrer">https://github.com/laravel/framework/pull/4914</a></p>