PHPackages                             rvanmarkus/modx-laravel-models - 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. [Database &amp; ORM](/categories/database)
4. /
5. rvanmarkus/modx-laravel-models

AbandonedArchivedLibrary[Database &amp; ORM](/categories/database)

rvanmarkus/modx-laravel-models
==============================

Build your application / website with help of Laravel and MODX

0.0.3(10y ago)14323MITPHPPHP &gt;=5.3.0

Since Oct 26Pushed 10y ago2 watchersCompare

[ Source](https://github.com/rvanmarkus/modx-laravel-models)[ Packagist](https://packagist.org/packages/rvanmarkus/modx-laravel-models)[ Docs](https://github.com/rvanmarkus/modx-laravel-models)[ RSS](/packages/rvanmarkus-modx-laravel-models/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (4)Versions (4)Used By (0)

MODX Laravel models
===================

[](#modx-laravel-models)

[Laravel](http://laravel.com) 5 Eloquent Database models to interact with [MODX](http://modx.com) database.

> This package helps you build Laravel applications that queries MODX pages/content and template variables. Use all the modern and beautiful features of the Laravel framework and give your users the ease of the MODX CMS.

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

[](#installation)

```
$ composer require rvanmarkus/modx-laravel-models

```

Or add this to your composer.json

```
"require": {
    "rvanmarkus/modx-laravel-models": "dev-master"
}

```

\##Getting started

Connect your laravel application to the same database as MODX, and use the same encoding settings. *(app/config/database.php)*

### Using the Rvanmarkus/Modxmodels/ModxContentModel class directly

[](#using-the-rvanmarkusmodxmodelsmodxcontentmodel-class-directly)

```
use Rvanmarkus\Modxmodels\ModxContentModel

//queries directly modx_site_content table => returns title, content, author, etc
$content = ModxContentModel::where('alias','=','/about-us')->get();

```

### Using your own model class that specifies a MODX template ID

[](#using-your-own-model-class-that-specifies-a-modx-template-id)

Create a new PHP Class and extend the Rvanmarkus/Modxmodels/PageModel. Create a new template in MODX manager and add the new template ID to the model.

*(ex. App/Books.php)*

```
use Rvanmarkus\Modxmodels\ModxPageModel

class Books extends ModxPageModel{
    const MODX_TEMPLATE_ID = 3; // id reference of the MODX (book) template (can be founded in MODX manager / or database)
}

$book = Books::where('alias','=','/example-book')
                ->with('templateVariables');
                ->published()
                ->sortPublished()
                ->get();

//Get your template variables from the templateVariables collection;
$book->templateVariables->get('NameOfTemplateVariables');

```

### Using your own model classes and scopes

[](#using-your-own-model-classes-and-scopes)

If you don't want a model that is specified by a template, create a model that extends the Rvanmarkus/Modxmodels/ModxContentModel class directly without the PageModel class. This class will query all the modx\_site\_content data by default, according the scopes you add. See the Eloquent documentation for more information.

Template variables
------------------

[](#template-variables)

You can eager load template variables by adding the 'TemplateVariables' relation (see Laravel [Eloquent Docs](http://laravel.com/docs/eloquent) for more information)

```
use Rvanmarkus/Modxmodels/ModxContentModel

//query content models where alias is'/about-us' and load all related template variables
$book = Books::with('templateVariables')
            ->where('alias','=','/john-doe-the-book')
            ->published()
            ->firstOrFail();

//for example: query the template variable (added in the MODX manager, with input type: *checkbox*) called 'Genres'

$tv = $book->templateVariables->get('Genres'); //ex. ['Roman','Science Fiction'] returns a array of selected checkbox TV values

```

The model automatically casts certain values of your template variables to Objects. The following template variable types will be automatically casted:

- Date
- Text
- checkbox (multiple values)
- MIGX data

example:

```
$book->templateVariables->get('DateTemplateVariable')
// returns Carbon DateTime Object value

$book->templateVariables->get('MIGXTemplateVariable')
// returns PHP Object value

$book->templateVariables->get('CheckboxTemplateVariable')
// returns PHP Array value

$book->templateVariables->get('TextTemplateVariable')
// returns string value

```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~2 days

Total

3

Last Release

3900d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b6b9b3e5b7cceb4762acb3aed21c3baa09d59e443184127054b1f6cd2a7c7b55?d=identicon)[rvanmarkus](/maintainers/rvanmarkus)

---

Top Contributors

[![rvanmarkus](https://avatars.githubusercontent.com/u/777833?v=4)](https://github.com/rvanmarkus "rvanmarkus (32 commits)")

---

Tags

laraveldatabasepdomodxeloquentcmsmodelsintergration

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rvanmarkus-modx-laravel-models/health.svg)

```
[![Health](https://phpackages.com/badges/rvanmarkus-modx-laravel-models/health.svg)](https://phpackages.com/packages/rvanmarkus-modx-laravel-models)
```

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.4M96](/packages/mongodb-laravel-mongodb)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k32.6M46](/packages/kirschbaum-development-eloquent-power-joins)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

592456.3k2](/packages/spiritix-lada-cache)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.5M2](/packages/glushkovds-phpclickhouse-laravel)

PHPackages © 2026

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