Skip to content

Instantly share code, notes, and snippets.

<?php namespace MyApp\Models\Repositories;
abstract class EloquentBaseRepository {
protected $model;
public function __construct()
{
$model = explode('\\', get_class($this));
$this->model = $model[count($model)-2];
@sorora
sorora / gist:8041074
Last active December 31, 2015 20:38
Is using this type of logic defeating the purpose of using interfaces/repositories? I like the idea because it means every time I define a new function on the model, I don't have to go into the Repository AND interface to define them too... yet it still allows me to swap out the Eloquent Repo's for something else if needed.
<?php namespace MyApp\Models\Repositories;
abstract class EloquentBaseRepository {
protected $methods;
protected $model;
public function __construct()
{