1. Go to this page and download the library: Download io-digital/repo 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/ */
io-digital / repo example snippets
//returns the model with the relationship as a paginated collection
$data = $this->model->make(['relation'])->paginate();
//returns with ->first()
$data = $this->model->findBy('title', $title);
//returns with ->get()
$data = $this->model->findAllBy('category', $category);
//returns with ->get()
$data = $this->model->findWhere([
'category' => $category,
['year', '>' , $year],
['name', 'like', "%$name%"],
['surname', 'like', '%nes']
]);
$data = $this->model->findWhereIn('id', [1, 2, 3])
->get(['name', 'email']);
php
...
use App\Models\Contracts\Repositories\PostRepository;
...
protected $model;
public function __construct(PostRepository $repo)
{
$this->model = $repo;
}
php
public function make($with = [], $orderBy = []);
public function all($with = [], $orderBy = [], $columns = ['*']);
public function find($id, $relations = []);
public function findBy($attribute, $value, $columns = ['*']);
public function findAllBy($attribute, $value, $columns = ['*']);
public function findWhere($where, $columns = ['*'], $or = false);
public function findWhereIn($field, array $values, $columns = ['*']);
public function paginate($perPage = 25, $columns = ['*']);
public function simplePaginate($limit = null, $columns = ['*']);
public function create($attributes = []);
public function edit($id, $attributes = []);
public function delete($id);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.