Adding method to get all records returned as query builder

parent 12da7a11
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
namespace Modules\Core\Repositories; namespace Modules\Core\Repositories;
use Illuminate\Database\Eloquent\Builder;
/** /**
* Interface CoreRepository * Interface CoreRepository
* @package Modules\Core\Repositories * @package Modules\Core\Repositories
...@@ -20,6 +22,11 @@ interface BaseRepository ...@@ -20,6 +22,11 @@ interface BaseRepository
*/ */
public function all(); public function all();
/**
* @return Builder
*/
public function allWithBuilder() : Builder;
/** /**
* Paginate the model to $perPage items per page * Paginate the model to $perPage items per page
* @param int $perPage * @param int $perPage
......
...@@ -50,6 +50,19 @@ abstract class EloquentBaseRepository implements BaseRepository ...@@ -50,6 +50,19 @@ abstract class EloquentBaseRepository implements BaseRepository
return $this->model->orderBy('created_at', 'DESC')->get(); return $this->model->orderBy('created_at', 'DESC')->get();
} }
/**
* @inheritdoc
*/
public function allWithBuilder() : Builder
{
if (method_exists($this->model, 'translations')) {
return $this->model->with('translations')->orderBy('created_at', 'DESC');
}
return $this->model->orderBy('created_at', 'DESC');
}
/** /**
* @inheritdoc * @inheritdoc
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment