1. Go to this page and download the library: Download xplodman/filamentapproval 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/ */
xplodman / filamentapproval example snippets
// app/Providers/Filament/AdminPanelProvider.php
use Filament\Panel;
use Filament\PanelProvider;
use Xplodman\FilamentApproval\FilamentApprovalPlugin;
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
FilamentApprovalPlugin::make(),
]);
}
}
return [
/*
|--------------------------------------------------------------------------
| User Model
|--------------------------------------------------------------------------
|
| The user model class that will be used for relationships in the
| approval requests. This should match your application's user model.
|
*/
'user_model' => config('auth.providers.users.model', 'App\Models\User'),
/*
|--------------------------------------------------------------------------
| Approval Request Model
|--------------------------------------------------------------------------
|
| The model class that will be used for approval requests.
| You can override this to use a custom model (e.g., MongoDB model).
|
*/
'approval_request_model' => \Xplodman\FilamentApproval\Models\ApprovalRequest::class,
/*
|--------------------------------------------------------------------------
| Navigation Group
|--------------------------------------------------------------------------
|
| The navigation group where the approval requests resource will appear
| in the Filament admin panel.
|
*/
'navigation_group' => 'Management',
/*
|--------------------------------------------------------------------------
| Navigation Icon
|--------------------------------------------------------------------------
|
| The icon that will be displayed next to the approval requests resource
| in the Filament admin panel navigation.
|
*/
'navigation_icon' => 'heroicon-o-clipboard-document-check',
/*
|--------------------------------------------------------------------------
| Auto Register Resource
|--------------------------------------------------------------------------
|
| Whether to automatically register the ApprovalRequestResource with
| Filament panels. Set to true if you want automatic registration.
| For most cases, you should manually register it in your panel.
|
*/
'auto_register_resource' => false,
/*
|--------------------------------------------------------------------------
| Debug Mode
|--------------------------------------------------------------------------
|
| Enable debug mode to show detailed debug information in the diff view.
| This
namespace App\Filament\Resources\PostResource\Pages;
use App\Filament\Resources\PostResource;
use Filament\Resources\Pages\CreateRecord;
use Xplodman\FilamentApproval\Concerns\InterceptsCreateForApproval;
class CreatePost extends CreateRecord
{
use InterceptsCreateForApproval;
protected static string $resource = PostResource::class;
}
namespace App\Filament\Resources\PostResource\Pages;
use App\Filament\Resources\PostResource;
use Filament\Resources\Pages\EditRecord;
use Xplodman\FilamentApproval\Concerns\InterceptsEditForApproval;
class EditPost extends EditRecord
{
use InterceptsEditForApproval;
protected static string $resource = PostResource::class;
}
namespace App\Filament\Resources;
use App\Filament\Resources\PostResource\Pages\CreatePost;
use App\Filament\Resources\PostResource\Pages\EditPost;
use App\Filament\Resources\PostResource\Pages\ListPosts;
use Filament\Resources\Resource;
use Xplodman\FilamentApproval\Enums\RelationTypeEnum;
class PostResource extends Resource
{
protected static ?string $model = Post::class;
public static function getPages(): array
{
return [
'index' => ListPosts::route('/'),
'create' => CreatePost::route('/create'),
'edit' => EditPost::route('/{record}/edit'),
];
}
/**
* Define approval relations for relationship handling
* This method is
// In your panel provider or service provider
use Xplodman\FilamentApproval\Resources\ApprovalRequestResource;
$panel->resources([
ApprovalRequestResource::class,
// ... your other resources
]);