PHPackages                             onpage-dev/laravel-plugin - 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. onpage-dev/laravel-plugin

ActiveLibrary

onpage-dev/laravel-plugin
=========================

A demo package

v1.39(2mo ago)2940PHP

Since May 26Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/onpage-dev/laravel-plugin)[ Packagist](https://packagist.org/packages/onpage-dev/laravel-plugin)[ RSS](/packages/onpage-dev-laravel-plugin/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (42)Used By (0)

On Page ® Laravel plugin
========================

[](#on-page--laravel-plugin)

This package implements all the OnPage data and data structure in any Laravel application. All the CLI command have to be execute at your Laravel project main directory.

Installation
------------

[](#installation)

Add the repository to your composer file and install the package:

```
composer require onpage-dev/laravel-plugin:^v1
```

Publish the configuration file

```
php artisan vendor:publish --provider 'OnPage\OnPageServiceProvider'
```

Run plugin migrations (we use the `op_*` prefix for our tables)

```
php artisan migrate
```

### Upgrade

[](#upgrade)

Run plugin migrations (we use the `op_*` prefix for our tables)

```
composer upgrade onpage-dev/laravel-plugin
```

Configuration
-------------

[](#configuration)

1. Go to your On Page and generate a new snapshot from the "Snapshot Generator" section
2. Copy the Snapshot Generator API token
3. Add the following to your `.env` file: ```
    ONPAGE_TOKEN=SNAPSHOT-GENERATOR-API-TOKEN
    ```

By default, the plugin will create a `onpage-models` directory in your base directory. The folder will be filled with On Page generated models, which you should not modify, as they are generated automatically. By default, the models will live in the Data namespace, so you can access them using `\Data\ModelName::...`. To make this work, you need to instruct composer to preload this folder.

```
{
  ...
  "autoload": {
    "psr-4": {
      ...
      "Data\\": "onpage-models"
    },
  }
}
```

Finally make sure to update composer.

```
composer dumpautoload
```

Import data
-----------

[](#import-data)

To import your data execute this command:

```
php artisan onpage:import
```

**Error prevention**If some resources or fields have been removed or changed, the import will prompt you whether you want to continue or not. You can use the `--force` flag to ignore this warning.

```
php artisan onpage:import --force # Not recommended
```

**Useless import prevention**If you try to import same data you already have, the import is stopped. You can use the `--anyway` flag to ignore this warning.

```
php artisan onpage:import --anyway # Not recommended
```

Restore a previous snapshot
---------------------------

[](#restore-a-previous-snapshot)

Each time you import data, the snapshot is saved locally in your Laravel project. If you want to restore a previous snapshot execute the rollback command and digit the number associated at the snapshot choosen.

```
php artisan onpage:rollback
```

Querying data
-------------

[](#querying-data)

Because the plugin does not actually generate tables and columns corresponding for your data, you will have to use the `whereField` function instead of the `where` clause, which works in the same manner. If you have trouble doing some operations, please open an issue explaining your use case.

```
// Search by native fields (id, created_at, updated_at, order)
\Data\Products::where('id', 123123)->first();

// For other fields, use the `whereField` function
\Data\Products::whereField('code', 'AT-1273')->first();

// By default, the filter will be applied on the current locale language
\Data\Products::whereField('description', 'like', '%icecream%')->get();

// You force the filter to search for values in a specific language
\Data\Products::whereField('description.it', 'like', '%gelato%')->paginate();

// To query relations, you can use the standard whereHas laravel function
\Data\Products::whereHas('categories', function($q) {
    $q->whereField('is_visible', true);
})->get();

// If you have a file field, you can query by token and by name
\Data\Products::whereField('image:name', 'gelato.jpg')->get();
\Data\Products::whereField('image:token', '79YT34R8798FG7394N')->get();

// For dimension fields (dim2 and dim3) you can use both the x,y,z selectors, or the 0,1,2 selectors
\Data\Products::whereField('dimension:x', '>', 100)->get();
// ... is the same as
\Data\Products::whereField('dimension:0', '>', 100)->get();

// If you have to filter on a time basis
\Data\Products::where('created_at', '>', '2026-01-28 12:30:00')
\Data\Products::where('updated_at', '>=', '2026-01-26 00:00:00')->where('updated_at', '',200)->get()

// Suffix 'Not' for negative query
\Data\Products::whereFieldNot('calories','like','low calorie')->get()

// Suffix 'In' for search in an array of values
\Data\Products::whereFieldIn('code',['4','8','15','16','23','42'])->get();
```

You can also combine them to obtain more advanced clauses, which work in the same manner.

```
$q->orWhereFieldNot(...)
$q->orWhereFieldIn(...)
$q->whereFieldNotIn(...)
$q->orWhereFieldNotIn(...)
```

Getting values
--------------

[](#getting-values)

Once you get your records, you need to display the related data. To access field data for a record, you need to use the `->val($field_name, $lang)` function. The `$lang` is set to use the current default language. Examples:

```
// Native field values:
$product->id // 123123
$product->created_at // 2022-01-01 00:00:00
$product->updated_at // 2023-02-03 01:30:00

// Field values:
$product->val('name') // Icecream
$product->val('name', 'it') // Gelato
```

### Multivalue fields

[](#multivalue-fields)

For fields which contain multiple values, the `val` function will always return a collection of the values:

```
echo $product->val('descriptions')->first();
// ... or
foreach ($product->val('descriptions') as $descr) {
    echo "- $descr\n";
}
```

### File and image fields

[](#file-and-image-fields)

For these files, the returned value will be an instance of `\OnPage\File::class`. To get a file or image url use the `->link()` function. The link will point to the original file.

```
// Original size
$product->val('specsheet')->name // Icecream-spec.pdf
$product->val('specsheet')->token // R417C0YAM90RF
$product->val('specsheet')->link() // https://acme-inc.onpage.it/api/storage/R417C0YAM90RF?name=icecream-spec.pdf
```

To turn images into a thumbnail add an array of options as shown below:

```
// Maintain proportions width 200px
$product->val('cover_image')->link(['x' => 200])

// Maintain proportions height 100px
$product->val('cover_image')->link(['y' => 100])

// Crop image to width 200px and height 100px
$product->val('cover_image')->link(['x' => 200, 'y' => 100])

// Maintain proportions and contain in a rectangle of width 200px and height 100px
$product->val('cover_image')->link(['x' => 200, 'y' => 100, 'contain' => true])

// Convert the image to png (default is jpg)
$product->val('cover_image')->link(['x' => 200, 'ext' => 'png'])
```

Getting Resources and Fields
----------------------------

[](#getting-resources-and-fields)

```
// Get a resource definition by name:
$prod_res = \Onpage\resource('prodotti') // Returns \OnPage\Resource::class
$prod_res->label; // "Prodotti"
$prod_res->name; // "products"
$prod_res->labels; // [ 'it' => 'Prodotti', 'en' => 'Products' ]

// Get all fields available for this resource:
$weight_field = $prod_res->field('weight'); // Returns \OnPage\Field::class or null
$weight_field->label; // "Peso"
$weight_field->name; // "weight"
$weight_field->type; // "real"
$weight_field->getUnit(); // "kg"
$weight_field->labels; // [ 'it' => 'Peso', 'en' => 'Weight' ]
$weight_field->descriptions; // 'Rappresenta il peso espresso in kg'
$weight_field->description; // [ 'it' => 'Rappresenta il peso espresso in kg', 'en' => 'Represents the weight expressed in kg' ]

// Get all resource fields:
$prod_res->fields // Collection of \OnPage\Field::class

// Print all fields of the products resource
foreach($products->fields as $field) {
  echo "- $field->label (type: $field->type)\n"
}
```

Using Fields Folders
--------------------

[](#using-fields-folders)

```
$prod_res = \Onpage\resource('prodotti') // Returns \OnPage\Resource::class

$prod_res->field_folders; // Collection of \OnPage\FieldFolders::class

$field_folder = $prod_res->field_folders->first() // get the first field folder
$field_folder->label; // "Folder1"

$field_folder->fields; // Collection of \OnPage\Field::class

$prod_res->things->first()->default_folder; // Get the default folder for the thing or null
```

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance83

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 54.9% 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 ~44 days

Total

40

Last Release

85d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/52adca625277f0a3baa22350a32c7a92d083433d14c8671c044c6554aab24e75?d=identicon)[dinside](/maintainers/dinside)

---

Top Contributors

[![gufoe](https://avatars.githubusercontent.com/u/4093558?v=4)](https://github.com/gufoe "gufoe (50 commits)")[![mirnero](https://avatars.githubusercontent.com/u/69771335?v=4)](https://github.com/mirnero "mirnero (28 commits)")[![CapitanPNG](https://avatars.githubusercontent.com/u/71767537?v=4)](https://github.com/CapitanPNG "CapitanPNG (10 commits)")[![AlessioGiacobbe](https://avatars.githubusercontent.com/u/16188637?v=4)](https://github.com/AlessioGiacobbe "AlessioGiacobbe (2 commits)")[![mirko-onpage](https://avatars.githubusercontent.com/u/84335418?v=4)](https://github.com/mirko-onpage "mirko-onpage (1 commits)")

### Embed Badge

![Health badge](/badges/onpage-dev-laravel-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/onpage-dev-laravel-plugin/health.svg)](https://phpackages.com/packages/onpage-dev-laravel-plugin)
```

PHPackages © 2026

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