Download the PHP package fuzzyma/contao-eloquent-bundle without Composer
On this page you can find all versions of the php package fuzzyma/contao-eloquent-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fuzzyma/contao-eloquent-bundle
More information about fuzzyma/contao-eloquent-bundle
Files in fuzzyma/contao-eloquent-bundle
Package contao-eloquent-bundle
Short Description Creates possibility to use eloquents relations in your dca files
License MIT
Informations about the package contao-eloquent-bundle
ContaoEloquentBundle
This bundle depends on the great eloquent-bundle from wouterj which makes eloquent usable in symfony. We want to go a step further and integrate Eloquent in Contao.
At the moment this bundle implements
- hasMany, hasOne, belongsTo, belongsToMany relations
- command to create dca-files for pivot tables
- Several Traits you may use in your models
- ContaoModelConsumerTrait (turns contao models into eloquent models)
- Eloquent models for all core Contao models
More features which will be implemented:
- hasManyThrough
- morphTo
- morphMany
- morphToMany
- morphedByMany
Guide
1. Install the Bundle
2. Activate the Bundle
In your AppKernel.php add:
This bundles are now active. But we have to configure the eloquent environment. You can see how it works here: eloquent-bundle. But for simplification here is the short version:
3. Configure Eloquent
After this is done we can finally use it
Usage
Say we have a Topic
model and a Tag
model. Every Topic
can have multiple Tag
s and the other way round.
To use Eloquents relation we need a pivot table but contao does not understand pivot tables. Furthermore we want
a multiple select field for topics and tags which works just fine. We can do that:
The important part is the model key in the config section and the eloquent key in the tags section. Note: Make sure, that the field-name is the same as defined in the Model. So your Topic Model would look like this:
For further code and other relations see the contao-eloquent-example-project-bundle
Generator
This bundle comes shipped with a command to create the dca file for you which then creates the pivot table. Just run the following command:
For further options run
All versions of contao-eloquent-bundle with dependencies
symfony/console Version ^3.1
symfony/filesystem Version ^3.1
symfony/http-kernel Version ^3.1
contao/core-bundle Version ^4.2
wouterj/eloquent-bundle Version ^0.2.3