Download the PHP package cuytamvan/base-pattern-laravel without Composer
On this page you can find all versions of the php package cuytamvan/base-pattern-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cuytamvan/base-pattern-laravel
More information about cuytamvan/base-pattern-laravel
Files in cuytamvan/base-pattern-laravel
Package base-pattern-laravel
Short Description Base pattern laravel, powerfull for API
License MIT
Informations about the package base-pattern-laravel
Base Repo Laravel
Instalation 💻
you can install the package via composer
composer require cuytamvan/base-pattern-laravel
Setup package in Lumen
you should copy config
cp ./vendor/cuytamvan/base-pattern-laravel/config/cuypattern.php ./config/cuypattern.php
change your bootstrap/app.php
Setup package in laravel
add your config/app.php
publish your fucking provider with command : php artisan vendor:publish
and choose Provider: Cuytamvan\BasePattern\BasePatternServiceProvider
run the migration to create table for this package:
php artisan migrate
Basic Usage
create repository file
php artisan make:repository ModuleName
it will generate file: ModuleNameRepository
and controller:
Searchable
On controller setup your index
using where
using with
using withCount
using whereHas
Config
app/config/cuypattern.php
if not using _limit on get query default limit will take limit from default limit
change payload
Min
filter data with min value of field, available for field date and numeric
example url:
{{base_url}}/module-name?_min=created_at:2022-02-02
{{base_url}}/module-name?_min=price:20000
if want to filter more than 1 field:
example url:
{{base_url}}/module-name?_min=created_at:2022-02-02|updated_at:2022-02-02
{{base_url}}/module-name?_min=price:20000|qty:20000
Max
filter data with max value of field, available for field date and numeric
example url:
{{base_url}}/module-name?_max=created_at:2022-02-02
{{base_url}}/module-name?_max=price:20000
if want to filter more than 1 field:
example url:
{{base_url}}/module-name?_max=created_at:2022-02-02|updated_at:2022-02-02
{{base_url}}/module-name?_max=price:20000|qty:20000
Search like
filter data with search like
example url:
{{base_url}}/module-name?_like=name:loremipsumdolor
{{base_url}}/module-name?_like=name,username,email:loremipsumdolor
Search perfield
filter data with search spesific columns, but you must define function on your model
example url for search like:
{{base_url}}/module-name?_search=name:lorem ipsum dolor sit amet|email:test
example url for search exact:
{{base_url}}/module-name?_search=name!:lorem ipsum dolor sit amet|email!:test
Search by relation
filter data with search spesific columns on relation, but you must define function on your model
example url for search like:
{{base_url}}/module-name?_search_relation=user.name:cuytamvan
example url for search exact:
{{base_url}}/module-name?_search_relation=user.name!:cuytamvan
Order
order by field
example url:
{{base_url}}/module-name?_order=name:asc
if want to order more than 1 field:
{{base_url}}/module-name?_order=name:asc|email:desc
Combine all searchable
{{base_url}}/module-name?_order=name:asc|email:desc&_search=name:lorem&_min=created_at:2022-02-02