Skip to content

Commit

Permalink
feat: support filament v3
Browse files Browse the repository at this point in the history
  • Loading branch information
daurensky committed Feb 12, 2024
1 parent a25c0c8 commit 7a85cca
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 36 deletions.
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,21 @@ php artisan vendor:publish --tag="admin-kit-documents-views"
## Usage

```php
$documents = new AdminKit\Documents();
echo $documents->echoPhrase('Hello, AdminKit!');
class AdminPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path('admin')
...
->plugins([
...
\AdminKit\Documents\FilamentPlugin::make(),
]);
}
}
```

## Testing
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
],
"require": {
"php": "^8.1",
"filament/filament": "^2.0",
"filament/spatie-laravel-translatable-plugin": "^2.0",
"ibecsystems/admin-kit-core": "^2.0",
"filament/filament": "^3.0-stable",
"filament/spatie-laravel-translatable-plugin": "^3.2",
"ibecsystems/admin-kit-core": "^3.1",
"illuminate/contracts": "^10.0",
"spatie/laravel-package-tools": "^1.14.0",
"spatie/laravel-data": "^3.2",
"spatie/laravel-json-api-paginate": "^1.13",
"spatie/laravel-query-builder": "^5.2",
"spatie/laravel-query-builder": "^5.7",
"spatie/laravel-translatable": "^6.5"
},
"require-dev": {
Expand Down
2 changes: 0 additions & 2 deletions src/DocumentsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace AdminKit\Documents;

use AdminKit\Documents\Commands\DocumentsCommand;
use AdminKit\Documents\Providers\FilamentServiceProvider;
use AdminKit\Documents\Providers\RouteServiceProvider;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
Expand All @@ -28,7 +27,6 @@ public function configurePackage(Package $package): void

public function registeringPackage()
{
$this->app->register(FilamentServiceProvider::class);
$this->app->register(RouteServiceProvider::class);
}
}
31 changes: 31 additions & 0 deletions src/FilamentPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace AdminKit\Documents;

use Filament\Panel;
use Filament\Contracts\Plugin;
use AdminKit\Documents\UI\Filament\Resources\DocumentResource;

class FilamentPlugin implements Plugin
{
public function getId(): string
{
return 'filament-plugin-admin-kit-documents';
}

public function register(Panel $panel): void
{
$panel->resources([
DocumentResource::class,
]);
}

public function boot(Panel $panel): void
{
}

public static function make(): static
{
return app(static::class);
}
}
17 changes: 0 additions & 17 deletions src/Providers/FilamentServiceProvider.php

This file was deleted.

8 changes: 3 additions & 5 deletions src/UI/Filament/Resources/DocumentResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
use AdminKit\Documents\UI\Filament\Resources\DocumentResource\Pages;
use Filament\Forms;
use Filament\Resources\Concerns\Translatable;
use Filament\Resources\Form;
use Filament\Resources\Resource;
use Filament\Resources\Table;
use Filament\Tables;

class DocumentResource extends Resource
Expand All @@ -17,9 +15,9 @@ class DocumentResource extends Resource

protected static ?string $model = Document::class;

protected static ?string $navigationIcon = 'heroicon-o-x';
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';

public static function form(Form $form): Form
public static function form(Forms\Form $form): Forms\Form
{
return $form
->schema([
Expand All @@ -30,7 +28,7 @@ public static function form(Form $form): Form
->columns(1);
}

public static function table(Table $table): Table
public static function table(Tables\Table $table): Tables\Table
{
return $table
->columns([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace AdminKit\Documents\UI\Filament\Resources\DocumentResource\Pages;

use AdminKit\Documents\UI\Filament\Resources\DocumentResource;
use Filament\Pages\Actions;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;

class CreateDocument extends CreateRecord
Expand All @@ -12,7 +12,7 @@ class CreateDocument extends CreateRecord

protected static string $resource = DocumentResource::class;

protected function getActions(): array
protected function getHeaderActions(): array
{
return [
Actions\LocaleSwitcher::make(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace AdminKit\Documents\UI\Filament\Resources\DocumentResource\Pages;

use AdminKit\Documents\UI\Filament\Resources\DocumentResource;
use Filament\Pages\Actions;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;

class EditDocument extends EditRecord
Expand All @@ -12,7 +12,7 @@ class EditDocument extends EditRecord

protected static string $resource = DocumentResource::class;

protected function getActions(): array
protected function getHeaderActions(): array
{
return [
Actions\LocaleSwitcher::make(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace AdminKit\Documents\UI\Filament\Resources\DocumentResource\Pages;

use AdminKit\Documents\UI\Filament\Resources\DocumentResource;
use Filament\Pages\Actions;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class ListDocument extends ListRecords
Expand All @@ -12,7 +12,7 @@ class ListDocument extends ListRecords

protected static string $resource = DocumentResource::class;

protected function getActions(): array
protected function getHeaderActions(): array
{
return [
Actions\LocaleSwitcher::make(),
Expand Down

0 comments on commit 7a85cca

Please sign in to comment.