innovareti / laravel-aux
v3.3
2023-02-17 14:36 UTC
Requires
- php: >=7.4 || ^8.0
- elgibor-solution/laravel-database-encryption: ^1.1
- fideloper/proxy: ^4.0
- laravel/framework: ^8.0
- laravel/tinker: ^2.0
Requires (Dev)
- orchestra/testbench: ^6.19
- phpunit/phpunit: ^9.5
README
这是一个旨在辅助Laravel API(遵循View -> Controller -> Service -> Repository -> Model)标准化和CRUD创建的包。
- View:负责向用户展示信息并捕获事件/操作。
- Controller:仅负责接收用户请求/操作并请求Service处理。
- Service:负责包含整体业务规则,但从不执行查询,而是将这一责任传递给repositories。
- Repository:通过使用model执行查询,可以将其定义为一个安全层。
- Model:通过使用Laravel的ORM(Eloquent)来查找/更新/删除和/或修改数据库中的数据。
使用示例
List all elements:
Paginated:
https://:8000/api/v1/users
Whithout pagination:
https://:8000/api/v1/users?paginated=false
Order:
Asc:
https://:8000/api/v1/users?orderByAsc[]=name
Desc:
https://:8000/api/v1/users?orderByDesc[]=id
Get element by id
https://:8000/api/v1/users?id=1
Bring with relationships
https://:8000/api/v1/users?with[]=company
Filter by any field, including children fields
Filtering by parent fields -> will bring all which name matches input 'name' (Ma), like Mateus, Maicon, Marcos
https://:8000/api/v1/users?name=Ma
Filtering by children -> will bring all which relation (companies) matches input 'name' (hospital) from companies table
https://:8000/api/v1/users?with[]=company&name=Mat&company[name]=hospital
Group by any field -> will bring data grouped by the value of field (company_id)
https://:8000/api/v1/users?with[]=company&groupBy[]=company_id
开发
要测试,需要安装 sudo apt-get install php-sqlite3
测试
composer dump-autoload