PHPackages                             zeng407/l5-repository - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. zeng407/l5-repository

AbandonedArchivedLibrary[Database &amp; ORM](/categories/database)

zeng407/l5-repository
=====================

Laravel 5 - Repositories to the database layer

v2.8(7y ago)027MITPHP

Since Feb 12Pushed 7y agoCompare

[ Source](https://github.com/zeng407/l5-repository)[ Packagist](https://packagist.org/packages/zeng407/l5-repository)[ Docs](https://github.com/zeng407/l5-repository)[ RSS](/packages/zeng407-l5-repository/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (8)Versions (78)Used By (0)

Simple RequestCriteria
======================

[](#simple-requestcriteria)

install
-------

[](#install)

```
composer require zeng407/l5-repository

```

filtering
---------

[](#filtering)

give serchable columns like this

```
class UserRepository extedns BaseRepository
{
	protected $fieldSearchable = [
		'user_name' => [
			'column' => 'name'
			// default column value is 'user_name' if you don't specify column name
		],
		'age' => [
			'operators' => ['=','in','>=']
			//limit operators input
		],
		'gender',
		'post_title' => [
			'relation' => 'posts', // give the relation name in User Model
			'column' => 'title'
		],
		'phone_number' => [
			'relation' => 'profile.phones'
		]
	];
}

```

then you can do these query

```
localhost/users?user_name_like="john"
// select * from users where name like '%john%'

localhost/users?age_gte=20
// select * from users where age >= 20

localhost/users?gender=female
// select * from users where gender = 'female'

localhost/users?age_in[]=20&age_in[]=30age_in[]=35
// select * from users where age in (20,30,35)

localhost/users?post_title_like='announcement'
// select * from users where exists
//  (select * from posts where posts.user_id = users.id
//.   and posts.title like '% announcement%')

```

the operations are defined at

```
class RequestCriteria implements CriteriaInterface {

protected $operatorMap = [
        'gt' => '>',
        'gte' => '>=',
        'lt' => '
