shekarsiri / baserepo by shekarsiri

Base repositories
88
0
2
Package Data
Maintainer Username: shekarsiri
Maintainer Contact: sshekarsiri@gmail.com (shekarsiri)
Package Create Date: 2015-06-19
Package Last Update: 2015-11-27
Language: PHP
License: MIT
Last Refreshed: 2024-12-14 15:11:16
Package Statistics
Total Downloads: 88
Monthly Downloads: 1
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Base Repository

Example

Repository


use ShekarSiri\BaseRepo\Crudable;
use ShekarSiri\BaseRepo\Pagination;
use ShekarSiri\BaseRepo\Repo;


/**
 * Interface LocationRepository
 *
 */
interface LocationRepository extends Crudable, Repo, Pagination
{

}

Implementation


use Location;
use ShekarSiri\BaseRepo\CrudableTrait;
use ShekarSiri\BaseRepo\PaginationTrait;
use ShekarSiri\BaseRepo\RepoTrait;

/**
 * Class LocationRepositoryEloquent
 * 
 */
class LocationRepositoryEloquent implements LocationRepository
{
    use CrudableTrait, PaginationTrait, RepoTrait;

    private $queries = [
        'name' => 'LIKE'
    ];

    function __construct(Location $model)
    {
        $this->model = $model;
    }

}

use LocationRepository;
use Illuminate\Http\Request;

class LocationController extends Controller
{

    /**
     * @var LocationRepository
     */
    private $repo;

    function __construct(LocationRepository $repo)
    {
        $this->middleware('auth', ['except' => ['autoComplete']]);
        $this->repo = $repo;
    }

    public function index(Request $request)
    {
        $locations = $this->repo->pagination(10, [], $request->all());
        return response()->json($locations, 200);
    }

   
}