Download the PHP package anil/fast-api-crud without Composer
On this page you can find all versions of the php package anil/fast-api-crud. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download anil/fast-api-crud
More information about anil/fast-api-crud
Files in anil/fast-api-crud
Package fast-api-crud
Short Description Laravel API CRUD with extended controller
License MIT
Informations about the package fast-api-crud
About FastApiCrud
It provides basic to advanced CRUD (Create, Read, Update, Delete) functionality for a given model.
Composer
Installation
Child Constructor method
- $model: The name of the model that this controller is responsible for.
- $storeRequest: The name of the request class to use when storing data.
- $updateRequest: The name of the request class to use when updating data.
- $resource: The name of the resource class to use when returning data.
This package has auto-discovery for laravel 6 and higher and for below you can add this in your providers array
This package is build on Top of Spatie role and permission Register in Kernel.php if you want to apply permission as well
Eample
The class has several protected properties that can be overridden in child classes:
$scopes
: An array of scopes to apply when fetching all records.$scopeWithValue
: An array of scoped values to apply when fetching all records.$loadScopes
: An array of scopes to apply when fetching a record.$loadScopeWithValue
: An array of scoped values to apply when fetching a record.$withAll
: An array of relationships to eager load when fetching all records.$withCount
: An array of relationships to count when fetching all records.$withAggregate
: An array of aggregate functions to apply when fetching all records.$loadAll
: An array of relationships to eager load when fetching a single record.$loadCount
: An array of relationships to count when fetching a single record.$loadAggregate
: An array of aggregate functions to apply when fetching a single record.$isApi
: A boolean indicating whether the controller is being used as an API or not.$forceDelete
: A boolean indicating whether to perform a soft delete or a hard delete.$applyPermission
: A boolean indicating whether to apply permission or not.$deleteScopes
: An array of scopes to apply when deleting a record.$deleteScopeWithValue
: An array of scoped values to apply when deleting a record.$changeStatusScopes
: An array of scopes to apply when changing status of a record.$changeStatusScopeWithValue
: An array of scoped values to apply when changing status of a record.$restoreScopes
: An array of scopes to apply when restoring a record.$restoreScopeWithValue
: An array of scoped values to apply when restoring a record.$updateScopes
: An array of scopes to apply when updating a record.$updateScopeWithValue
: An array of scoped values to apply when updating a record.
The class has several methods that correspond to basic CRUD operations:
index()
- Return Collection of all records.store()
- Create a new record.show($id)
- Return a single record.destroy($id)
Delete a record.delete()
- Bulk delete records.changeStatusOtherColumn($id,$column)
- Change specific$column
value between 0 and 1 provided from child classupdate($id)
- Update a record.changeStatus($id)
- Change status column value of a record between 0 and 1.restoreTrashed($id)
- Restore a soft deleted record.restoreAllTrashed()
- Restore all soft deleted records.forceDeleteTrashed($id)
- Hard delete a soft deleted record.
There are also two helper methods, error()
and success()
, that return a JSON response with a message and data. These are used to standardize error and success responses across the controller.
for example
This package has also featured for making service ,action,trait file also
After installation, the command php artisan make:service {name} {--N|noContract}
will be available.
Create services files
For example, the command php artisan make:service createUser
will generate a service file called CreateUserService.php
located in app/Services/CreateUser
.
It will also generate an interface (contract) called CreateUserContract.php
located in app/Services/Contracts
.
Create services for models
Adding a --service
or -S
option is now available when creating a model.
For example, the command php artisan make:model Post --service
or php artisan make:model Post -S
will generate a model with service too.
The command php artisan make:model Post --all
or php artisan make:model Post -a
will now generate a model, migration, factory, seeder, policy, controller, form requests and service.
Contracts
Adding a --noContract
or -N
option will prevent the commands from implementing any contract and will not create any contract file.
If you never need any contracts. Publish the config file and then turn the with_interface value to false in the config file.
//running test on active branch
All versions of fast-api-crud with dependencies
illuminate/database Version ^7.0|^8.0|^9.0|^10.0|^11.0
illuminate/http Version ^7.0|^8.0|^9.0|^10.0|^11.0
illuminate/pagination Version ^7.0|^8.0|^9.0|^10.0|^11.0
illuminate/routing Version ^7.0|^8.0|^9.0|^10.0|^11.0
illuminate/support Version ^7.0|^8.0|^9.0|^10.0|^11.0
spatie/laravel-permission Version 6.*|5.*|4.*