Skip to content

Commit

Permalink
3.x rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
bezhanSalleh committed Jan 24, 2024
1 parent 6e35d6c commit 97f97ee
Show file tree
Hide file tree
Showing 23 changed files with 606 additions and 188 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ php artisan exceptions:install
```

3. Register the plugin for the Filament Panel

```php
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
\BezhanSalleh\FilamentExceptions\FilamentExceptionsPlugin::make()
\BezhanSalleh\FilamentExceptions\ExceptionPlugin::make()
]);
}
```
Expand All @@ -58,7 +59,7 @@ public function panel(Panel $panel): Panel

namespace App\Exceptions;

use BezhanSalleh\FilamentExceptions\FilamentExceptions;
use BezhanSalleh\FilamentExceptions\ExceptionManager;

class Handler extends ExceptionHandler
{
Expand All @@ -68,7 +69,7 @@ class Handler extends ExceptionHandler
{
$this->reportable(function (Throwable $e) {
if ($this->shouldReport($e)) {
FilamentExceptions::report($e);
ExceptionManager::report($e);
}
});

Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@
],
"require": {
"php": "^8.1|^8.2",
"filament/filament": "^3.0",
"filament/filament": "^3.2",
"spatie/laravel-package-tools": "^1.9",
"spatie/laravel-ignition": "^2.0"
},
"require-dev": {
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.0",
"nunomaduro/larastan": "^2.0",
"larastan/larastan": "^2.0",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.9",
"phpunit/phpunit": "^10.0",
"spatie/laravel-ray": "^1.26"
},
"autoload": {
"psr-4": {
"BezhanSalleh\\FilamentExceptions\\": "src",
"BezhanSalleh\\FilamentExceptions\\Database\\Factories\\": "database/factories"
"BezhanSalleh\\ExceptionPlugin\\": "src",
"BezhanSalleh\\ExceptionPlugin\\Database\\Factories\\": "database/factories"
}
},
"autoload-dev": {
"psr-4": {
"BezhanSalleh\\FilamentExceptions\\Tests\\": "tests"
"BezhanSalleh\\Filament\\Tests\\": "tests"
}
},
"scripts": {
Expand All @@ -57,10 +57,10 @@
"extra": {
"laravel": {
"providers": [
"BezhanSalleh\\FilamentExceptions\\FilamentExceptionsServiceProvider"
"BezhanSalleh\\ExceptionPlugin\\ExceptionPluginServiceProvider"
],
"aliases": {
"FilamentExceptions": "BezhanSalleh\\FilamentExceptions\\Facades\\FilamentExceptions"
"FilamentExceptions": "BezhanSalleh\\ExceptionPlugin\\Facades\\FilamentExceptions"
}
}
},
Expand Down
52 changes: 0 additions & 52 deletions config/filament-exceptions.php

This file was deleted.

4 changes: 2 additions & 2 deletions src/Commands/MakeExceptionsInstallCommand.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace BezhanSalleh\FilamentExceptions\Commands;
namespace BezhanSalleh\ExceptionPlugin\Commands;

use Illuminate\Console\Command;

Expand Down Expand Up @@ -28,7 +28,7 @@ public function handle(): int
$this->comment('following snippet into your App\'s Exception Handlers\'s reportable method.');
$this->newLine();
$this->info(' if ($this->shouldReport($e)) {
FilamentExceptions::report($e);
ExceptionManager::report($e);
}');

return self::SUCCESS;
Expand Down
64 changes: 64 additions & 0 deletions src/Concerns/HasLabels.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

declare(strict_types=1);

namespace BezhanSalleh\FilamentExceptions\Concerns;

trait HasLabels
{
protected bool $isGloballySearchable = true;

protected ?string $modelLabel = null;

protected ?string $pluralModelLabel = null;

protected bool $hasTitleCaseModelLabel = true;

public function modelLabel(string $label): static
{
$this->modelLabel = $label;

return $this;
}

public function pluralModelLabel(string $label): static
{
$this->pluralModelLabel = $label;

return $this;
}

public function titleCaseModelLabel(bool $condition = true): static
{
$this->hasTitleCaseModelLabel = $condition;

return $this;
}

public function getModelLabel(): string
{
return $this->modelLabel ?? __('filament-exceptions::filament-exceptions.labels.model');
}

public function getPluralModelLabel(): string
{
return $this->pluralModelLabel ?? __('filament-exceptions::filament-exceptions.labels.model_plural');
}

public function hasTitleCaseModelLabel(): bool
{
return $this->hasTitleCaseModelLabel;
}

public function globallySearchable(bool $condition = true): static
{
$this->isGloballySearchable = $condition;

return $this;
}

public function canGloballySearch(): bool
{
return $this->isGloballySearchable;
}
}
24 changes: 24 additions & 0 deletions src/Concerns/HasModelPruneInterval.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace BezhanSalleh\FilamentExceptions\Concerns;

use Carbon\Carbon;

trait HasModelPruneInterval
{
protected ?Carbon $modelPruneInterval = null;

public function modelPruneInterval(Carbon $interval): static
{
$this->modelPruneInterval = $interval;

return $this;
}

public function getModelPruneInterval(): Carbon
{
return $this->modelPruneInterval ?? now()->subWeek();
}
}
150 changes: 150 additions & 0 deletions src/Concerns/HasNavigation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<?php

declare(strict_types=1);

namespace BezhanSalleh\FilamentExceptions\Concerns;

use Filament\Pages\SubNavigationPosition;

trait HasNavigation
{
protected bool $shouldEnableNavigationBadge = false;

protected string | array | null $navigationBadgeColor = null;

protected ?string $navigationGroup = null;

protected ?string $navigationParentItem = null;

protected ?string $navigationIcon = null;

protected ?string $activeNavigationIcon = null;

protected ?string $navigationLabel = null;

protected ?int $navigationSort = null;

protected ?string $slug = null;

protected bool $shouldRegisterNavigation = true;

protected SubNavigationPosition $subNavigationPosition = SubNavigationPosition::Start;

public function getSubNavigationPosition(): SubNavigationPosition
{
return $this->subNavigationPosition;
}

public function navigationBadge(bool $condition = true): static
{
$this->shouldEnableNavigationBadge = $condition;

return $this;
}

public function shouldEnableNavigationBadge(): bool
{
return $this->shouldEnableNavigationBadge;
}

public function navigationBadgeColor(string | array $color): static
{
$this->navigationBadgeColor = $color;

return $this;
}

public function getNavigationBadgeColor(): string | array | null
{
return $this->navigationBadgeColor;
}

public function navigationGroup(?string $group): static
{
$this->navigationGroup = $group;

return $this;
}

public function getNavigationGroup(): ?string
{
return $this->navigationGroup ?? __('filament-exceptions::filament-exceptions.labels.navigation_group');
}

public function getNavigationParentItem(): ?string
{
return $this->navigationParentItem;
}

public function navigationParentItem(?string $item): static
{
$this->navigationParentItem = $item;

return $this;
}

public function getNavigationIcon(): ?string
{
return $this->navigationIcon ?? 'heroicon-o-bug-ant';
}

public function navigationIcon(?string $icon): static
{
$this->navigationIcon = $icon;

return $this;
}

public function activeNavigationIcon(?string $icon): static
{
$this->activeNavigationIcon = $icon;

return $this;
}

public function getActiveNavigationIcon(): ?string
{
return $this->activeNavigationIcon ?? 'heroicon-o-bug-ant';
}

public function navigationLabel(?string $label): static
{
$this->navigationLabel = $label;

return $this;
}

public function getNavigationLabel(): ?string
{
return $this->navigationLabel ?? __('filament-exceptions::filament-exceptions.labels.navigation');
}

public function navigationSort(?int $sort): static
{
$this->navigationSort = $sort;

return $this;
}

public function getNavigationSort(): ?int
{
return $this->navigationSort;
}

public function shouldRegisterNavigation(): bool
{
return $this->shouldRegisterNavigation;
}

public function slug(string $slug): static
{
$this->slug = $slug;

return $this;
}

public function getSlug(): ?string
{
return $this->slug;
}
}
Loading

0 comments on commit 97f97ee

Please sign in to comment.