Prismoquent lets you access using the same methods you're used to in Eloquent.

0.5.1 2019-05-09 19:42 UTC

This package is auto-updated.

Last update: 2021-11-10 01:06:35 UTC


CircleCI Build Status Code Coverage Status Stable version on Packagist Dev version on Packagist Code Style Status License

This package provides a mostly Eloquent-compatible Model that you can use to access content from as though it were a standard Eloquent model.


class Page extends \Galahad\Prismoquent\Model
	// Automatically inferred from class name ("page") if left unset
	protected $type;
	// Cast RichText to text or HTML (all other cast types also supported)
	protected $casts = [
		'title' => 'text',
		'body' => 'html',
	// Resolve links as though they were relationships
	public function authorLinkResolver() : ?Person
		return $this->hasOne('author', Person::class);
	// Also supports repeating groups of links
	public function similarPagesLinkResolver()
		return $this->hasMany('', static::class);


class PageController extend Controller
	public function show(Page $page)
		return view('', compact('page'));


<h1>{{ $page->title }}</h1>

<div class="page-body">
	{{ $page->body }}
// Familiar API
$page = Page::where('', 'W2N5Dx8AAD1TPaYt')->first();
$page = Page::find('W2N5Dx8AAD1TPaYt');
$page = Page::findOrFail('W2N5Dx8AAD1TPaYt');

echo "<h1>{$page->title}</h1>";
echo $page->body;

echo "<p>Written by {$page->author->name}</p>"
echo "<h2>Similar Pages</h2>";

foreach ($page->similar_pages as $similar_page) {
	echo "<h3>{$similar_page->title}</h3>";
	echo "<p>{$similar_page->meta_description}</p>";

// With full support for all Prismic predicates
Page::where('', 'fulltext', 'laravel')->get();

Warning: Active Development

This project is still in active development and may have many bugs. Use at your own risk!


You can install the package via composer:

composer require glhd/laravel-prismoquent


See above for a basic example. More details coming soon.


Looks for config in your services.php file:

return [
	'prismic' => [
		'endpoint' => env('PRISMIC_ENDPOINT'), // Required
		'api_token' => env('PRISMIC_API_TOKEN'), // Optional, depending on your Prismic permissions
		'webhook_secret' => env('PRISMIC_WEBHOOK_SECRET'), // Optional, if you're using build-in controller
		'register_controller' => false, // Set to false to disable Webhook controller

Link Resolution

You can register link resolvers as either a callable or a route name:

// In your AppServiceProvider
Prismic::registerResolver('page', '');
Prismic::registerResolver('person', function(DocumentLink $link) {
	return url('/people/'.$link->getUid());

// In your web.php route file
Route::get('/pages/{page}', 'PageController@show')->name('');

If you do not set up a resolver, Prismoquent will try a resource route for your document. So Page will try route('', $uid) or NewsItem will try route('', $uid).

Once your resolvers are defined, you can resolve links in any Prismic Fragment using:

$html = Prismic::asHtml($fragment);

Blade Directives

{{-- Will render slice object using views/slices/slice-type.blade.php --}}

{{-- Will render all slices in slice zone using @slice directive --}}

{{-- Converts frament to HTML using link resolver --}}

{{-- Converts frament to plain text --}}

{{-- Converts a DocumentLink fragment to the resolved URL --}}


The MIT License (MIT). Please see License File for more information.