PHP code example of fuelviews / laravel-sabhero-blog

1. Go to this page and download the library: Download fuelviews/laravel-sabhero-blog library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fuelviews / laravel-sabhero-blog example snippets


use Fuelviews\SabHeroArticle\Facades\SabHeroArticle;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            SabHeroArticle::make()
        ]);
}

use Filament\Models\Contracts\FilamentUser;
use Filament\Panel;
use Fuelviews\SabHeroArticle\Traits\HasArticle;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable implements FilamentUser
{
    use HasFactory, Notifiable, HasArticle;
    
    protected $fillable = [
        'name',
        'email',
        'password',
        'slug',
        'bio',
        'links',
        'is_author',
    ];
    
    protected $casts = [
        'email_verified_at' => 'datetime',
        'password' => 'hashed',
        'links' => 'array',
        'is_author' => 'boolean',
    ];
    
    public function canAccessPanel(Panel $panel): bool
    {
        $allowedDomains = config('sabhero-article.user.allowed_domains', []);

        foreach ($allowedDomains as $domain) {
            if (str_ends_with($this->email, $domain)) {
                return true;
            }
        }

        return false;
    }
}
bash
php artisan make:filament-user
bash
php artisan vendor:publish --tag="sabhero-article-config"
bash
php artisan vendor:publish --tag="sabhero-article-migrations"
bash
php artisan migrate