# What is Filament
The Filament Panel Builder pre-installs the Form Builder, Table Builder, Notifications, Actions, Infolists, and Widgets packages
# Install Laravel
composer global require laravel/installer
laravel new {folder-or-application-name}
- or -
composer create-project laravel/laravel {folder-or-application-name}
# Install Filament Package
composer require filament/filament:"^3.3-stable" -W
php artisan filament:install --panels
# Create a user
php artisan make:filament-user
# Optimizing
php artisan filament:optimize
php artisan filament:optimize-clear
php artisan optimize
# Publishable configuration
php artisan vendor:publish --tag=filament-config
php artisan vendor:publish --tag=filament-panels-translations
php artisan vendor:publish --tag=filament-actions-translations
php artisan vendor:publish --tag=filament-forms-translations
php artisan vendor:publish --tag=filament-notifications-translations
php artisan vendor:publish --tag=filament-tables-translations
php artisan vendor:publish --tag=filament-translations
# Panel Builder
Panels are a container for pages, resources, forms, tables, notifications, actions, info lists, and widgets.
## Make models
php artisan make:model Owner -m
php artisan make:model Patient -m
php artisan make:model Treatment -m
// create_owners_table
Schema::create('owners', function (Blueprint $table) {
$table->id();
$table->string('email');
$table->string('name');
$table->string('phone');
$table->timestamps();
});
// create_patients_table
Schema::create('patients', function (Blueprint $table) {
$table->id();
$table->date('date_of_birth');
$table->string('name');
$table->foreignId('owner_id')->constrained('owners')->cascadeOnDelete();
$table->string('type');
$table->timestamps();
});
// create_treatments_table
Schema::create('treatments', function (Blueprint $table) {
$table->id();
$table->string('description');
$table->text('notes')->nullable();
$table->foreignId('patient_id')->constrained('patients')->cascadeOnDelete();
$table->unsignedInteger('price')->nullable();
$table->timestamps();
});
# Run migration
run php artisan migrate --seed
# Deploying to production
Implement the FilamentUser
in App\Models\User.php
<?php
namespace App\Models;
use Filament\Models\Contracts\FilamentUser;
use Filament\Panel;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable implements FilamentUser
{
// ...
public function canAccessPanel(Panel $panel): bool
{
return str_ends_with($this->email, '@yourdomain.com') && $this->hasVerifiedEmail();
}
}
# Create User Resource (CRUD)
php artisan make:filament-resource User
# Plugins
## Laravel Modules
composer require coolsam/modules
Add merge-plugin
configuration on composer.json
file
"extra": {
"laravel": {
"dont-discover": []
},
"merge-plugin": {
"include": [
"Modules/*/composer.json" # <-- add merge plugin
]
}
},
Then, run composer dump-autoload
to discover new packages.
Now, you can create new module
php artisan module:make Blog
php artisan module:filament:install Blog
Register plugin in App\Providers\Filament\AdminPanelProvider.php
use Coolsam\Modules\ModulesPlugin; # <-- add plugin
public function panel(Panel $panel): Panel
{
return $panel
...
->plugin(ModulesPlugin::make()); # <-- register plugin
}
Artisan commands for filament modules:
php artisan module:make:filament-resource
php artisan module:make:filament-page
php artisan module:make:filament-widget
php artisan module:make:filament-cluster
php artisan module:make:filament-plugin
php artisan module:make:filament-theme
Standard | Make | Filament |
---|---|---|
module:composer-update | module:make | module:make:filament-cluster |
module:delete | module:make-action | module:make:filament-page |
module:disable | module:make-cast | module:make:filament-plugin |
module:dump | module:make-channel | module:make:filament-resource |
module:enable | module:make-class | module:make:filament-theme |
module:filament:install | module:make-command | module:make:filament-widget |
module:install | module:make-component | |
module:lang | module:make-component-view | |
module:list | module:make-controller | |
module:migrate | module:make-enum | |
module:migrate-fresh | module:make-event | |
module:migrate-refresh | module:make-event-provider | |
module:migrate-reset | module:make-exception | |
module:migrate-rollback | module:make-factory | |
module:migrate-status | module:make-helper | |
module:model-show | module:make-interface | |
module:prune | module:make-job | |
module:publish | module:make-listener | |
module:publish-config | module:make-mail | |
module:publish-migration | module:make-middleware | |
module:publish-translation | module:make-migration | |
module:route-provider | module:make-model | |
module:seed | module:make-notification | |
module:setup | module:make-observer | |
module:unuse | module:make-policy | |
module:update | module:make-provider | |
module:update-phpunit-coverage | module:make-repository | |
module:use | module:make-request | |
module:v6:migrate | module:make-resource | |
module:make-rule | ||
module:make-scope | ||
module:make-seed | ||
module:make-service | ||
module:make-test | ||
module:make-trait | ||
module:make-view |
Top comments (0)