Download the PHP package robindrost/prismic-integration-field-laravel without Composer
On this page you can find all versions of the php package robindrost/prismic-integration-field-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download robindrost/prismic-integration-field-laravel
More information about robindrost/prismic-integration-field-laravel
Files in robindrost/prismic-integration-field-laravel
Package prismic-integration-field-laravel
Short Description A package that allows you to convert your models or collection of models to an Prismic integration field ready array.
License MIT
Informations about the package prismic-integration-field-laravel
Prismic integration field for Laravel
This package allows you to use Eloquent models as Prismic integration fields. You must implement an interface and have an option to use the trait on your models.
The package also provides a middleware that will verify the access tokens from Prismic.
Installation
Usage
You can use the implementation of the integration field on your model in two ways.
- You either specify the fields in the database that are required by the integration field.
- Or your define attribute accessor methods like
getImageUrlAttribute()
.
Model implementation example
Please note that I use a mix of option 1 and 2 here just as an example.
Collection implementation
And thats about it. Prismic can now handle the array returned by your collection.
Working with access tokens
This package also provide an easy way of protecting routes with access tokens. Prismic allows you to define access tokens for each integration field. These access tokens need to be defined in the config file and used by the middleware provided by this package.
- First publish the configuration file to your config folder.
And choose the service provider from this package.
- Now add access tokens inside the added configuration file. This is just an array of strings.
Apply the middleware on your routes
-
Add the middleware to your app/Http/Kernel.php.
- Apply the middleware on your api routes:
Now only allowed access tokens will reach the controller.