Download the PHP package mistersaal/laravel-mongodb-embedded-models without Composer

On this page you can find all versions of the php package mistersaal/laravel-mongodb-embedded-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 laravel-mongodb-embedded-models

Laravel Mongodb embedded models

A more productive and simpler solution for embedding models in mongodb models than custom casts in Laravel. This package is extension for jenssegers/mongodb package.

In new develop version of jenssegers/mongodb for Laravel 7 removed embedding relations. Instead of relations, it is proposed to use custom casts of Laravel. But custom casts is really bad for performance (read more) when we have multi-level embedding, for example: User:

Laravel calls cast set method on every action with model, and all of embedded models is converting to array every time. I may then post more detailed test results, but believe me, when there are a lot of calls to the model, custom casts load the system very much.

Installation

Make sure you have the jenssegers/mongodb develop installed.

Install the package via Composer:

Usage

Your every Model where there is an embedded model should implements Mistersaal\Mongodb\Embed\HasEmbeddedModelsInterface and use Mistersaal\Mongodb\Embed\HasEmbeddedModels trait.

Every model must has $fillable or $guarded property for mass assignment.

In every Model where there is an embedded model you should define protected $embedMany = []; or/and protected $embedOne = []; where key is name of attribute and value is Model class name.

In embedOne relation, the attribute will be cast to the Model when the Model is received from the database. In embedMany relation, the attribute will be cast to the Laravel Collection of Models. When Model is saving to database, Models is converting to array of attributes.

In every Model where there is an embedded model, you should define constructor method:

To save embedded models, just save base model. All actions are making through base model.

Example of code:

If you want to override static boot method, you should save it initial structures:


All versions of laravel-mongodb-embedded-models with dependencies

PHP Build Version
Package Version
Requires jenssegers/mongodb Version dev-develop
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 mistersaal/laravel-mongodb-embedded-models contains the following files

Loading the files please wait ....