Download the PHP package waad/laravel-generate-repository-api without Composer
On this page you can find all versions of the php package waad/laravel-generate-repository-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download waad/laravel-generate-repository-api
More information about waad/laravel-generate-repository-api
Files in waad/laravel-generate-repository-api
Package laravel-generate-repository-api
Short Description package to generate repository design pattern with all accessories
License MIT
Homepage https://github.com/waadmawlood/laravel-generate-repository-api
Informations about the package laravel-generate-repository-api
Generate Repository Design Pattern Api
you can create your restful api easily by using this library with filtering sorting
Installation:
Require this package with composer using the following command:
in config/app.php
⚠️ Change Default Guard from config/auth.php
=> defaults.guard
if you want use differnet guard.
\
in config/database.php
if use search multi column
\
🚀 About Me
I'm a Back End developer...
-
Author : Waad Mawlood
- Email : [email protected]
YAML Roadmap Job Of Package
Usage
- Generating All
if use force
in all that will generate (model
, migration
, controller api
, repository
, interface
, properties
, request forms
, route string in api or web
)
- Generating Some
\
- After migration Create validation And DTO Files
create table columns in migration and do migration
- Create permissions of model into database customs
⚠️ use it if refresh database or drop permissions from database `
`
`
\
- Filtering, Sorting And Properties Of Model
Example In properties/Car/CarPropertable
if you add manually
-
fillable : fill allowed fields to inserting and updating from
$fillable_override
array property -
filtering : fill allowed fields to filtering from
$filterable
array property that usefilter,find
parameter in request -
sorting : fill allowed fields to sorting from
$sortable
array property - Other :
Property in Model | Aliases in Propertable |
---|---|
$connection | $connection_override |
$table | $table_override |
$primary | $primary_override |
$primary | $primary_override |
$timestamps | $timestamps_override |
$incrementing | $incrementing_override |
$keyType | $keyType_override |
$hidden | $hidden_override |
$dates | $dates_override |
$casts | $casts_override |
$guarded | $guarded_override |
\
- Accessor And Mutator Of Model
Example In properties/Car/CarAccessorable
And properties/Car/CarMutatorable
if you add manually
-
In Accessor and Mutator files there are some examples to create accessor And Mutator methods
- Appending : add attributes for response from
$appends_override
array in Accessorable file
\
- Scopes Of Model
Example In properties/Car/CarScopable
if you add manually
- In Scopable file there are some examples to create scope methods
\
- Related Of Model
Example In properties/Car/CarRelatable
if you add manually
-
In Relatable file there are some examples to create Relationship methods with other models
- including : model allow include (join) with other model Relationship by used
$includeable
array property exampleuser
,user.city
when useinclude=model,user.city
in request - Other :
Property in Model | Aliases in Relatable |
---|---|
$with | $with_override |
$withCount | $withCount_override |
⚠️ don't remove use ConstructorableModel;
in Relatable
\
- Policy Of Controller
Example In Policies/CarPolicy
- first : Add Triats to any model used Authontication eg .
User
,Admin
in Model
Example
if you choose generate policy in command line with creating policy for model and controller will call to it automatic from cosntructor of controller ex $this->authorizeResource(Car::class, 'car');
- if don't define policy because of named or another problem define it from
app/Providers/AuthServiceProvider.php
example
🔥 Change Role Of Super from config/laravel-generate-repository-api.php
❤️ to clear cache of config
Example Policy for HasAnyRolePermissions
\ \
Examples with Requests
\
Parameter | Cases |
---|---|
include | string seperator "," comma |
sort | string with "-" DESC Order else ASC (support multiple nested seperator "," comma) |
select | return only select columns from table |
except | return all columns of table exclude except |
- http://127.0.0.1:8000/api/cars?include=user.city&filter[user.city.name]=baghdad
=>
user.city.name LIKE baghdad
Parameter | Cases |
---|---|
filter | array search also with relationsip used LIKE Operator In Database |
search | search multi columns with relationsip used LIKE Operator In Database use searchable property |
strict | flag boolean used with search if equal 1 or true will return more data else return few |
=> (user.city.name = baghdad) And (model.year < 1995 OR model.year > 2020)
- find same filter but not use
Like
Operator by defaultEqual
=
Operator | Aliases | Example |
---|---|---|
eq | = | find[user.name]=waad find[user.name]=eq:waad |
ne | != | find[user.name]=ne:waad |
gt | > | find[user.age]=gt:50 find[user.age]=gt:50:and:lt:100 |
ge | >= | find[user.age]=ge:50 find[user.age]=ge:50:and:le:100 |
lt | < | find[user.age]=lt:50 find[user.age]=lt:50:and:gt:10 |
le | <= | find[user.age]=le:50 find[user.age]=le:50:and:ge:10 |
notlike | NOT LIKE | find[user.name]=notlike:waad |
in | OR | find[user.age]=in:44,43 |
notin | NOT OR | find[user.age]=notin:44,43 |
null | NULL | find[user.name]=null |
notnull | NOT NULL | find[user.name]=notnull |
today | TODAY | find[car.created_at]=today |
nottoday | NOT TODAY | find[car.created_at]=nottoday |
😍 If you send values by base64
example find[user.age]={{b64(NTY=)}}
=> find[user.age]=56
\
- Use Pagination Or Unlimit Takes with Request
Use take
and page
Parameters
-
Pagination : use
Pagination
request form with take 100 default eg. - Unlimit : use
Unlimit
request form with take 100 default if use take eg.
\
- Return Trashed Records if use soft delete
Use trash
parameter including these values:
Operator | Meaning |
---|---|
current or NULL or empty | get records without trashed |
all | get all records with trashed |
trashed | get records only trashed |
\
- Use DTO Model, Pagination and List Responses
-
one model use direct DTO eg.
- Pagination model use paginate DTO from package eg.
OR
- List model use List DTO from package eg.
OR
\
License
All versions of laravel-generate-repository-api with dependencies
nicolaslopezj/searchable Version ^1.13
spatie/laravel-permission Version ^5.10
spatie/data-transfer-object Version ^3.9
spatie/laravel-query-builder Version ^5.2