1. Go to this page and download the library: Download dugajean/repositories library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dugajean / repositories example snippets
namespace App\Http\Controllers;
use App\Repositories\FilmRepository;
class FilmsController extends Controller {
/**
* @var FilmRepository
*/
private $filmRepository;
public function __construct(FilmRepository $filmRepository)
{
$this->filmRepository = $filmRepository;
}
public function index()
{
return response()->json($this->filmRepository->all());
}
}
public function all($columns = ['*'])
public function lists($value, $key = null)
public function paginate($perPage = 1, $columns = ['*'], $method = 'full');
public function create(array $data)
// if you use mongodb then you'll need to specify primary key $attribute
public function update(array $data, $id, $attribute = 'id')
public function delete($id)
public function find($id, $columns = ['*'])
public function findBy($field, $value, $columns = ['*'])
public function findAllBy($field, $value, $columns = ['*'])
public function findWhere($where, $columns = ['*'])
public function apply($model, Repository $repository)