Download the PHP package rvanmarkus/modx-laravel-models without Composer

On this page you can find all versions of the php package rvanmarkus/modx-laravel-models. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package modx-laravel-models

MODX Laravel models

Laravel 5 Eloquent Database models to interact with MODX 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

$ 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

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

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

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

You can eager load template variables by adding the 'TemplateVariables' relation (see Laravel Eloquent Docs 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:

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

All versions of modx-laravel-models with dependencies

PHP Build Version
Package Version
Requires illuminate/support Version ~5.0
php Version >=5.3.0
illuminate/database Version ~5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package rvanmarkus/modx-laravel-models contains the following files

Loading the files please wait ....