PHPackages                             robindrost/prismic-integration-field-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. robindrost/prismic-integration-field-laravel

ActiveLibrary

robindrost/prismic-integration-field-laravel
============================================

A package that allows you to convert your models or collection of models to an Prismic integration field ready array.

1.3(5y ago)23361MITPHPPHP ^7.1 || ^8.0CI failing

Since Sep 1Pushed 5y ago1 watchersCompare

[ Source](https://github.com/robindrost/prismic-integration-field-laravel)[ Packagist](https://packagist.org/packages/robindrost/prismic-integration-field-laravel)[ RSS](/packages/robindrost-prismic-integration-field-laravel/feed)WikiDiscussions master Synced yesterday

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

Prismic integration field for 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
------------

[](#installation)

```
composer require robindrost/prismic-integration-field-laravel

```

Usage
-----

[](#usage)

You can use the implementation of the integration field on your model in two ways.

1. You either specify the fields in the database that are required by the integration field.
2. Or your define attribute accessor methods like `getImageUrlAttribute()`.

### Model implementation example

[](#model-implementation-example)

Please note that I use a mix of option 1 and 2 here just as an example.

```
use RobinDrost\PrismicIntegrationField\IntegrationField;
use RobinDrost\PrismicIntegrationField\Contracts\IntegrationField as IntegrationFieldContract;

class MyModel extends Model implements ModelToIntegrationField
{
    // Using existing database fields
    public $fillable = [
        'id',
        'title',
        'description',
    ];

    // Using a getter method
    public function getImageUrlAttribute()
    {
        return 'https://via.placeholder.com/350x150';
    }

    // Convert this model to an integration field.
    public function toIntegrationField() : IntegrationFieldContract
    {
        IntegrationField::create()
            ->setId($this->id)
            ->setTitle($this->title)
            ->setDescription($this->description)
            ->setImageUrl($this->image_url)
            ->setUpdatedAt($this->updated_at->timestamp)
            ->setBlob([
                'id' => $this->id,
            ]);
    }
}

```

### Collection implementation

[](#collection-implementation)

```
// Override Laravels newCollectiom method:
class MyModel extends Model implements ModelToIntegrationField
{
    ...

    public function newCollection(array $models)
    {
        return new IntegrationFieldCollection($models);
    }
}

// Usage in your controller:
class MyController extends Controller
{
    public function myApiMethodCallback()
    {
        $models = MyModel::paginate(50);

        return response()->json([
            'results_size' => $models->total(),
            'results' => $models->getCollection()->toArray(),
        ]);
    }
}

```

And thats about it. Prismic can now handle the array returned by your collection.

Working with access tokens
--------------------------

[](#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.

1. First publish the configuration file to your config folder.

```
php artisan vendor:publish

```

And choose the service provider from this package.

2. Now add access tokens inside the added configuration file. This is just an array of strings.

### Apply the middleware on your routes

[](#apply-the-middleware-on-your-routes)

3. Add the middleware to your app/Http/Kernel.php.

```
protected $routeMiddleware = [

....
'prismic.verify.access.token' => \RobinDrost\PrismicIntegrationField\Http\Middleware\VerifyAccessToken::class,

];

```

4. Apply the middleware on your api routes:

```
Route::middleware('prismic.verify.access.token')->get('/your-path', 'YourController@index');

```

Now only allowed access tokens will reach the controller.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~308 days

Total

4

Last Release

1886d ago

PHP version history (2 changes)v1.0PHP ^7.1

1.3PHP ^7.1 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/919bc2d80025cfa2b8fa158a372dee82dbbe2796094dd7f2606f14e6acf13743?d=identicon)[robindrost](/maintainers/robindrost)

---

Top Contributors

[![S-Arba](https://avatars.githubusercontent.com/u/19268155?v=4)](https://github.com/S-Arba "S-Arba (2 commits)")[![robindrost](https://avatars.githubusercontent.com/u/588012?v=4)](https://github.com/robindrost "robindrost (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/robindrost-prismic-integration-field-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/robindrost-prismic-integration-field-laravel/health.svg)](https://phpackages.com/packages/robindrost-prismic-integration-field-laravel)
```

###  Alternatives

[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
