PHP code example of guava / filament-knowledge-base
1. Go to this page and download the library: Download guava/filament-knowledge-base 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 Filament\Panel;
use Guava\FilamentKnowledgeBase\KnowledgeBasePlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
// ...
KnowledgeBasePlugin::make(),
])
}
use Guava\FilamentKnowledgeBase\Filament\Panels\KnowledgeBasePanel;
KnowledgeBasePanel::configureUsing(
fn(KnowledgeBasePanel $panel) => $panel
->viteTheme('resources/css/filament/admin/theme.css') // your filament vite theme path here
);
use Guava\FilamentKnowledgeBase\Contracts\HasKnowledgeBase;
use Guava\FilamentKnowledgeBase\Facades\KnowledgeBase;
class UserResource extends Resource implements HasKnowledgeBase
{
// ...
//
public static function getDocumentation(): array
{
return [
'users.introduction',
'users.authentication',
KnowledgeBase::model()::find('users.permissions'),
];
}
}
use Guava\FilamentKnowledgeBase\Actions\Forms\Components\HelpAction;
->hintAction(HelpAction::forDocumentable('projects.creating-projects.slug')
->label('What is a slug?')
->slideOver(false)
),
use \Guava\FilamentKnowledgeBase\KnowledgeBase;
// find specific model
KnowledgeBase::model()::find('<id>');
// query models
KnowledgeBase::model()::query()->where('title', 'Some title');
// etc.
use Guava\FilamentKnowledgeBase\Filament\Panels\KnowledgeBasePanel;
KnowledgeBasePanel::configureUsing(
fn(KnowledgeBasePanel $panel) => $panel
// Your options here
);
use Guava\FilamentKnowledgeBase\Filament\Panels\KnowledgeBasePanel;
KnowledgeBasePanel::configureUsing(
fn(KnowledgeBasePanel $panel) => $panel
->brandName('My Docs')
);
use Guava\FilamentKnowledgeBase\Filament\Panels\KnowledgeBasePanel;
KnowledgeBasePanel::configureUsing(
fn(KnowledgeBasePanel $panel) => $panel
->articleClass('max-w-2xl')
);
use Guava\FilamentKnowledgeBase\Filament\Panels\KnowledgeBasePanel;
KnowledgeBasePanel::configureUsing(
fn(KnowledgeBasePanel $panel) => $panel
->disableDefaultClasses()
);
use \Filament\View\PanelsRenderHook;
$plugin->disableKnowledgeBasePanelButton();
use Guava\FilamentKnowledgeBase\Filament\Panels\KnowledgeBasePanel;
KnowledgeBasePanel::configureUsing(
fn(KnowledgeBasePanel $panel) => $panel
->disableBackToDefaultPanelButton()
);
use \Filament\View\PanelsRenderHook;
$plugin->helpMenuRenderHook(PanelsRenderHook::TOPBAR_START);
use Guava\FilamentKnowledgeBase\Filament\Panels\KnowledgeBasePanel;
KnowledgeBasePanel::configureUsing(
fn(KnowledgeBasePanel $panel) => $panel
->disableTableOfContents()
);
use Guava\FilamentKnowledgeBase\Filament\Panels\KnowledgeBasePanel;
use Guava\FilamentKnowledgeBase\Enums\TableOfContentsPosition;
KnowledgeBasePanel::configureUsing(
fn(KnowledgeBasePanel $panel) => $panel
->tableOfContentsPosition(TableOfContentsPosition::Start)
);
use Guava\FilamentKnowledgeBase\Filament\Panels\KnowledgeBasePanel;
KnowledgeBasePanel::configureUsing(
fn(KnowledgeBasePanel $panel) => $panel
->anchorSymbol('¶')
);
use Guava\FilamentKnowledgeBase\Filament\Panels\KnowledgeBasePanel;
KnowledgeBasePanel::configureUsing(
fn(KnowledgeBasePanel $panel) => $panel
->disableAnchors()
);
$plugin->modalPreviews();
$plugin->slideOverPreviews();
use Guava\FilamentKnowledgeBase\Filament\Panels\KnowledgeBasePanel;
KnowledgeBasePanel::configureUsing(
fn(KnowledgeBasePanel $panel) => $panel
->disableBreadcrumbs()
);
$plugin->modalTitleBreadcrumbs();
$plugin->openDocumentationInNewTab()
use Guava\FilamentKnowledgeBase\Filament\Panels\KnowledgeBasePanel;
KnowledgeBasePanel::configureUsing(
fn(KnowledgeBasePanel $panel) => $panel
->guestAccess()
);
use Guava\FilamentKnowledgeBase\Filament\Panels\KnowledgeBasePanel;
KnowledgeBasePanel::configureUsing(
fn(KnowledgeBasePanel $panel) => $panel
->syntaxHighlighting()
);