I've tried to update this excellent solution of Collin James to work in Laravel 4.
Until know without luck. This is what I came up with:
/app/libraries/Model.php (i've registered the libraries directory using composer)
namespace Elegant;
class Model extends \Illuminate\Database\Eloquent\Model {
function __construct()
{
echo 'Show me if the Model exension works<br />';
}
protected function query()
{
echo 'Show me if the query function gets called<br />';
return new \Elegant\Query($this);
}
}
/app/libraries/Query.php (i've registered the libraries directory using composer)
namespace Elegant;
class Query extends \Illuminate\Database\Query {
public function __construct()
{
echo 'Show me if the Query exension works<br />';
}
public function byArray($column, $value)
{
if (is_array($value))
return $this->whereIn($column, $value);
else
return $this->where($column, '=', $value);
}
public function __call()
{
}
}
/app/config/app.php
'aliases' => array(
...
'Eloquent' => 'Elegant\Model',
...
)
The only thing that works is:
- "Show me if the Model exension works".
The other "markers" don't work:
- query() doesn't get called at all
- Eloquent/Query is used, instead of looking at Elegant/Query first