1. Go to this page and download the library: Download beier/filament-pages 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/ */
beier / filament-pages example snippets
use Beier\FilamentPages\Filament\FilamentPageTemplates\DefaultTemplate;
use Beier\FilamentPages\Filament\Resources\FilamentPageResource;
use Beier\FilamentPages\Models\FilamentPage;
use Beier\FilamentPages\Renderer\SimplePageRenderer;
return [
'filament' => [
/*
|--------------------------------------------------------------------------
| Filament: Custom Filament Resource
|--------------------------------------------------------------------------
|
| Use your own extension of the FilamentPageResource
| below to fully customize every aspect of it.
|
*/
'resource' => FilamentPageResource::class,
/*
|--------------------------------------------------------------------------
| Filament: Custom Filament Model
|--------------------------------------------------------------------------
|
| Use your own extension of the FilamentPage Model
| below to fully customize every aspect of it.
|
*/
'model' => FilamentPage::class,
/*
|--------------------------------------------------------------------------
| Filament: Title Attribute
|--------------------------------------------------------------------------
|
| Point to another field or Attribute to change the
| computed record title provided in filament.
|
*/
'recordTitleAttribute' => 'title',
/*
|--------------------------------------------------------------------------
| Filament: Label
|--------------------------------------------------------------------------
|
| If you don't need to support multiple languages you can
| globally change the model label below. If you do,
| you should rather change the translation files.
|
*/
'modelLabel' => 'Page',
/*
|--------------------------------------------------------------------------
| Filament: Plural Label
|--------------------------------------------------------------------------
|
| If you don't need to support multiple languages you can
| globally change the plural label below. If you do,
| you should rather change the translation files.
|
*/
'pluralLabel' => 'Pages',
'navigation' => [
/*
|--------------------------------------------------------------------------
| Filament: Navigation Icon
|--------------------------------------------------------------------------
|
| If you don't need to support multiple languages you can
| globally change the navigation icon below. If you do,
| you should rather change the translation files.
|
*/
'icon' => 'heroicon-o-document',
/*
|--------------------------------------------------------------------------
| Filament: Navigation Group
|--------------------------------------------------------------------------
|
| If you don't need to support multiple languages you can
| globally change the navigation group below. If you do,
| you should rather change the translation files.
|
*/
'group' => 'content',
/*
|--------------------------------------------------------------------------
| Filament: Navigation Group
|--------------------------------------------------------------------------
|
| If you don't need to support multiple languages you can
| globally change the navigation sort below. If you do,
| you should rather change the translation files.
|
*/
'sort' => null,
]
],
/*
|--------------------------------------------------------------------------
| Templates
|--------------------------------------------------------------------------
|
| Add your own Templates implementing FilamentPageTemplate::class
| below. They will appear in the Template selection,
| and persisted to the data column.
|
*/
'templates' => [
DefaultTemplate::class,
],
/*
|--------------------------------------------------------------------------
| Renderer
|--------------------------------------------------------------------------
|
| If you want to use the Rendering functionality, you can create your
| own Renderer here. Take the available Renderers for reference.
| See FilamentPageController for recommended usage.
|
| Available Renderers:
| - SimplePageRenderer:
| Renders everything to the defined layout below.
| - AtomicDesignPageRenderer:
| More opinionated Renderer to be used with Atomic Design.
|
| To use the renderer, Add a Route for the exemplary FilamentPageController:
|
| Route::get('/{filamentPage}', [FilamentPageController::class, 'show']);
|
| To route the homepage, you could add a data.is_homepage
| field and query it in a controller.
|
*/
'renderer' => SimplePageRenderer::class,
/*
|--------------------------------------------------------------------------
| Simple Page Renderer: Default Layout
|--------------------------------------------------------------------------
|
| Only applicable to the SimplePageRenderer.
|
*/
'default_layout' => 'layouts.app',
];
namespace App\Filament\FilamentPageTemplates;
use Beier\FilamentPages\Contracts\FilamentPageTemplate;
use Filament\Forms\Components\Card;
use Filament\Forms\Components\RichEditor;
class MyTemplate implements FilamentPageTemplate
{
public static function title(): string
{
return 'My Template';
}
public static function schema(): array
{
return [
Card::make()
->schema([
RichEditor::make('content')
]),
];
}
}
namespace App\Filament\Resources;
use Beier\FilamentPages\Filament\Resources\FilamentPageResource;
use Filament\Resources\Form;
use Filament\Resources\Table;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\TextInput;
class PageResource extends FilamentPageResource
{
/**
* Recommended: Insert Fields at the beginning of the primary column.
*/
public static function insertBeforePrimaryColumnSchema(): array
{
return [
Toggle::make('is_homepage'),
];
}
/**
* Recommended: Insert Fields at the end of the primary column.
*/
public static function insertAfterPrimaryColumnSchema(): array
{
return [
TextInput::make('author'),
];
}
/**
* Recommended: Insert Fields at the beginning of the secondary column. (sidebar)
*/
public static function insertBeforeSecondaryColumnSchema(): array
{
return [
Toggle::make('is_homepage'),
];
}
/**
* Recommended: Insert Fields at the end of the secondary column. (sidebar)
*/
public static function insertAfterSecondaryColumnSchema(): array
{
return [
SEO::make(),
];
}
/**
* Not Recommended: Override the whole form
*/
/** public static function form(Form $form): Form
{
return $form
->schema([
//
]);
} */
/**
* Not Recommended: Override the whole table
*/
/** public static function table(Table $table): Table
{
return $table
->columns([
//
]);
} */
}
namespace App\Models;
use Beier\FilamentPages\Models\FilamentPage as BeierFilamentPage;
use RalphJSmit\Laravel\SEO\Support\HasSEO;
use RalphJSmit\Laravel\SEO\Support\SEOData;
class FilamentPage extends BeierFilamentPage
{
use HasSEO;
public function getDynamicSEOData(): SEOData
{
return new SEOData(
title: $this->title,
);
}
}
namespace App\Filament\Resources;
use RalphJSmit\Filament\SEO\SEO;
use Beier\FilamentPages\Filament\Resources\FilamentPageResource;
class PageResource extends FilamentPageResource
{
public static function insertAfterSecondaryColumnSchema(): array
{
return [
SEO::make(),
];
}
}