12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace App\Repositories\Eloquent\Base;
- use App\Contracts\Repositories\Base\DepartmentRepository;
- use App\Repositories\Models\Base\Department;
- use Prettus\Repository\Criteria\RequestCriteria;
- use Prettus\Repository\Eloquent\BaseRepository;
- class DepartmentRepositoryEloquent extends BaseRepository implements DepartmentRepository
- {
- protected $fieldSearchable = [
- // 'name' => 'like', Default Condition "="
- ];
- /**
- * Specify Model class name.
- *
- * @return string
- */
- public function model()
- {
- return Department::class;
- }
- /**
- * Boot up the repository, pushing criteria.
- *
- * @throws \Prettus\Repository\Exceptions\RepositoryException
- */
- public function boot()
- {
- $this->pushCriteria(app(RequestCriteria::class));
- }
- /**
- * @return mixed
- */
- public function searchDepartmentsByPage()
- {
- return $this->paginate(request('per_page', 15));
- }
- public function searchDepartments()
- {
- return $this->all();
- }
- /**
- * @param $id
- *
- * @return mixed
- */
- public function searchDepartmentBy($id)
- {
- return $this->find($id);
- }
- public function tree($where)
- {
- return toTree($this->all());
- }
- }
|