Skip to content

RelationshipGraph ​

Facade: Unusualify\Modularous\Facades\RelationshipGraph
Accessor: modularous.relationship.graph
Underlying: Unusualify\Modularous\Services\CacheRelationshipGraph

Builds and queries the model → module-route dependency graph used by ModularousCache to invalidate the right cache entries when a related model changes. See CacheRelationshipGraph for implementation details.

Methods ​

MethodSignatureDescription
isEnabled(): boolWhether relationship graph tracking is enabled
getGraph(): arrayReturns the full cached graph
buildGraph(): arrayBuilds the graph and stores it in cache
rebuildGraph(): arrayForces a fresh rebuild, ignoring the cached version
clearGraph(): voidRemoves the graph from cache
isCached(): boolWhether the graph is currently cached
getAffectedSubmodules(string $modelClass): arrayReturns module routes affected by a model class
getAffectedSubmodulesByTable(string $tableName): arrayReturns module routes affected by a table name
analyzeImpact(string $modelOrTable): arrayFull impact analysis for a model class or table name
getStats(): arrayReturns graph statistics (node count, edge count, etc.)
getVisualGraph(): arrayReturns graph data formatted for visualization

Usage ​

php
use Unusualify\Modularous\Facades\RelationshipGraph;

// Find which routes cache should be invalidated when a User is updated
$affected = RelationshipGraph::getAffectedSubmodules(\App\Models\User::class);
// → [['module' => 'Blog', 'route' => 'posts'], ...]

// Force a rebuild after adding new module relationships
RelationshipGraph::rebuildGraph();