Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating a chainable method in Laravel 4
    primarykey
    data
    text
    <p>I've tried to update <a href="https://stackoverflow.com/a/15182765/1709022">this excellent solution of Collin James</a> to work in <strong>Laravel 4</strong>.</p> <p>Until know without luck. This is what I came up with:</p> <p><strong>/app/libraries/Model.php</strong> (i've registered the libraries directory using composer) </p> <pre><code>namespace Elegant; class Model extends \Illuminate\Database\Eloquent\Model { function __construct() { echo 'Show me if the Model exension works&lt;br /&gt;'; } protected function query() { echo 'Show me if the query function gets called&lt;br /&gt;'; return new \Elegant\Query($this); } } </code></pre> <p><strong>/app/libraries/Query.php</strong> (i've registered the libraries directory using composer) </p> <pre><code>namespace Elegant; class Query extends \Illuminate\Database\Query { public function __construct() { echo 'Show me if the Query exension works&lt;br /&gt;'; } public function byArray($column, $value) { if (is_array($value)) return $this-&gt;whereIn($column, $value); else return $this-&gt;where($column, '=', $value); } public function __call() { } } </code></pre> <p><strong>/app/config/app.php</strong> </p> <pre><code>'aliases' =&gt; array( ... 'Eloquent' =&gt; 'Elegant\Model', ... ) </code></pre> <p>The only thing that works is:</p> <ul> <li>"Show me if the Model exension works".</li> </ul> <p>The other "markers" don't work:</p> <ul> <li>query() doesn't get called at all</li> <li>Eloquent/Query is used, instead of looking at Elegant/Query first</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload