The Filament Blog Plugin is a feature-rich plugin designed to enhance your blogging experience on your website. It has various powerful features to help you manage and customize your blog posts effectively.
Table of Contents
Features
- Easy Installation: Simple installation process.
- User-Friendly Interface: Intuitive and user-friendly interface for easy management of blog posts.
- SEO Meta Extension: Enhance your blog’s search engine optimization with built-in meta tag customization.
- Post Scheduled for Future: Schedule your blog posts to be published at a future date and time.
- Social Media Share Feature: Allow users to share their blog posts on social media platforms easily.
- Comment Feature: Enable comments on your blog posts to encourage engagement and discussion.
- Newsletter Subscription: Integrate newsletter subscription forms to grow your email list.
- New Post Published Notification: Notify subscribers when a new blog post is published.
- Category Search: Categorize your blog posts for easy navigation and search.
- Support: Laravel 11 and Filament 3.x.
Upgrade Note
Note: If you are upgrading from version 1.x to 2.x, please follow the following steps:
- Backup your database before running the migration. This is done to play safely while upgrading any system.
- Now you can add prefixes on blog tables from the config file.
'tables' => [
'prefix' => 'fblog_', // prefix for all blog tables
],
After setting the prefix please run the migration by running the following command:
php artisan filament-blog:upgrade-tables
Installation
If your project is not already using Filament, you can install it by running the following commands:
composer require filament/filament:"^3.2" -W
php artisan filament:install --panels
Install the Filament Blog Plugin by running the following command:
composer require firefly/filament-blog
Usage
After the composer is required, you can start using the Filament Blog Plugin by running the following command:
php artisan filament-blog:install
This command will publish filamentblog.php
config file and create_blog_tables.php
migration file.
[
'prefix' => 'fblog_', // prefix for all blog tables
],
'route' => [
'prefix' => 'blogs',
'middleware' => ['web'],
// 'home' => [
// 'name' => 'filamentblog.home',
// 'url' => env('APP_URL'),
// ],
'login' => [
'name' => 'filamentblog.post.login',
],
],
'user' => [
'model' => User::class,
'foreign_key' => 'user_id',
'columns' => [
'name' => 'name',
'avatar' => 'profile_photo_path', // column name for avatar
],
],
'seo' => [
'meta' => [
'title' => 'Filament Blog',
'description' => 'This is filament blog seo meta description',
'keywords' => [],
],
],
'recaptcha' => [
'enabled' => false, // true or false
'site_key' => env('RECAPTCHA_SITE_KEY'),
'secret_key' => env('RECAPTCHA_SECRET_KEY'),
],
];
If you have a different URL for the home page, you can set it in the home
key in the route
configuration. Before running the migration, you can modify the filamentblog.php
config file to suit your needs.
If you want to publish config, views, components, and migrations individually you can run the following command:
php artisan vendor:publish --provider="Firefly\FilamentBlog\FilamentBlogServiceProvider" --tag=filament-blog-views
php artisan vendor:publish --provider="Firefly\FilamentBlog\FilamentBlogServiceProvider" --tag=filament-blog-views
php artisan vendor:publish --provider="Firefly\FilamentBlog\FilamentBlogServiceProvider" --tag=filament-blog-components
php artisan vendor:publish --provider="Firefly\FilamentBlog\FilamentBlogServiceProvider" --tag=filament-blog-migrations
What if You Already Have a User Model?
- If you already have a User model, you can modify the
filamentblog.php
config file to use your User model. - Make sure the name column is the user’s
name
column. - If you have already
avatar
column in your User model, you can set it in thefilamentblog.php
config file inuser.columns.avatar
key. - If you want to change
foreign_key
column name, you can modify thefilamentblog.php
config file.
Migrate the Database
After modifying the filamentblog.php
config file, you can run the migration by running the following command:
php artisan migrate
Storage Link
After running the migration, you can create a symbolic link to the storage directory by running the following command:
php artisan storage:link
Attach the Filament Blog Panel to the Dashboard
You can attach the Filament Blog panel to the dashboard by adding the following code to your panel provider: Add Blog::make()
to your panel passing the class to your plugins()
method.
use Firefly\FilamentBlog\Blog;
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
Blog::make()
])
}
Manage User Relationship
If you want to manage the user relationship, you can modify the User
model to have a relationship with the Post
model.
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Firefly\FilamentBlog\Traits\HasBlog;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use HasBlog;
}
Allow Users to Comment
If you want to allow users to comment on blog posts, you can modify the User
model to add a method canComment()
.
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Firefly\FilamentBlog\Traits\HasBlog;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
public function canComment(): bool
{
// your conditional logic here
return true;
}
}
Now you can start using the Filament Blog Plugin to manage your blog posts effectively. yourdomain.com/blogs
You can change the route prefix in the filamentblog.php
config file.
Social Media Share
For social media sharing, please visit Sharethis and generate the JS Script and HTML code, and save them from our share snippet section.
Recaptcha
To add the ReCaptcha to the blog comment form, you can add environment variables to your .env
file. And make sure enabled is set to true
in the filamentblog.php
config file.
RECAPTCHA_SITE_KEY
RECAPTCHA_SECRET_KEY
Filament Blog Demo Video
Stay tuned with Laravel Projects for more such amazing posts. You can also explore our Laravel Tutorials and Laravel Projects sections to get more interesting insights.