PHP code example of guardianslabs / repository

1. Go to this page and download the library: Download guardianslabs/repository 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/ */

    

guardianslabs / repository example snippets

 php
use App\User;
use GuardiansLabs\Repository\Repositories\ActiveRepository;

class UserRepository extends ActiveRepository
{
    public function __construct()
    {
        $this->model =  new User();
    }
}
 php
    
    public function setModel(Model $model);

    public function getModel();

    /**
     * @return Collection
     */
    public function findAll();
    
    /**
     * @param $itemId
     * @return Collection
     */
    public function findItemById($itemId);
    
    /**
     * @param array $data
     * @return Collection
     */
    public function createNew(array $data);
    
    /**
     * @param $itemId
     * @param array $data
     * @return mixed
     */
    public function update($itemId, array $data);
    
    /**
     * @param $itemId
     * @return mixed
     */
    public function delete($itemId);
    
    /**
     * @param array $where
     * @param array $columns
     * @internal param array $attributes
     * @return Collection
     */
    public function findWhere(array $where, $columns = ['*']);
    
    /**
     * @param $column
     * @param $values
     * @throws RepositoryException
     * @return Collection
     */
    public function findWhereIn($column, $values);