1. Go to this page and download the library: Download birdcar/laravel-label-graph 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/ */
use Birdcar\LabelGraph\Models\Concerns\HasLabels;
class Ticket extends Model
{
use HasLabels;
}
// Attach routes by path
$ticket->attachRoute('priority.high.critical');
$ticket->attachRoute('type.bug');
// Query by exact route
Ticket::whereHasRoute('priority.high')->get();
// Query by pattern (lquery-style: * matches zero or more labels)
Ticket::whereHasRouteMatching('priority.*')->get(); // priority and descendants
Ticket::whereHasRouteMatching('*.bug')->get(); // any path ending in bug
// Query descendants/ancestors
Ticket::whereHasRouteDescendantOf('priority')->get();
Ticket::whereHasRouteAncestorOf('priority.high.critical')->get();
use Birdcar\LabelGraph\Models\LabelRoute;
// Find routes by pattern
LabelRoute::wherePathMatches('priority.*')->get();
// Find descendants of a path
LabelRoute::whereDescendantOf('priority')->get();
// Find ancestors of a path
LabelRoute::whereAncestorOf('priority.high.critical')->get();