### Install Filament Exceptions Package Source: https://github.com/bezhansalleh/filament-exceptions/blob/main/README.md Install the package using Composer. ```bash composer require bezhansalleh/filament-exceptions ``` -------------------------------- ### Example Translation File Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt An example of the structure for the English translation file after publishing. Customize labels, columns, and other strings as needed. ```php // resources/lang/en/filament-exceptions.php (after publishing) return [ 'labels' => [ 'navigation' => 'Exceptions', 'navigation_group' => 'Exception', 'model' => 'Exception', 'model_plural' => 'Exceptions', ], 'columns' => [ 'method' => 'Method', 'path' => 'Path', 'type' => 'Type', 'code' => 'Code', 'ip' => 'IP Address', 'occurred_at' => 'Occurred At', ], ]; ``` -------------------------------- ### Install Filament Exceptions Plugin Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Install the package via Composer and run the artisan command to publish and run the migration for the exceptions table. ```bash composer require bezhansalleh/filament-exceptions php artisan exceptions:install ``` -------------------------------- ### Example Plugin Usage Source: https://github.com/bezhansalleh/filament-exceptions/blob/main/README.md Demonstrates how to register and configure the Filament Exceptions plugin within a Laravel panel, including navigation and pruning settings. ```php return $panel ->plugins([ FilamentExceptionsPlugin::make() ->navigationLabel('Error Logs') ->navigationIcon('heroicon-o-bug-ant') ->navigationBadge() ->navigationGroup('System') ->modelPruneInterval(now()->subDays(7)) ]); ``` -------------------------------- ### Configure Filament Exceptions Plugin Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Integrate the FilamentExceptionsPlugin into your AdminPanelProvider. Customize navigation labels, icons, groups, sorting, badges, model pruning intervals, searchability, and tenant scoping. This setup ensures the error logs are accessible and managed within your Filament admin panel. ```php use BezhanSalleh\FilamentExceptions\FilamentExceptionsPlugin; use Filament\Panel; use Filament\PanelProvider; // ... other use statements public function panel(Panel $panel): Panel { return $panel ->default() ->id('admin') ->path('admin') ->plugins([ FilamentExceptionsPlugin::make() ->navigationLabel('Error Logs') ->navigationIcon('heroicon-o-bug-ant') ->navigationGroup('System') ->navigationSort(99) ->navigationBadge() ->navigationBadgeColor('danger') ->modelPruneInterval(now()->subDays(30)) ->globallySearchable(true) ->scopeToTenant(false), ]); } ``` -------------------------------- ### Customize Exception Recording Logic Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Define custom logic for recording exceptions using FilamentExceptions::recordUsing(). This allows you to filter which exceptions are logged, for example, by excluding validation or authentication exceptions, or by only logging errors in production environments. ```php use BezhanSalleh\FilamentExceptions\FilamentExceptions; use Throwable; // ... inside boot() method FilamentExceptions::recordUsing(function (Throwable $e): bool { if (! app()->isProduction()) { return false; } if ($e instanceof \Illuminate\Validation\ValidationException) { return false; } if ($e instanceof \Illuminate\Auth\AuthenticationException) { return false; } return true; }); ``` -------------------------------- ### Publish and Run Migrations Source: https://github.com/bezhansalleh/filament-exceptions/blob/main/README.md Publish and run the package's migrations to set up the database schema for storing exceptions. ```bash php artisan exceptions:install ``` -------------------------------- ### Run Tests Source: https://github.com/bezhansalleh/filament-exceptions/blob/main/README.md Command to run the test suite for the Filament Exceptions plugin. ```bash composer test ``` -------------------------------- ### Configure Plugin Tenancy Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Enable tenant scoping for exception records in multi-tenant applications. Specify the ownership and exception relationship names on your tenant model. ```php use BezhanSalleh\FilamentExceptions\FilamentExceptionsPlugin; FilamentExceptionsPlugin::make() ->scopeToTenant(true) // enable tenant scoping (default: true) ->tenantOwnershipRelationshipName('organization') // ownership relationship on the model ->tenantRelationshipName('exceptions') // relationship to fetch records from tenant ``` -------------------------------- ### Tenancy Configuration Source: https://github.com/bezhansalleh/filament-exceptions/blob/main/README.md Configure how the plugin interacts with multi-tenant applications. ```APIDOC ## Tenancy Configuration ### Description Configure how the plugin interacts with multi-tenant applications. ### Methods - `scopeToTenant(bool | Closure $condition = true)`: Scope exceptions to the current tenant. - `tenantOwnershipRelationshipName(string | Closure | null $ownershipRelationshipName)`: Set the name of the relationship for tenant ownership. - `tenantRelationshipName(string | Closure | null $relationshipName)`: Set the name of the relationship to the tenant. ``` -------------------------------- ### General Configuration Source: https://github.com/bezhansalleh/filament-exceptions/blob/main/README.md General configuration options for the plugin. ```APIDOC ## General Configuration ### Description General configuration options for the plugin. ### Methods - `cluster(string | Closure | null $cluster)`: Assign the plugin to a cluster. - `slug(string | Closure | null $slug)`: Set the slug for the plugin's resources. ``` -------------------------------- ### Configure Plugin Navigation with FilamentExceptionsPlugin::make() Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Customize the Filament navigation sidebar appearance for the Exceptions resource using various fluent methods on FilamentExceptionsPlugin::make(). Options include labels, icons, sorting, badges, parent items, and conditional registration. ```php use BezhanSalleh\FilamentExceptions\FilamentExceptionsPlugin; FilamentExceptionsPlugin::make() ->navigationLabel('Error Logs') ->navigationIcon('heroicon-o-bug-ant') ->activeNavigationIcon('heroicon-s-bug-ant') ->navigationGroup('System') ->navigationSort(10) ->navigationBadge() // show live count badge ->navigationBadgeColor('danger') // badge color ->navigationParentItem('Monitoring') // nest under a parent nav item ->subNavigationPosition(\"Filament\Pages\Enums\SubNavigationPosition::End) ->registerNavigation(fn () => auth()->user()?->isAdmin()) // conditional registration ->slug('error-logs') // custom URL slug ``` -------------------------------- ### Configure Plugin Labels and Search Source: https://github.com/bezhansalleh/filament-exceptions/blob/main/README.md Customize model labels and searchability for the Filament Exceptions plugin. Set singular and plural labels, and control global search. ```php FilamentExceptionsPlugin::make() ->modelLabel(string | Closure | null $label) ->pluralModelLabel(string | Closure | null $label) ->titleCaseModelLabel(bool | Closure $condition = true) ->globallySearchable(bool | Closure $condition = true) ``` -------------------------------- ### Configure General Plugin Settings Source: https://github.com/bezhansalleh/filament-exceptions/blob/main/README.md Set general configuration options for the Filament Exceptions plugin, such as cluster and slug. ```php FilamentExceptionsPlugin::make() ->cluster(string | Closure | null $cluster) ->slug(string | Closure | null $slug) ``` -------------------------------- ### Configure Tenancy Settings Source: https://github.com/bezhansalleh/filament-exceptions/blob/main/README.md Configure tenancy settings for the Filament Exceptions plugin. Control scoping to tenants and relationship names. ```php FilamentExceptionsPlugin::make() ->scopeToTenant(bool | Closure $condition = true) ->tenantOwnershipRelationshipName(string | Closure | null $ownershipRelationshipName) ->tenantRelationshipName(string | Closure | null $relationshipName) ``` -------------------------------- ### Navigation Configuration Source: https://github.com/bezhansalleh/filament-exceptions/blob/main/README.md Configure how the exceptions plugin appears in the Filament navigation. ```APIDOC ## Navigation Configuration ### Description Configure how the exceptions plugin appears in the Filament navigation. ### Methods - `navigationBadge(bool | Closure $condition = true)`: Show a badge in the navigation. - `navigationBadgeColor(string | array | Closure $color)`: Set the color of the navigation badge. - `navigationGroup(string | Closure | null $group)`: Assign the navigation item to a group. - `navigationParentItem(string | Closure | null $item)`: Set a parent item for the navigation item. - `navigationIcon(string | Closure | null $icon)`: Set the icon for the navigation item. - `activeNavigationIcon(string | Closure | null $icon)`: Set the active icon for the navigation item. - `navigationLabel(string | Closure | null $label)`: Set the label for the navigation item. - `navigationSort(int | Closure | null $sort)`: Set the sorting order for the navigation item. - `registerNavigation(bool | Closure $shouldRegisterNavigation)`: Control whether to register the navigation item. - `subNavigationPosition(SubNavigationPosition | Closure $position)`: Set the position of sub-navigation items. ``` -------------------------------- ### Configure Plugin Cluster Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Place the Exceptions resource within a Filament cluster for grouped resources. Specify the cluster class when making the plugin. ```php use App\Filament\Clusters\SystemCluster; use BezhanSalleh\FilamentExceptions\FilamentExceptionsPlugin; FilamentExceptionsPlugin::make() ->cluster(SystemCluster::class) ``` -------------------------------- ### Configure Plugin Navigation Source: https://github.com/bezhansalleh/filament-exceptions/blob/main/README.md Set navigation properties for the Filament Exceptions plugin. Customize labels, icons, badges, and grouping. ```php FilamentExceptionsPlugin::make() ->navigationBadge(bool | Closure $condition = true) ->navigationBadgeColor(string | array | Closure $color) ->navigationGroup(string | Closure | null $group) ->navigationParentItem(string | Closure | null $item) ->navigationIcon(string | Closure | null $icon) ->activeNavigationIcon(string | Closure | null $icon) ->navigationLabel(string | Closure | null $label) ->navigationSort(int | Closure | null $sort) ->registerNavigation(bool | Closure $shouldRegisterNavigation) ->subNavigationPosition(SubNavigationPosition | Closure $position) ``` -------------------------------- ### Publish Translations Source: https://github.com/bezhansalleh/filament-exceptions/blob/main/README.md Command to publish the translation files for the Filament Exceptions plugin. ```bash php artisan vendor:publish --tag=filament-exceptions-translations ``` -------------------------------- ### Custom Exception Model Source: https://github.com/bezhansalleh/filament-exceptions/blob/main/README.md Instructions on how to use a custom model for exceptions. ```APIDOC ## Custom Exception Model ### Description Instructions on how to use a custom model for exceptions. ### Usage 1. Extend the base model: ```php app()->isProduction()); // Skip specific exception types FilamentExceptions::recordUsing(function (Throwable $e) { return ! $e instanceof \Illuminate\Validation\ValidationException && ! $e instanceof \Illuminate\Auth\AuthenticationException; }); // Combine multiple conditions FilamentExceptions::recordUsing(function (Throwable $e) { if (! app()->isProduction()) { return false; } // Skip 4xx HTTP exceptions if ($e instanceof \Symfony\Component\HttpKernel\Exception\HttpException && $e->getStatusCode() < 500) { return false; } return true; }); } ``` -------------------------------- ### Configure Plugin Labels and Search with FilamentExceptionsPlugin::make() Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Control how exception records are displayed and searched within Filament's UI. Use methods like modelLabel(), pluralModelLabel(), titleCaseModelLabel(), and globallySearchable() to adjust singular/plural labels and searchability. ```php use BezhanSalleh\FilamentExceptions\FilamentExceptionsPlugin; FilamentExceptionsPlugin::make() ->modelLabel('Error') // singular label ->pluralModelLabel('Errors') // plural label ->titleCaseModelLabel() // apply title-case formatting ->globallySearchable(false) // exclude from Filament global search ``` -------------------------------- ### Labels and Search Configuration Source: https://github.com/bezhansalleh/filament-exceptions/blob/main/README.md Customize labels and searchability for the exceptions. ```APIDOC ## Labels and Search Configuration ### Description Customize labels and searchability for the exceptions. ### Methods - `modelLabel(string | Closure | null $label)`: Set the singular label for the model. - `pluralModelLabel(string | Closure | null $label)`: Set the plural label for the model. - `titleCaseModelLabel(bool | Closure $condition = true)`: Enable or disable title casing for model labels. - `globallySearchable(bool | Closure $condition = true)`: Enable or disable global search for exceptions. ``` -------------------------------- ### Plugin Navigation Configuration Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Customize how the Exceptions resource appears in the Filament navigation sidebar. All methods accept a raw value or a `Closure` for dynamic evaluation. ```APIDOC ## Plugin Navigation Configuration Customize how the Exceptions resource appears in the Filament navigation sidebar. All methods accept a raw value or a `Closure` for dynamic evaluation. ### Usage ```php use BezhanSalleh\FilamentExceptions\FilamentExceptionsPlugin; FilamentExceptionsPlugin::make() ->navigationLabel('Error Logs') ->navigationIcon('heroicon-o-bug-ant') ->activeNavigationIcon('heroicon-s-bug-ant') ->navigationGroup('System') ->navigationSort(10) ->navigationBadge() // show live count badge ->navigationBadgeColor('danger') // badge color ->navigationParentItem('Monitoring') // nest under a parent nav item ->subNavigationPosition(\'Filament\Pages\Enums\SubNavigationPosition::End) ->registerNavigation(fn () => auth()->user()?->isAdmin()) // conditional registration ->slug('error-logs'); // custom URL slug ``` ``` -------------------------------- ### Control Exception Recording Globally Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Use FilamentExceptions::stopRecording(), FilamentExceptions::startRecording(), and FilamentExceptions::isRecording() to globally manage whether exceptions are recorded. This is useful for disabling recording during maintenance or testing. ```php // app/Providers/AppServiceProvider.php use BezhanSalleh\FilamentExceptions\FilamentExceptions; public function boot(): void { // Disable recording entirely FilamentExceptions::stopRecording(); // Re-enable recording FilamentExceptions::startRecording(); // Check current state (returns bool) $isActive = FilamentExceptions::isRecording(); // true } ``` -------------------------------- ### Store Pre-built Exception Data with FilamentExceptions::store() Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Utilize FilamentExceptions::store() for low-level persistence of exception data. This method accepts a pre-formatted array and returns true on success or false on failure. It's primarily for custom integrations. ```php use BezhanSalleh\FilamentExceptions\FilamentExceptions; $stored = FilamentExceptions::store([ 'type' => 'App\Exceptions\PaymentFailedException', 'code' => '402', 'message' => 'Card declined: insufficient funds', 'file' => '/var/www/app/Services/PaymentService.php', 'line' => 87, 'trace' => [], 'method' => 'POST', 'path' => 'checkout/pay', 'ip' => '203.0.113.42', 'headers' => ['content-type' => ['application/json']], 'body' => ['amount' => 9900, 'currency' => 'usd'], 'cookies' => null, 'query' => [], 'route_context' => ['controller' => 'CheckoutController@pay'], 'route_parameters' => [], 'markdown' => null, ]); // $stored === true on success ``` -------------------------------- ### Configure Mass Pruning Settings Source: https://github.com/bezhansalleh/filament-exceptions/blob/main/README.md Set the interval for automatically pruning old exception records. Requires Laravel scheduler to be configured. ```php FilamentExceptionsPlugin::make() ->modelPruneInterval(Carbon $interval) ``` -------------------------------- ### Extend Custom Exception Model Source: https://github.com/bezhansalleh/filament-exceptions/blob/main/README.md Shows how to extend the base exception model provided by the Filament Exceptions plugin to create a custom model. ```php isProduction()) { return false; } // Skip validation and auth errors if ($e instanceof \Illuminate\Validation\ValidationException) { return false; } if ($e instanceof \Illuminate\Auth\AuthenticationException) { return false; } // Skip 4xx HTTP errors, only record 5xx if ($e instanceof \Symfony\Component\HttpKernel\Exception\HttpException && $e->getStatusCode() < 500) { return false; } return true; }); } ``` -------------------------------- ### Register Filament Exceptions Plugin Source: https://github.com/bezhansalleh/filament-exceptions/blob/main/README.md Register the FilamentExceptionsPlugin in your Filament panel configuration to enable the exception viewer. ```php public function panel(Panel $panel): Panel { return $panel ->plugins([ \BezhanSalleh\FilamentExceptions\FilamentExceptionsPlugin::make() ]); } ``` -------------------------------- ### Add Custom Theme Path Source: https://github.com/bezhansalleh/filament-exceptions/blob/main/README.md Add the provided CSS source path to your custom theme's `theme.css` file to ensure the plugin follows Filament's theming rules. After adding, build your theme using `npm run build`. ```css @source '../../../../vendor/bezhansalleh/filament-exceptions/resources/views/**/*.blade.php'; ``` -------------------------------- ### Plugin Labels and Search Configuration Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Control how exception records are labelled in Filament's UI, tables, and global search. ```APIDOC ## Plugin Labels and Search Configuration Control how exception records are labelled in Filament's UI, tables, and global search. ### Usage ```php use BezhanSalleh\FilamentExceptions\FilamentExceptionsPlugin; FilamentExceptionsPlugin::make() ->modelLabel('Error') // singular label ->pluralModelLabel('Errors') // plural label ->titleCaseModelLabel() // apply title-case formatting ->globallySearchable(false); // exclude from Filament global search ``` ``` -------------------------------- ### Storing Pre-built Exception Data Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt A low-level method to persist a pre-built exception data array directly to the database. Returns `true` on success, `false` on failure. ```APIDOC ## `FilamentExceptions::store(array $data)` Low-level method to persist a pre-built exception data array directly to the database. Returns `true` on success, `false` on failure (e.g., model not configured or DB error). Used internally by `report()` but accessible for custom integrations. ### Usage ```php use BezhanSalleh\FilamentExceptions\FilamentExceptions; $stored = FilamentExceptions::store([ 'type' => 'App\Exceptions\PaymentFailedException', 'code' => '402', 'message' => 'Card declined: insufficient funds', 'file' => '/var/www/app/Services/PaymentService.php', 'line' => 87, 'trace' => [], 'method' => 'POST', 'path' => 'checkout/pay', 'ip' => '203.0.113.42', 'headers' => ['content-type' => ['application/json']], 'body' => ['amount' => 9900, 'currency' => 'usd'], 'cookies' => null, 'query' => [], 'route_context' => ['controller' => 'CheckoutController@pay'], 'route_parameters' => [], 'markdown' => null, ]); // $stored === true on success ``` ``` -------------------------------- ### Custom Recording Logic Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Define custom logic to determine which exceptions should be recorded using a closure. ```APIDOC ## FilamentExceptions::recordUsing(Closure $callback) Provide a custom closure to determine whether a given `Throwable` should be recorded. The closure receives the exception as its argument and must return a boolean. Replaces the global on/off toggle with fine-grained, per-exception logic. ```php // app/Providers/AppServiceProvider.php use BezhanSalleh\FilamentExceptions\FilamentExceptions; use Throwable; public function boot(): void { FilamentExceptions::recordUsing(function (Throwable $e): bool { // Only record in production if (! app()->isProduction()) { return false; } // Skip validation and auth errors if ($e instanceof \Illuminate\Validation\ValidationException) { return false; } if ($e instanceof \Illuminate\Auth\AuthenticationException) { return false; } // Skip 4xx HTTP errors, only record 5xx if ($e instanceof \Symfony\Component\HttpKernel\Exception\HttpException && $e->getStatusCode() < 500) { return false; } return true; }); } ``` ``` -------------------------------- ### Register Custom Exception Model Source: https://github.com/bezhansalleh/filament-exceptions/blob/main/README.md Demonstrates how to register a custom exception model with the Filament Exceptions plugin in a Laravel service provider. ```php use App\Models\MyCustomException; use BezhanSalleh\FilamentExceptions\FilamentExceptions; ... public function boot() { FilamentExceptions::model(MyCustomException::class); } ... ``` -------------------------------- ### Stop Exception Recording Source: https://github.com/bezhansalleh/filament-exceptions/blob/main/README.md Use `FilamentExceptions::stopRecording()` in your `AppServiceProvider`'s `boot()` method to disable automatic exception recording. ```php use BezhanSalleh\FilamentExceptions\FilamentExceptions; public function boot(): void { // Stop recording exceptions FilamentExceptions::stopRecording(); // Resume recording FilamentExceptions::startRecording(); // Check if recording is active FilamentExceptions::isRecording(); } ``` -------------------------------- ### Manually Report Exceptions with FilamentExceptions::report() Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Use FilamentExceptions::report() to manually record exceptions that are caught and handled within your application code. This ensures that even swallowed exceptions are logged for debugging. ```php use BezhanSalleh\FilamentExceptions\FilamentExceptions; try { $result = someRiskyOperation(); } catch (\RuntimeException $e) { // Handle gracefully but still record it FilamentExceptions::report($e); $result = defaultValue(); } ``` -------------------------------- ### Mass Pruning Settings Source: https://github.com/bezhansalleh/filament-exceptions/blob/main/README.md Configure automatic pruning of old exception records. ```APIDOC ## Mass Pruning Settings ### Description Configure automatic pruning of old exception records. ### Method - `modelPruneInterval(Carbon $interval)`: Set the interval for pruning old records. Requires Laravel scheduler to be set up. ### Note This requires the Laravel scheduler to be set up and configured. See [Running The Scheduler](https://laravel.com/docs/10.x/scheduling#running-the-scheduler) for details. ``` -------------------------------- ### Extend Exception Model with Custom Eloquent Model Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Create a custom Eloquent model that extends the base Exception model to add custom casts, relationships, scopes, or observers. Register this custom model using FilamentExceptions::model() in your AppServiceProvider. ```php namespace App\Models; use BezhanSalleh\FilamentExceptions\Models\Exception as BaseException; use Illuminate\Database\Eloquent\Builder; class MyException extends BaseException { // Add a scope to filter by HTTP method public function scopeGetRequests(Builder $query): Builder { return $query->where('method', 'GET'); } // Add a custom accessor public function getShortMessageAttribute(): string { return str($this->message)->limit(80)->value(); } } ``` ```php use App\Models\MyException; use BezhanSalleh\FilamentExceptions\FilamentExceptions; public function boot(): void { FilamentExceptions::model(MyException::class); } ``` -------------------------------- ### Add Plugin Views to Custom Filament Theme Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Include the plugin's Blade views in your custom Filament theme's CSS file to ensure Tailwind includes them during compilation. Remember to build your assets afterwards. ```css /* resources/css/filament/admin/theme.css */ @source '../../../../vendor/bezhansalleh/filament-exceptions/resources/views/**/*.blade.php'; ``` ```bash npm run build ``` -------------------------------- ### Schedule Artisan Command for Pruning Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Ensure the Laravel scheduler is running in your production environment to process scheduled tasks, including the automatic pruning of old exception records configured via the Filament Exceptions plugin. ```bash # In production: ensure the scheduler runs every minute * * * * * cd /var/www/html && php artisan schedule:run >> /dev/null 2>&1 ``` -------------------------------- ### Configure Plugin Pruning with FilamentExceptionsPlugin::modelPruneInterval() Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Set up automatic deletion of old exception records using Laravel's model pruning. Configure the interval with modelPruneInterval(), specifying how old records should be before being pruned. Ensure the Laravel scheduler is running. ```php use BezhanSalleh\FilamentExceptions\FilamentExceptionsPlugin; // Prune records older than 30 days (default is 7 days / subWeek()) FilamentExceptionsPlugin::make() ->modelPruneInterval(now()->subDays(30)) ``` -------------------------------- ### Query Stored Exceptions Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Query the Exception model directly to retrieve stored exception data. Access properties like type, code, message, file, line, and request details. ```php use BezhanSalleh\FilamentExceptions\Models\Exception; // Querying stored exceptions directly $recent = Exception::query() ->where('type', 'like', '%Http%') ->where('method', 'POST') ->whereDate('created_at', '>=', now()->subDays(7)) ->orderByDesc('created_at') ->get(); foreach ($recent as $exception) { echo $exception->type; // e.g. "Symfony\Component\HttpKernel\Exception\NotFoundHttpException" echo $exception->code; // e.g. "404" echo $exception->message; // e.g. "No query results for model [App\Models\User] 42" echo $exception->file; // absolute path to source file echo $exception->line; // integer line number echo count($exception->trace); // array of stack frames echo $exception->method; // "GET", "POST", etc. echo $exception->path; // "api/users/42" echo $exception->ip; // "203.0.113.1" print_r($exception->headers); // associative array print_r($exception->body); // parsed request body array or null print_r($exception->query); // DB queries executed during the request print_r($exception->route_context); // controller/action context print_r($exception->route_parameters); // route model binding values echo $exception->created_at; // Carbon timestamp } ``` -------------------------------- ### Plugin Pruning Configuration Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Configure automatic deletion of old exception records via Laravel's model pruning feature. Requires the Laravel scheduler to be running. ```APIDOC ## Plugin Pruning Configuration Configure automatic deletion of old exception records via Laravel's model pruning feature. Requires the Laravel scheduler to be running. ### Usage ```php use BezhanSalleh\FilamentExceptions\FilamentExceptionsPlugin; // Prune records older than 30 days (default is 7 days / subWeek()) FilamentExceptionsPlugin::make() ->modelPruneInterval(now()->subDays(30)); ``` ### Scheduler Configuration In production, ensure the Laravel scheduler runs every minute: ```bash # In production: ensure the scheduler runs every minute * * * * * cd /var/www/html && php artisan schedule:run >> /dev/null 2>&1 ``` ``` -------------------------------- ### Register FilamentExceptionsPlugin in Panel Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Register the FilamentExceptionsPlugin within your Filament panel's provider. The plugin automatically registers its resource and hooks into the exception handler. ```php // app/Providers/Filament/AdminPanelProvider.php use BezhanSalleh\FilamentExceptions\FilamentExceptionsPlugin; use Filament\Panel; use Filament\PanelProvider; class AdminPanelProvider extends PanelProvider { public function panel(Panel $panel): Panel { return $panel ->default() ->id('admin') ->path('admin') ->plugins([ FilamentExceptionsPlugin::make(), ]); } } ``` -------------------------------- ### Registering a Custom Exception Model Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Override the default Exception model with a custom Eloquent model to add custom casts, relationships, scopes, or observers to stored exception records. ```APIDOC ## `FilamentExceptions::model(string $model)` Override the default `Exception` model with a custom Eloquent model. Allows adding custom casts, relationships, scopes, or observers to the stored exception records. ### Usage 1. Create a custom model extending the base `Exception` model. ```php // app/Models/MyException.php namespace App\Models; use BezhanSalleh\FilamentExceptions\Models\Exception as BaseException; use Illuminate\Database\Eloquent\Builder; class MyException extends BaseException { // Add a scope to filter by HTTP method public function scopeGetRequests(Builder $query): Builder { return $query->where('method', 'GET'); } // Add a custom accessor public function getShortMessageAttribute(): string { return str($this->message)->limit(80)->value(); } } ``` 2. Register the custom model in `AppServiceProvider`. ```php // app/Providers/AppServiceProvider.php use App\Models\MyException; use BezhanSalleh\FilamentExceptions\FilamentExceptions; public function boot(): void { FilamentExceptions::model(MyException::class); } ``` ``` -------------------------------- ### Toggle Exception Recording Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Control whether exceptions are recorded globally. This is useful for disabling recording during maintenance or testing. ```APIDOC ## FilamentExceptions::stopRecording() / startRecording() / isRecording() Toggle exception recording on or off globally, and check the current recording state. Useful for disabling recording during maintenance windows, seeding, or test runs. ```php // app/Providers/AppServiceProvider.php use BezhanSalleh\FilamentExceptions\FilamentExceptions; public function boot(): void { // Disable recording entirely FilamentExceptions::stopRecording(); // Re-enable recording FilamentExceptions::startRecording(); // Check current state (returns bool) $isActive = FilamentExceptions::isRecording(); // true } ``` ``` -------------------------------- ### Manually Reporting an Exception Source: https://context7.com/bezhansalleh/filament-exceptions/llms.txt Manually report an exception to be stored. This is useful for exceptions that are caught and swallowed in application code. ```APIDOC ## `FilamentExceptions::report(Throwable $throwable)` Manually report an exception to be stored. Normally called automatically via Laravel's exception handler hook, but can be called directly to record exceptions that are caught and swallowed in application code. ### Usage ```php use BezhanSalleh\FilamentExceptions\FilamentExceptions; try { $result = someRiskyOperation(); } catch (\RuntimeException $e) { // Handle gracefully but still record it FilamentExceptions::report($e); $result = defaultValue(); } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.