<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
byjesper / laravel-decision-support-filament example snippets
use ByJesper\DecisionSupportFilament\DecisionSupportPlugin;
use Filament\Panel;
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugin(DecisionSupportPlugin::make());
}
use ByJesper\DecisionSupport\DecisionSupportManager;
app(DecisionSupportManager::class)
->registerProvider('employment-eligibility', EmploymentFactProvider::class);
// config/decision-support-filament.php
return [
// Where the GuideResource appears in the panel navigation.
'navigation' => [
'group' => 'Decision Support', // null to ungroup
'sort' => null, // int to order within the group
'icon' => 'heroicon-o-rectangle-group', // any registered icon
'label' => null, // null => "Guides"; string or translation key
],
// Override the singular/plural model labels (titles, breadcrumbs, buttons).
// null => Filament's defaults. Strings may be plain text or translation keys.
'labels' => [
'model' => null, // e.g. 'Decision guide'
'plural' => null, // e.g. 'Decision guides'
],
// How a guide is CREATED from the list: 'page' (default), 'modal', or
// 'slideover'. Editing always stays a full page — it hosts the versions.
'forms' => [
'layout' => 'page',
],
// The catalog of permissions an author can pick from (chosen ones stored on
// the guide at extra_attributes.permissions):
// null => no catalog; the field becomes a warning callout (you can't
// gate by permission until you supply one),
// array => a searchable multi-select with that catalog for every guide,
// closure => fn (?Guide $guide): array, resolved per guide so different
// guides offer different catalogs.
// 'mode' is the default for how the chosen permissions combine — 'any' (OR)
// or 'all' (AND); authors override it per guide (extra_attributes.permissions_mode).
'permissions' => [
'options' => null,
'mode' => 'any',
],
// The guide list table.
// scope_to_viewable => when true (default), the list shows only guides
// the user can view() per your Guide policy, so each
// guide's
public function view(User $user, Guide $guide): bool
{
$]
?? config('decision-support-filament.permissions.mode', 'any');
$held = collect($
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Builder;
$panel->plugin(
DecisionSupportPlugin::make()->scopeGuideListUsing(
fn (Builder $query, Authenticatable $user): Builder => $query
->whereJsonContains('extra_attributes->permissions', $user->guidePermissions()),
),
);