GithubHelp home page GithubHelp logo

thefireflytech / filament-blog Goto Github PK

View Code? Open in Web Editor NEW
56.0 4.0 23.0 1.35 MB

Blog plugin for laravel filament

Home Page: https://packagist.org/packages/firefly/filament-blog

License: Other

PHP 74.94% Blade 25.06%
filament filament-plugin filamentadmin laravel laravel-package

filament-blog's Introduction

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

  • Easy Installation: Simple and straightforward 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 easily share your blog posts on social media platforms.
  • 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

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?

  • 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 the filamentblog.php config file in user.columns.avatar key.
  • If you want to change foreign_key column name, you can modify the filamentblog.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 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 [email protected], 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

filament-blog's People

Contributors

asmitnepali avatar demianshtepa avatar sagautam5 avatar thefireflytech avatar tonypartridge avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

filament-blog's Issues

Please don't use generic tables and models in your plugin

Hi there,

i've noticed that you use generic table names and models etc. in your filament plugin.
This means that no other plugins can use these because it would conflict when installing both plugins.

categories
comments
tags
settings

Please consider changing this to blog-categories or something less generic.

Thanks

Column not found: 1054 Unknown column 'users.name' in 'field list'

I'm encountering an error related to the user model fields while using the filament-blog package. In my user model, I've replaced the name field with separate first_name and last_name fields. Despite updating filamentblog.php accordingly, I'm still encountering errors when accessing the post creation page. How can I resolve this issue?

Illuminate
โ€‰\โ€‰
Database
โ€‰\โ€‰
QueryException
PHP 8.2.4
11.3.1
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.name' in 'field list'
SELECT users.name, users.id FROM users ORDER BY users.name ASC

The blog not working with an existing application.

The blog not working with an existing application.

I'm using filament version 3.2. And running the application in localhost

http://127.0.0.1:8000/blogs โ‡’ working fine

http://127.0.0.1:8000/admin/categories โ‡’ Not working getting 404 not found error.

Also, I did not get the menus in the sidebar.

My AdminPanelProvider provider

<?php

namespace App\Providers\Filament;

use Filament\Pages;
use Filament\Panel;
use Filament\Widgets;
use Filament\PanelProvider;
use Firefly\FilamentBlog\Blog;
use Filament\Navigation\MenuItem;
use Filament\Support\Colors\Color;
use App\Filament\Pages\EditProfile;
use Filament\Navigation\NavigationGroup;
use Filament\Http\Middleware\Authenticate;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Session\Middleware\AuthenticateSession;
use Illuminate\View\Middleware\ShareErrorsFromSession;
use Filament\Http\Middleware\DisableBladeIconComponents;
use Filament\Http\Middleware\DispatchServingFilamentEvent;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
use Saade\FilamentFullCalendar\FilamentFullCalendarPlugin;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;

class AdminPanelProvider extends PanelProvider
{




    public function panel(Panel $panel): Panel
    {
        return $panel
            ->default()
            ->databaseNotifications(true)
            ->databaseNotificationsPolling('2s')
            ->id('admin')
            ->path('admin')
            ->login()
            ->font('Poppins')
            ->profile()
            ->userMenuItems([
                'profile' => MenuItem::make()->url(fn (): string => EditProfile::getUrl())
            ])
            ->brandLogo(asset('images/logo.png'))
            ->darkModeBrandLogo(asset('images/logo_white.png'))
            ->favicon(asset('images/fav.png'))
            ->brandLogoHeight('2.5rem')
            ->colors([
                'danger' => Color::Rose,
                'gray' => Color::Gray,
                'info' => Color::Blue,
                'primary' => Color::Indigo,
                'success' => Color::Emerald,
                'warning' => Color::Orange,
            ])
            ->sidebarCollapsibleOnDesktop(true)
            // ->collapsibleNavigationGroups()
            ->navigationGroups([
                NavigationGroup::make('User Managment')
                    ->label('User Managment')
                    ->icon('heroicon-o-users')
                    ->collapsed(true),
                NavigationGroup::make('System Management')
                    ->label('System Management')
                    ->icon('heroicon-o-adjustments-horizontal')
                    ->collapsed(true),
                NavigationGroup::make('All Reports')
                    ->label('All Reports')
                    ->icon('heroicon-o-cursor-arrow-ripple')
                    ->collapsed(true),
                NavigationGroup::make('Utilities')
                    ->label('Utilities')
                    ->icon('heroicon-o-cog')
                    ->collapsed(true),
                NavigationGroup::make('Blog')
                    ->label('Blog')
                    ->icon('heroicon-o-document-minus')
                    ->collapsed(true),

            ])
            ->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
            ->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
            ->pages([
                Pages\Dashboard::class,
            ])
            ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
            ->widgets([
                Widgets\AccountWidget::class,
                // Widgets\FilamentInfoWidget::class,
            ])
            ->plugin(
                FilamentFullCalendarPlugin::make(),
                Blog::make()
            )
            ->middleware([
                EncryptCookies::class,
                AddQueuedCookiesToResponse::class,
                StartSession::class,
                AuthenticateSession::class,
                ShareErrorsFromSession::class,
                VerifyCsrfToken::class,
                SubstituteBindings::class,
                DisableBladeIconComponents::class,
                DispatchServingFilamentEvent::class,
            ])
            ->authMiddleware([
                Authenticate::class,
            ])
            ->viteTheme('resources/css/filament/admin/theme.css');
    }
}

