PHP code example of doctorbeat / eloquent-repository
1. Go to this page and download the library: Download doctorbeat/eloquent-repository library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
doctorbeat / eloquent-repository example snippets
[Model:] [Repository:] [result]
- $model->parent $repo->getAttribute($model, 'parent'); the parent model
- $model->children $repo->getAttribute($model, 'children'); the child models as a collection
- $model->children() $repo->children($model); the child models as a relation
- $model->children()->save($child)
$repo->children($model, $child); add the child to the children of the model
- $model->children()->saveMany($list)
$repo->children($model, $list); add an array of new children to the children of the model