Skip to content

Commit dc811b1

Browse files
author
Mohammad Arif
committed
initial release
1 parent 1307dfb commit dc811b1

File tree

12 files changed

+152
-48
lines changed

12 files changed

+152
-48
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ jobs:
1414
matrix:
1515
php: [8.1, 8.2, 8.3]
1616
laravel: [10, 11]
17+
exclude:
18+
# Laravel 11 requires PHP 8.2+
19+
- php: 8.1
20+
laravel: 11
1721

1822
steps:
1923
- name: Checkout code

.github/workflows/tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ jobs:
2222
testbench: 8.*
2323
- laravel: 11
2424
testbench: 9.*
25+
exclude:
26+
# Laravel 11 requires PHP 8.2+
27+
- php: 8.1
28+
laravel: 11
2529

2630
steps:
2731
- name: Checkout code

CONTRIBUTING.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,16 @@ composer format
3636

3737
1. Fork the repository
3838
2. Clone your fork locally
39-
3. Install dependencies:
39+
3. **Run the setup script** (recommended):
40+
```bash
41+
./setup.sh
42+
```
43+
44+
Or manually install dependencies:
4045
```bash
4146
composer install
4247
```
48+
4349
4. Create a feature branch:
4450
```bash
4551
git checkout -b feature/your-feature-name
@@ -56,6 +62,14 @@ composer format
5662
8. Commit and push
5763
9. Create a Pull Request
5864

65+
### PHP Version Compatibility
66+
67+
This package supports:
68+
- **PHP 8.1** with **Laravel 10**
69+
- **PHP 8.2+** with **Laravel 10 or 11**
70+
71+
The `setup.sh` script automatically detects your PHP version and installs compatible dependencies.
72+
5973
## Reporting Issues
6074

6175
When creating an issue, please provide:

composer.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@
1515
"require": {
1616
"php": "^8.1",
1717
"filament/filament": "^3.0",
18-
"illuminate/support": "^10.0|^11.0"
18+
"illuminate/support": "^10.0|^11.0",
19+
"laravel/framework": "^10.0",
20+
"orchestra/testbench": "^8.0"
21+
},
22+
"require-dev": {
23+
"laravel/pint": "^1.0",
24+
"phpunit/phpunit": "^10.0|^11.0",
25+
"pestphp/pest": "^2.0",
26+
"pestphp/pest-plugin-laravel": "^2.0"
1927
},
2028
"autoload": {
2129
"psr-4": {

phpunit.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
<directory suffix="Test.php">./tests</directory>
1313
</testsuite>
1414
</testsuites>
15-
<coverage includeUncoveredFiles="true"
16-
processUncoveredFiles="true"
17-
ignoreDeprecatedCodeUnits="true"
18-
disableCodeCoverageIgnore="true">
15+
<coverage>
1916
<include>
2017
<directory suffix=".php">./src</directory>
2118
</include>
@@ -27,5 +24,7 @@
2724
<php>
2825
<env name="APP_ENV" value="testing"/>
2926
<env name="APP_KEY" value="base64:2fl+Ktvkfl+Fuz4Qp/A75G2RTiWVA/ZoKZvp6fiiM10="/>
27+
<env name="DB_CONNECTION" value="sqlite"/>
28+
<env name="DB_DATABASE" value=":memory:"/>
3029
</php>
3130
</phpunit>

setup.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
# Local development setup script for Filament AlertBox Package
4+
5+
set -e
6+
7+
echo "🚀 Setting up Filament AlertBox Package for development..."
8+
9+
# Check PHP version
10+
PHP_VERSION=$(php -r "echo PHP_VERSION;")
11+
echo "📋 Detected PHP version: $PHP_VERSION"
12+
13+
# Determine Laravel version based on PHP version
14+
if php -r "exit(version_compare(PHP_VERSION, '8.2.0', '<') ? 1 : 0);"; then
15+
echo "⚠️ PHP < 8.2 detected, using Laravel 10"
16+
LARAVEL_VERSION="^10.0"
17+
TESTBENCH_VERSION="^8.0"
18+
else
19+
echo "✅ PHP >= 8.2 detected, using Laravel 11"
20+
LARAVEL_VERSION="^11.0"
21+
TESTBENCH_VERSION="^9.0"
22+
fi
23+
24+
echo "📦 Installing dependencies..."
25+
26+
# Install dependencies with appropriate versions
27+
composer require "laravel/framework:$LARAVEL_VERSION" "orchestra/testbench:$TESTBENCH_VERSION" --no-interaction --no-update
28+
29+
echo "🔄 Updating all dependencies..."
30+
composer update --prefer-dist --no-interaction
31+
32+
echo "✅ Setup complete!"
33+
echo ""
34+
echo "Available commands:"
35+
echo " composer test - Run tests"
36+
echo " composer format - Format code with Pint"
37+
echo " composer test-coverage - Run tests with coverage"
38+
echo ""
39+
echo "🎉 Happy coding!"

src/AlertBoxManager.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66

77
/**
88
* Alert Box Manager
9-
*
9+
*
1010
* Manages alerts in memory for FilamentPHP using render hooks system.
1111
* Provides a fluent API for creating and managing alerts across different page positions.
12-
*
13-
* @package RifRocket\FilamentAlertBox
12+
*
1413
* @author Mohammad Arif <mohammad.arif9999@gmail.com>
1514
*/
1615
final class AlertBoxManager
@@ -60,11 +59,11 @@ public static function addAlert(string $position, array $config): void
6059
}
6160

6261
// Validate required config fields
63-
if (!isset($config['type']) || !in_array($config['type'], ['info', 'success', 'warning', 'danger', 'error'])) {
62+
if (! isset($config['type']) || ! in_array($config['type'], ['info', 'success', 'warning', 'danger', 'error'])) {
6463
throw new \InvalidArgumentException('Invalid alert type');
6564
}
6665

67-
if (!isset(self::$alerts[$position])) {
66+
if (! isset(self::$alerts[$position])) {
6867
self::$alerts[$position] = [];
6968
}
7069

@@ -96,15 +95,15 @@ public static function getAlerts(?string $position = null): array
9695
*/
9796
public static function getPositionsWithAlerts(): array
9897
{
99-
return array_keys(array_filter(self::$alerts, fn($alerts) => !empty($alerts)));
98+
return array_keys(array_filter(self::$alerts, fn ($alerts) => ! empty($alerts)));
10099
}
101100

102101
/**
103102
* Check if a position has alerts
104103
*/
105104
public static function hasAlerts(string $position): bool
106105
{
107-
return !empty(self::$alerts[$position]);
106+
return ! empty(self::$alerts[$position]);
108107
}
109108

110109
/**
@@ -136,7 +135,7 @@ public static function clearAll(): void
136135
}
137136

138137
// Quick static methods for common patterns (backwards compatibility)
139-
138+
140139
/**
141140
* Create a success alert
142141
*/

src/AlertBoxPlugin.php

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
class AlertBoxPlugin implements Plugin
1111
{
1212
protected bool $enabled = true;
13+
1314
public string $view = 'alert-box::layouts.unified-alert';
1415

1516
public function getId(): string
@@ -19,7 +20,7 @@ public function getId(): string
1920

2021
public function register(Panel $panel): void
2122
{
22-
if (!$this->enabled) {
23+
if (! $this->enabled) {
2324
return;
2425
}
2526

@@ -62,7 +63,7 @@ function () use ($hook) {
6263
'position' => $hook, // Pass position to help determine layout type
6364
]);
6465
},
65-
66+
6667
);
6768
}
6869
}
@@ -73,6 +74,7 @@ function () use ($hook) {
7374
public function enabled(bool $enabled = true): static
7475
{
7576
$this->enabled = $enabled;
77+
7678
return $this;
7779
}
7880

@@ -81,7 +83,8 @@ public function enabled(bool $enabled = true): static
8183
*/
8284
public function disable(bool $disable = true): static
8385
{
84-
$this->enabled = !$disable;
86+
$this->enabled = ! $disable;
87+
8588
return $this;
8689
}
8790

@@ -90,7 +93,7 @@ public function disable(bool $disable = true): static
9093
*/
9194
public static function make(): static
9295
{
93-
return new static();
96+
return new static;
9497
}
9598

9699
/**
@@ -99,37 +102,38 @@ public static function make(): static
99102
public function view(string $view): self
100103
{
101104
$this->view = $view;
105+
102106
return $this;
103107
}
104108

105-
106109
/**
107110
* Define default colors for alert types
108111
*/
109112
public function defineColors(array $colors = []): self
110113
{
111114
Config::set('alert-box.colors', $colors ?: [
112115
'success' => [
113-
'title' => '#047857',
116+
'title' => '#047857',
114117
'description' => '#10b981',
115-
'icon' => '#10b981',
118+
'icon' => '#10b981',
116119
],
117120
'danger' => [
118-
'title' => '#b91c1c',
121+
'title' => '#b91c1c',
119122
'description' => '#ef4444',
120-
'icon' => '#ef4444',
123+
'icon' => '#ef4444',
121124
],
122125
'warning' => [
123-
'title' => '#b45309',
126+
'title' => '#b45309',
124127
'description' => '#f59e0b',
125-
'icon' => '#f59e0b',
128+
'icon' => '#f59e0b',
126129
],
127130
'info' => [
128-
'title' => '#1d4ed8',
131+
'title' => '#1d4ed8',
129132
'description' => '#3b82f6',
130-
'icon' => '#3b82f6',
133+
'icon' => '#3b82f6',
131134
],
132135
]);
136+
133137
return $this;
134138
}
135139
}

src/AlertBoxServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function register(): void
1313

1414
public function boot(): void
1515
{
16-
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'alert-box');
16+
$this->loadViewsFrom(__DIR__.'/../resources/views', 'alert-box');
1717
// No CSS assets needed - using Tailwind CSS utility classes only
1818
}
1919
}

0 commit comments

Comments
 (0)