|
| 1 | +# Firefly Filament Blog |
| 2 | +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. |
| 3 | + |
| 4 | +[![Latest Version on Packagist][ico-version]][link-packagist] |
| 5 | +[![Total Downloads][ico-downloads]][link-downloads] |
| 6 | +![Packagist License][ico-license] |
| 7 | +![GitHub forks][ico-forks] |
| 8 | +![GitHub Org's stars][ico-stars] |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +## Features |
| 15 | + |
| 16 | +- **Easy Installation:** Simple and straightforward installation process. |
| 17 | +- **User-Friendly Interface:** Intuitive and user-friendly interface for easy management of blog posts. |
| 18 | +- **SEO Meta Extension:** Enhance your blog's search engine optimization with built-in meta tag customization. |
| 19 | +- **Post Scheduled for Future:** Schedule your blog posts to be published at a future date and time. |
| 20 | +- **Social Media Share Feature:** Allow users to easily share your blog posts on social media platforms. |
| 21 | +- **Comment Feature:** Enable comments on your blog posts to encourage engagement and discussion. |
| 22 | +- **Newsletter Subscription:** Integrate newsletter subscription forms to grow your email list. |
| 23 | +- **New Post Published Notification:** Notify subscribers when a new blog post is published. |
| 24 | +- **Category Search:** Categorize your blog posts for easy navigation and search. |
| 25 | +- **Support**: [Laravel 11](https://laravel.com) and [Filament 3.x](https://filamentphp.com) |
| 26 | + |
| 27 | +### Demo Video |
| 28 | +[](https://www.youtube.com/watch?v=8UkcAicQZUc) |
| 29 | + |
| 30 | +## Installation |
| 31 | +If your project is not already using Filament, you can install it by running the following commands: |
| 32 | +```bash |
| 33 | +composer require filament/filament:"^3.2" -W |
| 34 | +``` |
| 35 | +```bash |
| 36 | +php artisan filament:install --panels |
| 37 | +``` |
| 38 | +Install the Filament Blog Plugin by running the following command: |
| 39 | + ```bash |
| 40 | +composer require firefly/filament-blog |
| 41 | +``` |
| 42 | + |
| 43 | +## Usage |
| 44 | +After composer require, you can start using the Filament Blog Plugin by runing the following command: |
| 45 | + |
| 46 | +```bash |
| 47 | +php artisan filament-blog:install |
| 48 | +``` |
| 49 | +This command will publish `filamentblog.php` config file and `create_blog_tables.php` migration file. |
| 50 | +````php |
| 51 | +<?php |
| 52 | +/** |
| 53 | + * |-------------------------------------------------------------------------- |
| 54 | + * | Set up your blog configuration |
| 55 | + * |-------------------------------------------------------------------------- |
| 56 | + * | |
| 57 | + * | This file is for storing the configuration of your blog. |
| 58 | + * | The route configuration is for setting up the route prefix and middleware. |
| 59 | + * | The user configuration is for setting up the user model and columns. |
| 60 | + * | The seo configuration is for setting up the default meta tags for the blog. |
| 61 | + * | The recaptcha configuration is for setting up the recaptcha for the blog. |
| 62 | + * | |
| 63 | + * / |
| 64 | + */ |
| 65 | + |
| 66 | +return [ |
| 67 | + 'route' => [ |
| 68 | + 'prefix' => 'blogs', |
| 69 | + 'middleware' => ['web'], |
| 70 | + 'login' => [ |
| 71 | + 'name' => 'filament.admin.auth.login', |
| 72 | + ], |
| 73 | + ], |
| 74 | + 'user' => [ |
| 75 | + 'model' => App\Models\User::class, |
| 76 | + 'foreign_key' => 'user_id', |
| 77 | + 'columns' => [ |
| 78 | + 'name' => 'name', |
| 79 | + 'avatar' => 'profile_photo_path', // column name of avatar |
| 80 | + ], |
| 81 | + ], |
| 82 | + 'seo' => [ |
| 83 | + 'meta' => [ |
| 84 | + 'title' => 'Filament Blog', |
| 85 | + 'description' => 'This is filament blog seo meta description', |
| 86 | + 'keywords' => [], |
| 87 | + ], |
| 88 | + ], |
| 89 | + |
| 90 | + 'recaptcha' => [ |
| 91 | + 'enabled' => false, // true or false |
| 92 | + 'site_key' => env('RECAPTCHA_SITE_KEY'), |
| 93 | + 'secret_key' => env('RECAPTCHA_SECRET_KEY'), |
| 94 | + ], |
| 95 | +]; |
| 96 | +```` |
| 97 | +Before running the migration, you can modify the `filamentblog.php` config file to suit your needs. |
| 98 | + |
| 99 | + If you want to publish config, views, components, and migrations individually you can run the following command: |
| 100 | +```bash |
| 101 | +php artisan vendor:publish --provider="Firefly\FilamentBlog\FilamentBlogServiceProvider" --tag=filament-blog-views |
| 102 | +``` |
| 103 | +```bash |
| 104 | +php artisan vendor:publish --provider="Firefly\FilamentBlog\FilamentBlogServiceProvider" --tag=filament-blog-config |
| 105 | +``` |
| 106 | +```bash |
| 107 | +php artisan vendor:publish --provider="Firefly\FilamentBlog\FilamentBlogServiceProvider" --tag=filament-blog-components |
| 108 | +``` |
| 109 | +```bash |
| 110 | +php artisan vendor:publish --provider="Firefly\FilamentBlog\FilamentBlogServiceProvider" --tag=filament-blog-migrations |
| 111 | +``` |
| 112 | + |
| 113 | +## What if you have already a User model? |
| 114 | +- If you already have a User model, you can modify the `filamentblog.php` config file to use your User model. |
| 115 | +- Make sure the name column is the user's `name` column. |
| 116 | +- 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. |
| 117 | +- If you want to change `foreign_key` column name, you can modify the `filamentblog.php` config file. |
| 118 | + |
| 119 | +### Migrate the database |
| 120 | +After modifying the `filamentblog.php` config file, you can run the migration by running the following command: |
| 121 | +```bash |
| 122 | +php artisan migrate |
| 123 | +``` |
| 124 | +### Storage Link |
| 125 | +After running the migration, you can create a symbolic link to the storage directory by running the following command: |
| 126 | +```bash |
| 127 | +php artisan storage:link |
| 128 | +``` |
| 129 | +### Attach filament blog panel to the dashboard |
| 130 | +You can attach the Filament Blog panel to the dashboard by adding the following code to your panel provider: |
| 131 | +Add `Blog::make()` to your panel passing the class to your `plugins()` method. |
| 132 | + |
| 133 | +```php |
| 134 | +use Firefly\FilamentBlog\Blog; |
| 135 | + |
| 136 | +public function panel(Panel $panel): Panel |
| 137 | +{ |
| 138 | + return $panel |
| 139 | + ->plugins([ |
| 140 | + Blog::make() |
| 141 | + ]) |
| 142 | +} |
| 143 | +``` |
| 144 | + |
| 145 | +### Manage user relationship |
| 146 | +If you want to manage the user relationship, you can modify the `User` model to have a relationship with the `Post` model. |
| 147 | +```php |
| 148 | +<?php |
| 149 | + |
| 150 | +namespace App\Models; |
| 151 | + |
| 152 | +// use Illuminate\Contracts\Auth\MustVerifyEmail; |
| 153 | +use Firefly\FilamentBlog\Traits\HasBlog; |
| 154 | +use Illuminate\Foundation\Auth\User as Authenticatable; |
| 155 | + |
| 156 | +class User extends Authenticatable |
| 157 | +{ |
| 158 | + use HasBlog; |
| 159 | +} |
| 160 | +``` |
| 161 | +### Allow user to comment |
| 162 | +If you want to allow users to comment on blog posts, you can modify the `User` model to add a method `canComment()`. |
| 163 | + |
| 164 | +```php |
| 165 | +<?php |
| 166 | + |
| 167 | +namespace App\Models; |
| 168 | + |
| 169 | +// use Illuminate\Contracts\Auth\MustVerifyEmail; |
| 170 | +use Firefly\FilamentBlog\Traits\HasBlog; |
| 171 | +use Illuminate\Foundation\Auth\User as Authenticatable; |
| 172 | + |
| 173 | +class User extends Authenticatable |
| 174 | +{ |
| 175 | + public function canComment(): bool |
| 176 | + { |
| 177 | + // your conditional logic here |
| 178 | + return true; |
| 179 | + } |
| 180 | + |
| 181 | +} |
| 182 | +``` |
| 183 | +Now you can start using the Filament Blog Plugin to manage your blog posts effectively. |
| 184 | +```yourdomain.com/blogs``` |
| 185 | +You can change the route prefix in the `filamentblog.php` config file. |
| 186 | + |
| 187 | +### Social Media Share |
| 188 | +For social media share, please visit [Sharethis](https://platform.sharethis.com) and generate the JS Script and HTML code and save from our share snippet section. |
| 189 | + |
| 190 | +### Recaptcha |
| 191 | +To add the recaptcha to the blog comment form, you can add environment variables in your `.env` file. |
| 192 | +And make sure enabled is set to `true` in the `filamentblog.php` config file. |
| 193 | +``` |
| 194 | +RECAPTCHA_SITE_KEY |
| 195 | +RECAPTCHA_SECRET_KEY |
| 196 | +``` |
| 197 | +## Credits |
| 198 | + |
| 199 | +- [Author Name][link-author] |
| 200 | +- [All Contributors][link-contributors] |
| 201 | + |
| 202 | +### Security |
| 203 | + |
| 204 | +If you discover a security vulnerability within this package, please send an e-mail to [email protected], All security vulnerabilities will be promptly addressed. |
| 205 | + |
| 206 | +### 🤝 Contributing |
| 207 | + |
| 208 | +Please see [CONTRIBUTING](CONTRIBUTING.md) for details. |
| 209 | + |
| 210 | +### 📄 License |
| 211 | + |
| 212 | +The MIT License (MIT). Please see [License File](LICENSE.txt) for more information. |
| 213 | + |
| 214 | + |
| 215 | +<i>Made with love by Firefly IT Solutions, Nepal - [thefireflytech.com](https://thefireflytech.com)</i> |
| 216 | + |
| 217 | + |
| 218 | +[ico-version]: https://img.shields.io/packagist/v/firefly/filament-blog.svg?style=flat-square |
| 219 | +[ico-downloads]: https://img.shields.io/packagist/dt/firefly/filament-blog.svg?style=flat-square |
| 220 | +[ico-stable]: https://img.shields.io/packagist/s/firefly/filament-blog.svg?style=flat-square |
| 221 | +[ico-license]: https://img.shields.io/packagist/l/firefly/filament-blog.svg?style=flat-square |
| 222 | +[ico-forks]: https://img.shields.io/github/forks/thefireflytech/filament-blog.svg?style=flat-square |
| 223 | +[ico-stars]: https://img.shields.io/github/stars/thefireflytech?style=flat-square |
| 224 | + |
| 225 | + |
| 226 | +[link-packagist]: https://packagist.org/packages/firefly/filament-blog |
| 227 | +[link-downloads]: https://packagist.org/packages/firefly/filament-blog |
| 228 | +[link-author]: https://github.com/thefireflytech |
| 229 | +[link-contributors]: ../../contributors |
0 commit comments