My config file

<?php

use App\Models\User;

/**
 * |--------------------------------------------------------------------------
 * | 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.
 */



return [
    'route' => [
        'prefix' => 'blogs',
        'middleware' => ['web'],
        // 'home' => [
        //     'name' => 'home',
        //     'url' => env('APP_URL'),
        // ],
        'login' => [
            'name' => 'filamentblog.post.login',
        ],
    ],
    'user' => [
        'model' => User::class,
        'foreign_key' => 'user_id',
        'columns' => [
            'name' => 'name',
            'avatar' => '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'),
    ],
];

My User model

<?php

namespace App\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;

use Filament\Panel;
use Spatie\Permission\Traits\HasRoles;
use Illuminate\Notifications\Notifiable;
use Filament\Models\Contracts\FilamentUser;
use Firefly\FilamentBlog\Traits\HasBlog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements FilamentUser
{
    use HasFactory, Notifiable, HasRoles, HasBlog;

    /**
     * The attributes that are mass assignable.
     *
     * @var array<int, string>
     */
    protected $fillable = [
        'name',
        'email',
        'password',
        'manager_id',
        'senior_manager',
        'regional_manager',
        'sales_head',
        'email_verified_at',
        'remember_token',
        'created_at',
        'updated_at',
        'mobile_number',
        'avatar',
        'is_active',
    ];

    /**
     * The attributes that should be hidden for serialization.
     *
     * @var array<int, string>
     */
    protected $hidden = [
        'password',
        'remember_token',
    ];

    /**
     * Get the attributes that should be cast.
     *
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'email_verified_at' => 'datetime',
            'password' => 'hashed',
        ];
    }


    public function canComment(): bool
    {
        // your conditional logic here
        return false;
    }

    public function students()
    {
        return $this->hasMany(Students::class, 'user_id', 'id');
    }

    public function tasks()
    {
        return $this->belongsToMany(Task::class, 'task_user', 'user_id', 'task_id');
    }


    public function canAccessPanel(Panel $panel): bool
    {
        return $this->hasRole(['Admin', 'Accounts', 'BDA', 'Manager', 'Onboard', 'Senior Manager', 'Regional Manager', 'Sales Head', 'CEO', 'Operations Manager','HR','PA','users','Author']) && $this->is_active;
    }
}

Please help me to resolve this issue

Schedule post feature does not work

Hello,

I attempted to use the schedule post feature, but it doesn't seem to be working. I followed the installation steps and tried to schedule the post, but it's not working. Are there any special steps I need to follow?
I can schedule the post but it's not get published when time meets.

Thank you for your time.

How to disable any feature

Hi there,

Thank you for the amazing plugin! We're enjoying it. I was wondering if there's a way to disable the newsletter feature in the plugin. Also, could you let me know if there's a way to enable or disable any other features in the plugin?

Looking forward to your reply.

[IMPROVEMENT] DB tables prefix

Hi,

It would be great to have a prefix for the tables (for example defined in the config), so that all tables would be of the same type:

blog_posts
blog_tags,
etc..

Thanks

is this plguin mintained ?

hey there,

I'm encountering an error while using this plugin with filament for migration. The issue lies in the "->constrained()" method used with "$table->foreignIdFor(Firefly\FilamentBlog\Models\Post::class)". This error occurred in my existing project, where I have already implemented role and permission features.
image

The same issue does not occur in the blank filament project, but I am encountering table-missing and field-missing errors.
image

It would be great if you can help me to resolve the issue.

Here is the minimal reproduction repo:
blog-minimal-reproduction.zip

step to run

  • composer install
  • pnpm install
  • PHP artisan migrate
  • PHP artisan serve
  • pnpm run dev

Now try to add delete or create blog etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.