fuelviews / laravel-sabhero-blog
SabHero Blog package
Requires
- php: >=8.2
- ext-zip: *
- diglactic/laravel-breadcrumbs: ^9.0
- embed/embed: ^4.4
- filament/spatie-laravel-media-library-plugin: ^3.2
- filament/support: ^3.2
- fuelviews/laravel-sabhero-wrapper: >=0.0
- spatie/filament-markdown-editor: ^2.0
- spatie/laravel-package-tools: ^1.19
Requires (Dev)
- driftingly/rector-laravel: ^2.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- rector/rector: ^2.0
README
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 SabHero Blog Plugin by running the following command:
composer require fuelviews/sabhero-blog -W
Usage
After composer require, you can start using the SabHero Blog Plugin by running the following command:
php artisan sabhero-blog:install
This command will publish sabhero-blog.php
config file and migration files.
<?php use App\Models\User; return [ 'tables' => [ 'prefix' => 'blog_', ], 'route' => [ 'prefix' => 'blog', 'middleware' => ['web'], ], 'user' => [ 'model' => User::class, 'foreign_key' => 'user_id', 'columns' => [ 'name' => 'name', 'slug' => 'slug', ], ], 'heading_permalink' => [ 'html_class' => 'scroll-mt-40', ], 'dropdown' => [ 'name' => 'Posts', ], 'crm' => [ 'name' => 'CRM', 'link' => '#', ], ];
Before running the migration, you can modify the sabhero-blog.php
config file to suit your needs.
You can publish the config file with:
php artisan vendor:publish --tag="sabhero-blog-config"
Optionally, you can publish the views using
php artisan vendor:publish --tag="sabhero-blog-views"
Migrate the database
After modifying the sabhero-blog.php
config file, you can run the migration by running the following command:
php artisan migrate
Attach SabHero Blog panel to the dashboard
You can attach the SabHero Blog panel to the dashboard by adding the following code to your panel provider:
Add SabHeroBlog::make()
to your panel passing the class to your plugins()
method.
use Fuelviews\SabHeroBlog\SabHeroBlog; public function panel(Panel $panel): Panel { return $panel ->plugins([ SabHeroBlog::make() ]) }
Authorizing access to the panel
By default, all App\Models\Users can access Filament locally. To allow them to access Filament in production, you must take a few extra steps to ensure that only the correct users have access to the app.
<?php namespace App\Models; use Filament\Panel; use Fuelviews\SabHeroBlog\Traits\HasAuthor; use Fuelviews\SabHeroBlog\Traits\HasBlog; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Filament\Models\Contracts\FilamentUser; use Filament\Models\Contracts\HasAvatar; class User extends Authenticatable implements FilamentUser, HasAvatar { use HasFactory, Notifiable, HasBlog, HasAuthor; public function canAccessPanel(Panel $panel): bool { return str_ends_with($this->email, '@your-domain-here.com'); } }
You can publish and run the migrations with:
php artisan vendor:publish --tag="sabhero-blog-migrations"
php artisan migrate
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.