Download the PHP package innoflash/larastart without Composer
On this page you can find all versions of the php package innoflash/larastart. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download innoflash/larastart
More information about innoflash/larastart
Files in innoflash/larastart
Package larastart
Short Description This is the package to give access to common API functions
License MIT
Informations about the package larastart
LaraStart
Table of contents
- API Responses
- Exception Traits
- Auth Service
- CRUD Services
Installation
Usage
API Responses
This used for manipulating API JSON responses for calls
-
You can simply use for like:
- Usage on all your controllers
Calling the functions
and this gets you a response with status 200
ExceptionsTrait
This is to override Laravel error logging do that we sent all type of errors to our API clients
-
You can simply set it up by using the ExceptionsTrait in your
-
Now override the render function
- This overrides all errors and format
If you want the default error rendering
AuthService
- This one helps handle logging in and fetching the user access token.
- Works really well with JWT
SETUP
In the file you will need to add JWT secret key. Run the command below to get the key into your file
By default JWT tokens live for 60 minutes so if you want to alter the lifespan add the following in the file
Then in your you will need to inject the class in it
USAGE
- This is how simple you will call when you need the our desired results
- You can make the same call if you want login the user after registering
If you are using multi-auth you will need to pass the guard you are using for authentication
OUTPUT
CUSTOMIZATION
If you want to customize the the results you need to publish the config file
and this copies the into you config folder
- Edit the file to suit your needs
CRUD Service
This is meant to simplify the most CRUD operations and its best done by generating some service classes in the directory. The services handle basic
- Create
- Update
- Delete
- Select
SETUP
Just create run an artisan command to create the and customize all you want if the boilder plate is not sufficient for you
- Almost done, you now need to inject your service class into the controller as follows
Alternatively you can inject the service directly into your controller functions.
- If you are going to use the in more than one class ie. the controller (and you wanna use it in requests and resources and wherever) you will have to add the into the as a singleton so that the app does not have rerun querying the model
Good to go, now let`s see how to run crud functions here
Please note that for all CRUD Ops (except destroy) you can pass a
boolean flag
oftrue
if you want to return the object and skip responding as JSON.Also keep in mind that the services are wired in such a way that they can fetch route-model-bound models.
SELECT QUERY
DELETE QUERY
`
UPDATE QUERY
CREATE QUERY
SPECIAL CREATE QUERY
Oftenly we would wanna create models based on a model they belong to. You will need to override the in the (overriding the CRUDService class method)
When the service is setup now you can do the create function
All versions of larastart with dependencies
tymon/jwt-auth Version ^1.0.0-rc.5.1
php Version ^7.4|^8.0