PHP code example of afea / filament-redirect

1. Go to this page and download the library: Download afea/filament-redirect 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/ */

    

afea / filament-redirect example snippets


->plugin(\Afea\Cms\Redirect\Filament\RedirectPlugin::make())

$middleware->web(append: [
    \Afea\Cms\Redirect\Http\Middleware\HandleRedirects::class,
]);

use Afea\Cms\Redirect\Models\Redirect;

Redirect::query()->insert([
    ['source_url' => '/eski-blog', 'target_url' => '/blog', 'status_code' => 301, 'is_active' => true, 'hit_count' => 0, 'created_at' => now(), 'updated_at' => now()],
]);

class Redirect extends \Afea\Cms\Redirect\Models\Redirect
{
    public function scopeStale(Builder $q): Builder
    {
        return $q->where('last_used_at', '<', now()->subMonths(6));
    }
}

'models' => ['redirect' => \App\Models\Redirect::class],