neiderruiz/filter-eloquent-laravel
Composer 安装命令:
composer require neiderruiz/filter-eloquent-laravel
包简介
filter query eloquent laravel
README 文档
README
Translate text php
composer require neiderruiz/filter-eloquent-laravel
how using translator
// import pachage
use Neiderruiz\FilterEloquentLaravel\Traits\FilterQuery;
// use trait in controller
class UserController extends Controller
{
use FilterQuery;
}
// example use filter
public function index(Request $request)
{
$this->filter = User::query();
$this->addWith();
$this->where();
$this->search();
return $this->success($this->paginate());
}
// your url request
?paginate=true&search=[articles,name,laravel]&with=[articles:id,title]
// get specific fields
&inputs=id,name,email
get specific fields
// your url request
&fields=id,name,email
with relations
&with=[posts:id,title,user_id]
with multiple relations
//example one &with=[posts:id,title,user_id] // example two &with=[posts:id,title,user_id][posts.comments] // example three &with=[posts:id,title,user_id][posts.comments][posts.comments.user] // example four &with=[posts:id,title,user_id][posts.comments][posts.comments:id,description]
Simple Search
// your url request
&search=[name,your text]
Search With Relation
// your url request
&search=[articles,name,your text]
Search With Multiple Relation
// your url request
&search=[articles,name,your text][articles,description,your text]
Where
// example one &where=[id,10] // example two &where=[id,10][name,neider ruiz] // example three &where=[name,neider ruiz,like] // example four &where=[age,20,<=]
Where With Relation
// example one &where=[articles,id,10] // example two &where=[articles,title,mi titulo,like]
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-02-26