remihin / filament-prefab
prefab for a filament website
1.0.2
2024-10-24 13:27 UTC
Requires
- php: ^8.2
- ext-json: *
- illuminate/filesystem: ^11.0
- illuminate/support: ^11.0
- illuminate/validation: ^11.0
Requires (Dev)
- deployer/deployer: v7.0.0-rc.8
- friendsofphp/php-cs-fixer: ^3.8
- dev-main
- 1.0.2
- 1.0.1
- 1.0.0
- dev-feature/MOTIVO-13-add-motivo-users-command
- dev-feature/MOTIVO-10-fix-WCAG-compliance
- dev-translations
- dev-feature/MOTIVO-14-location-searchable
- dev-feature/MOTIVO-12-admin-status-users-beheren
- dev-MOTIVO-11-passwor-reset-action-admin-panel
- dev-feature/locations
- dev-feature/routing
- dev-update-main
- dev-feature/users
- dev-feature/Maillog
- dev-feature/vacancy
- dev-feature/forms
- dev-feature/block-module
- dev-feature/contact
- dev-feature/configure-modules
- dev-feature/menu
- dev-feature/cookie-consent
- dev-feature/searching
This package is auto-updated.
Last update: 2024-10-29 09:38:01 UTC
README
Use this template to scaffold a new website
Installation
- Create a new project
laravel new project-name
- clone this repository
- update the
composer.json
of your new project and change minimum stability to dev:"minimum-stability": "dev",
composer require remihin/filament-prefab
- Install all modules:
php artisan prefab:filament --module=base --force
- be patient with the shell script, force is required to overwrite the user model
php artisan prefab:filament --module=blog
php artisan prefab:filament --module=news
php artisan prefab:filament --module=story
php artisan prefab:filament --module=employee
php artisan prefab:filament --module=form-builder
php artisan prefab:filament --module=service
php artisan prefab:filament --module=location
php artisan prefab:filament --module=vacancy
php artisan prefab:filament --module=job-alert
- NOTE: When updating modules after their initial rollout add
--force
to override local files. Additionally--no-shell
can be added to prevent shell commands from being executed to speed up rolling out updates.
composer dump
php artisan migrate
- Create a user
php artisan make:filament-user
and follow the prompts php artisan db:seed
- open
docker-compose.yml
and replace the container_name with a name of this project docker compose up -d
npm install && npm run dev
How to use search
- Add the
IsSearchable
interface to the model - Implement the required methods. Your IDE will inform you when adding the interface.
- Add the
use Searchable
trait to the model - Add the config to
searchable.php
config by adding it to themodels
array where the key is the model and the value is an array with the searchable columns - Modules can also be specified in the
modules
section insearchable.php
. Here the key is the relation name and the value an array of searchable fields. To search a module on a model add the name of the resource to the model array like you would add a column - In the example below the page searches in the columns
name
andcontent
, as well as the moduleheroImage
, for which the columnstitle
andcontent
are searchable
'models' => [ Page::class => [ 'name', 'content', 'heroImage', ], ], 'modules' => [ 'heroImage' => [ 'title', 'content', ], ],
Elasticsearch
The search module makes use of elasticsearch, please make sure SCOUT_DRIVER
is set to elastic
in your .env
To sync models to elastic run php artisan search:sync
.
This project also contains a docker file which can be executed using laravel sail. The default port for elastic in this docker file is 9298. To allow your local project to communicate with this docker file add ELASTIC_HOST=localhost:9298
to your .env
How to use Hero Images
- add the
use Heroable
trait to the model - add
static::$model::heroableFields(),
to the form fields in the resource
How to use Employees
- add the
use Employeeable
trait to the model - add
static::$model::employeeableFields(),
to the form fields in the resource
How to use Seoable en Ogable
- add the
use Seoable
trait to the model - add
static::$model::seoFields(),
to the form fields in the resource
How to use Labels
- add the
use Labelable
trait to the model - add
static::$model::labelableFields(),
to the form fields in the resource
How to use menus
- Implement
App/Contracts/Menuable
on models that should be able to be linked in menus. - Implement required methods
- Available resources will be auto detected by the menu item resource
How to use icon picker
- create a folder in
/resources/images/svg
(if this folder is empty it will not be committed, so add atleast 1 icon) - Place all the SVGs voor de icons you want in this folder (make sure the name of the file is prefixed with
icon-
) - add the IconPicker to a resource (with preload):
IconPicker::make('icon') ->preload()
- in the blade use
<x-icon :name="$model->icon" />
to get the icon
How to use titles and slugs
- For titles and slugs we use a forked and self-hosted project filament-title-with-slug
- On forms use the
TitleWithSlugInput
form component. This will handle both the title and the slug. Both fields are required and the slug field validates if it is unique. - For more documentation checkout the motivo repository
How to use blocks module
- Simple add
BlockModule::make('content')
to any resource, where the param is the name of the column which stores the data. - Add
'content' => 'array'
to the casts of the model - New blocks can be created by making a new class in the
App/Filament/Plugins/Blocks
directory and extending theBaseBlock
model - New blocks can be registered in the
active
array in theblocks.php
config file - There is also a toggle content field, which can have nested fields. These are registed in the
toggle_content
array in theblocks.php
config - You can also create your own set of blocks.
- First create a new array in the
blocks.php
config file. The key of this array is not restricted. - When adding the block module to the resource you can specify a second parameter, which is the key of the array from the previous step, for example
BlockModule::make('content', 'form-builder')
- First create a new array in the
How to use form module
- The form module is build on top of the blocks module
- Adding a new form can be done by creating a new form block, extending the
FormBlock
class - Blocks can be registered in the
form
array in theblocks.php
config file.
Front-end
- visit
/blog
for a blog overview - visit
/blog/{blog:slug}
for the show page of a blog
Settings
- For settings we use the spatie plugin.
- Optional: add the filament page to the correct navigation group
protected static ?string $navigationGroup = 'settings';
- Add the settings to view composer in
AppServiceProvider
to access variables in blade
Biggest Todos:
- Update naar Laravel 11
- slugs
- redo SEO as field instead of trait (?)
- Cookie consent
Base module
- Something formbuilder-like (alternative methods?) (https://filamentphp.com/plugins/lara-zeus-bolt)?
Contact module
- Blocks module (WIP)
Blocks module
- Email sending (?)
Job Alert
- Search functionalities
Search Module
- Donation module
- Redirects en dead-link tracker
- Add route for home
- Translations
"Copypaste" Todos:
- Employee
- Location
- News
- Service
- Story
- Vacancy
- Settings
- Toptasks
dependencies:
filamentphp/filament
awcodes/filament-curator
(media manager)solution-forest/filament-tree
(menu builder)