poing / ylem
ylem /ˈiːlɛm/ - noun - (in the Big Bang theory) the primordial matter of the universe, originally conceived as composed of neutrons at high temperature and density..
Installs: 60
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 3
Language:CSS
Requires
- php: ^7
- gazsp/baum: ~1.1
- illuminate/config: ~5.0
- illuminate/support: ~5.0
Requires (Dev)
- laravel/framework: ^5.7
- orchestra/testbench: ~3.7
- phpunit/phpunit: ^7
- dev-master
- 0.1.1.x-dev
- 0.1.0.x-dev
- 0.0.11.x-dev
- dev-dependabot/composer/guzzlehttp/guzzle-6.5.8
- dev-dependabot/composer/guzzlehttp/psr7-1.8.5
- dev-dependabot/composer/symfony/http-foundation-4.4.1
- dev-0.1.1-Issues16and17
- dev-0.1.0-ContactMedium
- dev-overhaul
- dev-newIssueBuilds
- dev-rebuild
- dev-frontendToPackage
This package is auto-updated.
Last update: 2024-10-21 22:52:50 UTC
README
ylem /ˈiːlɛm/ noun
(in the Big Bang theory) the primordial matter of the universe, originally conceived as composed of neutrons at high temperature and density.
ylem
This is an implementation of the TMF632 Party Management API REST Specification in Laravel. Supporting Individual, Organization, & Organizational Unit relational hierarchies.
composer require poing/ylem
php artisan ylem:seed
Like the primordial substance from which all matter is formed, this is intended as the core application fabric for business and consumer interaction.
Directed Acyclic Graph (DAG)
Topological ordering and directed acyclic graph functions are provided for Laravel Eloquent models by the gazsp/baum
package. baum/baum
is no longer maintained. While some key functions will be covered in this document, see the complete documentation for additional functions.
The use of the Dijkstras algorithm, to determine the shortest path, is not a necessary consideration of this project. Dijkstras algorithm functionally is not provided by the gazsp/baum
package anyway.
Package discovery for gazsp/baum
is handled by the extra section of this packages composer.json
file. Just to make it easier to use.
Recursive Functions
Recursive functions are important for cyclining through all elements in the tree. This is because the depth
of nodes and all decendants will be different. This is the advantage that DAG provides, you're not locked into a strict level of hierarchies.
.
├── alpha
│ └── bravo
│ └── charlie
└── one
└── two
└── three
└── four
└── five
└── six
└── seven
└── eight
└── nine
└── ten
└── eleven
└── twelve
Blade
Below is an example of recursive iteration using the Blade templating engine provided with Laravel. Recursive iteration can be acheived with PHP
and other languages too. Generating an unordered list output, similar to the tree shown above.
function getBlade() // Function or Route { $roots = \App\DirectedAcyclicGraph::roots()->get(); return view('roots', compact('roots')); }
<!-- roots.blade.php --> <ul> @foreach ($roots as $item) <li>{{ $item->someValue }}</li> @include('nodes', array('items' => $item->getImmediateDescendants())) @endforeach </ul>
<!-- nodes.blade.php --> </ul> @foreach ($items as $item) <li>{{ $item->someValue }}</li> @include('nodes', array('items' => $item->getImmediateDescendants())) @endforeach </ul>
Quick Start
- Create a Laravel Project
laravel new project_name -or- composer create-project --prefer-dist laravel/laravel project_name
cd project_name
composer require poing/ylem
- Publish the Laravel package
php artisan vendor:publish --provider Ylem\\Providers\\YlemServiceProvider
php artisan migrate
- Seed the demo table This could take a while, builds
10
root nodes with random nested itmes.
php artisan db:seed --class=Ylem\\Database\\Seeds\\StubSeeder
- Open
/ylem
in a browser.
Stub Model and Data
You will see the random data associated to Ylem\Models\Stub
. This is simply a test table, once seeded, it can be used to examine the relationships. Faker is used to create: Company Name, JOB TITLE, and People Name.
$faker->company └── strtoupper($faker->jobTitle) └── $faker->name
php artisan tinker
Here are some tinker
commands to check out:
$node = Ylem\Models\Stub::find(50); $node->isRoot(); // Checks if root node $node->getRoot(); // Gets the root node $node->parent()->get(); // Gets parent node, if not root $node->siblings()->get(); // Gets siblings, sharing the same parent $node->children()->get(); // Gets any children for this node