PHP code example of schenke-io / laravel-relation-manager
1. Go to this page and download the library: Download schenke-io/laravel-relation-manager 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/ */
schenke-io / laravel-relation-manager example snippets
// app/Console/Commands/RelationWriteCommand
use SchenkeIo\LaravelRelationManager\Console\RelationManagerCommand;
class RelationWriteCommand extends RelationManagerCommand
{
public function handle(): void
{
$this->relationManager->model('Country')
->hasOne('Capital', true)
->hasMany('Region', true);
$this->relationManager->model('Region')
->hasMany('City', true);
// repeat this for any model
// finally
$this->relationManager
->writeMarkdown()
->showTables()
->writeTest(strict: true)
->runTest();
}
}
bash
php artisan relation-manager:install