|Maintainer Contact:||firstname.lastname@example.org (Coen Zimmerman)|
|Package Create Date:||2015-10-10|
|Package Last Update:||2020-06-18|
|Last Refreshed:||2022-09-28 15:08:45|
|Total Open Issues:||0|
PXL CMS Adapter for Laravel.
Laravel | Package :---------|:-------- 5.1.x | 1.1.x 5.2.x | 1.2.x
$ composer require czim/laravel-pxlcms
Add this line of code to the providers array located in your
Publish the configuration:
$ php artisan vendor:publish
Generated Models work, for the most part, exactly like normal Eloquent Models. This includes relationships, updating, eager loading and so forth. There are a few caveats:
$model->categoryon an unloaded relationship will not trigger the magic property since the attribute is present. You will get the ID integer instead. To get around this, simply call the relation method itself (ie.
e_active = true).
withInactive()scope (ie. something like
unordered()scope (ie. something like
->remember()method on any Eloquent Builder instance for the models.
See the configuration file for ways to change or disable the above.
Image and File fields are set up as special relationships on the generated model. If you use the magic property for the relationship on the model, like so:
// For a model with a relationship: images() to the CMS Image model $model->images
... then the image results will be enriched with information about resizes and the external URLs to the images or files.
$image = $model->images->first(); // This will return the external URL to the (base) image $image->url // This will return the local path to the file $image->localPath // This will list all resizes with appended prefixes and full URLs $image->resizes
Saving images will work, but will not affect resizes. Note that Laravel leaves you free to update the Image model's records with nonexistant files. Additionally, no resize files will be generated for any fresh images this way.
Note that this will work for translated images and uploads. Relationships will only return results for the current locale. The locale used may be overridden (generated model code allows this by default):
// Return image results for locale other than the active application locale $englishImage = $model->images('en')->first(); $dutchImage = $model->images('nl')->first();
A modified version of the Sluggable Eloquent model trait is used to handle slugs for the models that were 'sluggified' during model generation. This works mostly like the original Sluggify, with some exceptions:
cms_slugstable (which can be defined in the generator config). If so, the change is transparent when using Sluggable methods.
findBymethod is now expanded with an optional
localeparameter, wich limits slug searches to a specific locale/language:
findBy($slug, $locale = null). Likewise, the
whereSlugscope has an optional
SluggableInterfaceand delegate the relevant calls to the translation model.
The code generator is run through the Artisan command:
It will analyze the database CMS content, if it can find it, and generate code based on the
pxclms.php config file.
The following options are available:
--auto automatic mode, skips interactivity --dry-run performs analysis and outputs data without writing any files -v verbose mode, shows debug output
detect typical cms_m#_languages table
detect typical multilingual_labels table
The MIT License (MIT). Please see License File for more information.