thefireflytech / filament-blog

Blog plugin for laravel filament
https://packagist.org/packages/firefly/filament-blog
Other
86 stars 36 forks source link
filament filament-plugin filamentadmin laravel laravel-package

Firefly Filament Blog

The Filament Blog Plugin is a feature-rich plugin designed to enhance your blogging experience on your website. It comes with a variety of powerful features to help you manage and customize your blog posts effectively.

Latest Version on Packagist Total Downloads Packagist License GitHub forks GitHub Org's stars

Firefly Filament Blog

Features

Demo Video

IMAGE ALT TEXT HERE

Upgrade Note

Important: If you are upgrading from version 1.x to 2.x, please follow the steps below:

  • Backup your database before running the migration. This is just for safety purposes.
  • Now you can add prefix on blog tables from the config file.
    'tables' => [
    'prefix' => 'fblog_', // prefix for all blog tables
    ],
  • After set 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 composer require, you can start using the Filament Blog Plugin by runing the following command:

php artisan filament-blog:install

This command will publish filamentblog.php config file and create_blog_tables.php migration file.

<?php

/**
 * |--------------------------------------------------------------------------
 * | Set up your blog configuration
 * |--------------------------------------------------------------------------
 * |
 * | The route configuration is for setting up the route prefix and middleware.
 * | The user configuration is for setting up the user model and columns.
 * | The seo configuration is for setting up the default meta tags for the blog.
 * | The recaptcha configuration is for setting up the recaptcha for the blog.
 */

use Firefly\FilamentBlog\Models\User;

return [
    'tables' => [
        '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-config
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 have already a User model?

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 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 user 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 share, please visit Sharethis and generate the JS Script and HTML code and save from our share snippet section.

Recaptcha

To add the recaptcha to the blog comment form, you can add environment variables in your .env file. And make sure enabled is set to true in the filamentblog.php config file.

RECAPTCHA_SITE_KEY
RECAPTCHA_SECRET_KEY

Credits

Security

If you discover a security vulnerability within this package, please send an e-mail to dev@thefireflytech.com, All security vulnerabilities will be promptly addressed.

🤝 Contributing

Please see CONTRIBUTING for details.

📄 License

The MIT License (MIT). Please see License File for more information.

Made with love by Firefly IT Solutions, Nepal - thefireflytech.com