PHP code example of jiaxincui / repository

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

    

jiaxincui / repository example snippets




class UserRepositoryEloquent extends Repository implements UserRepository
{
    // 可以生效的查询字段,关联字段用 . 分割
    protected $fieldsQueryable = [
        'name',
        'age',
        'role.name'
    ];

    // 可以生效的关联查询
    protected $releasable = ['book', 'order'];


    public function model()
    {
        return User::class;
    }

   // 应用请求参数查询
    public function boot()
    {
        $this->pushCriteria(app(RequestCriteria::class));
    }
}

terminal
php artisan repository:install
terminal
php artisan make:criteria Example