Skip to content

Commit 19a4d30

Browse files
committed
feat: rename 'state' to 'status' in Progress Stepper; update related documentation and examples for Posts
1 parent b678bd3 commit 19a4d30

File tree

7 files changed

+67
-78
lines changed

7 files changed

+67
-78
lines changed
19.5 KB
Loading
-26.2 KB
Binary file not shown.
22.3 KB
Loading

src/master/advanced/progress-stepper.md

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ public static function form(Form $form): Form
3131
{
3232
return $form
3333
->schema([
34-
ProgressStepper::make('state')
34+
ProgressStepper::make('status')
3535
->hiddenLabel()
3636
->inline()
3737
->options(fn ($record) => self::getStateOptions($record))
38-
->default(OrderState::DRAFT->value)
38+
->default(PostStatus::DRAFT->value)
3939
->disabled()
4040
->live()
4141
->reactive(),
@@ -44,14 +44,17 @@ public static function form(Form $form): Form
4444

4545
protected static function getStateOptions($record): array
4646
{
47-
$options = OrderState::options();
47+
$options = PostStatus::options();
4848

49-
if ($record && $record->state !== OrderState::CANCEL->value) {
50-
unset($options[OrderState::CANCEL->value]);
49+
if (
50+
$record
51+
&& $record->status !== PostStatus::UNPUBLISHED->value
52+
) {
53+
unset($options[PostStatus::UNPUBLISHED->value]);
5154
}
5255

53-
if (!$record) {
54-
unset($options[OrderState::CANCEL->value]);
56+
if (! $record) {
57+
unset($options[PostStatus::UNPUBLISHED->value]);
5558
}
5659

5760
return $options;
@@ -60,19 +63,19 @@ protected static function getStateOptions($record): array
6063

6164
## **Changing Button Colors**
6265

63-
To modify the colors of different states, use the `colors()` method:
66+
To modify the colors of different status, use the `colors()` method:
6467

6568
```php
66-
ProgressStepper::make('state')
69+
ProgressStepper::make('status')
6770
->options([
68-
'draft' => 'Draft',
69-
'processing' => 'Processing',
70-
'completed' => 'Completed'
71+
'draft' => 'Draft',
72+
'unpublished' => 'Unpublished',
73+
'published' => 'Published'
7174
])
7275
->colors([
73-
'draft' => 'gray',
74-
'processing' => 'info',
75-
'completed' => 'success',
76+
'draft' => 'gray',
77+
'unpublished' => 'info',
78+
'published' => 'success',
7679
]);
7780
```
7881

@@ -83,14 +86,14 @@ To display icons alongside state labels, use the `icons()` method:
8386
```php
8487
ProgressStepper::make('state')
8588
->options([
86-
'draft' => 'Draft',
87-
'processing' => 'Processing',
88-
'completed' => 'Completed'
89+
'draft' => 'Draft',
90+
'unpublished' => 'Unpublished',
91+
'published' => 'Published'
8992
])
9093
->icons([
91-
'draft' => 'heroicon-o-pencil',
92-
'processing' => 'heroicon-o-clock',
93-
'completed' => 'heroicon-o-check-circle',
94+
'draft' => 'heroicon-o-pencil',
95+
'unpublished' => 'heroicon-o-circle',
96+
'published' => 'heroicon-o-check-badge',
9497
]);
9598
```
9699

@@ -99,37 +102,36 @@ ProgressStepper::make('state')
99102
Instead of defining options manually, you can use an Enum:
100103

101104
```php
102-
use App\Enums\OrderState;
105+
use App\Enums\PostStatus;
103106

104-
ProgressStepper::make('state')
105-
->options(OrderState::options())
106-
->colors(OrderState::colors())
107-
->icons(OrderState::icons());
107+
ProgressStepper::make('status')
108+
->options(PostStatus::options())
109+
->colors(PostStatus::colors())
110+
->icons(PostStatus::icons());
108111
```
109112

110-
This keeps the state definitions centralized in an `OrderState` enum.
113+
This keeps the status definitions centralized in an `PostStatus` enum.
111114

112-
## **Handling Conditional States**
115+
## **Handling Conditional Statuses**
113116

114-
To prevent certain states from being displayed (e.g., hiding "Canceled" if the order is active):
117+
To prevent certain statuses from being displayed (e.g., hiding "UNPUBLISHED" if the status is unpublished):
115118

116119
```php
117-
ProgressStepper::make('state')
120+
ProgressStepper::make('status')
118121
->options(function ($record) {
119-
$options = OrderState::options();
122+
$options = PostStatus::options();
120123

121-
if ($record && $record->state != OrderState::CANCEL->value) {
122-
unset($options[OrderState::CANCEL->value]);
124+
if (
125+
$record
126+
&& $record->status != PostStatus::UNPUBLISHED->value
127+
) {
128+
unset($options[PostStatus::UNPUBLISHED->value]);
123129
}
124130

125131
return $options;
126132
});
127133
```
128134

129-
## **Example Output**
130-
131-
![Progress Stepper](./images/progress-stepper.png)
132-
133135
## **Key Features**
134136

135137
- **Extends Filament’s `ToggleButtons`**: Ensures seamless integration with Filament forms.

src/master/advanced/table-views.md

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,20 @@ When applied to a resource page, this trait:
9393

9494
## Implementation Example
9595

96-
The `ListOrders` class demonstrates how to implement table views in a resource page:
96+
The `ListBlogs` class demonstrates how to implement table views in a resource page:
9797

9898
```php
99-
namespace Webkul\Purchase\Filament\Admin\Clusters\Orders\Resources\OrderResource\Pages;
99+
namespace Webkul\Blog\Filament\Admin\Clusters\Blog\Resources\BlogResource\Pages;
100100
```
101101

102-
This class uses the `HasTableViews` trait and defines multiple preset views for the Orders table:
102+
This class uses the `HasTableViews` trait and defines multiple preset views for the Blogs table:
103103

104104
```php
105105
public function getPresetTableViews(): array
106106
{
107107
return [
108-
'my_purchases' => PresetView::make(__('My Purchases'))
109-
->icon('heroicon-o-shopping-cart')
108+
'my_posts' => PresetView::make(__('My Posts'))
109+
->icon('heroicon-o-user')
110110
->favorite()
111111
->modifyQueryUsing(fn (Builder $query) => $query->where('user_id', Auth::id())),
112112

@@ -115,22 +115,12 @@ public function getPresetTableViews(): array
115115
}
116116
```
117117

118-
### Available Preset Views in the Example
119-
120-
1. **My Purchases**: Shows orders created by the current user
121-
2. **Purchase Orders**: Filters orders in PURCHASE or DONE states
122-
3. **Starred Orders**: Shows high-priority (starred) orders
123-
4. **Orders**: Shows orders in DRAFT or SENT states
124-
5. **Draft Orders**: Shows only orders in DRAFT state
125-
6. **Waiting Orders**: Shows only orders in SENT state
126-
7. **Late Orders**: Shows orders past their ordered_at date that are still in DRAFT or SENT states
127-
128118
## Customizing Queries
129119

130120
Each preset view can modify the underlying query using the `modifyQueryUsing` method. This allows for powerful filtering capabilities:
131121

132122
```php
133-
->modifyQueryUsing(fn (Builder $query) => $query->where('state', OrderState::DRAFT))
123+
->modifyQueryUsing(fn (Builder $query) => $query->where('author_id', Auth::id()))
134124
```
135125

136126
## User Favorites System
@@ -163,7 +153,7 @@ Preset views can include icons for better visual recognition:
163153
The example shows proper use of translation strings for view labels:
164154

165155
```php
166-
PresetView::make(__('purchases::filament/admin/clusters/orders/resources/order/pages/list-orders.tabs.my-purchases'))
156+
PresetView::make(__('blogs::filament/admin/clusters/blogs/resources/posts/pages/list-posts.tabs.my-posts'))
167157
```
168158

169159
## **Example Output of Table View Filters**

src/master/getting-started/clusters.md

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,48 +24,47 @@ To enable clusters in Aures ERP, configure the panel to discover cluster classes
2424
$panel
2525
->when($panel->getId() == 'admin', function (Panel $panel) {
2626
$panel
27-
->discoverResources(in: $this->getPluginBasePath('/Filament/Resources'), for: 'Webkul\\Inventory\\Filament\\Resources')
28-
->discoverPages(in: $this->getPluginBasePath('/Filament/Pages'), for: 'Webkul\\Inventory\\Filament\\Pages')
29-
->discoverClusters(in: $this->getPluginBasePath('/Filament/Clusters'), for: 'Webkul\\Inventory\\Filament\\Clusters')
30-
->discoverWidgets(in: $this->getPluginBasePath('/Filament/Widgets'), for: 'Webkul\\Inventory\\Filament\\Widgets');
27+
->discoverResources(in: $this->getPluginBasePath('/Filament/Resources'), for: 'Webkul\\Blog\\Filament\\Resources')
28+
->discoverPages(in: $this->getPluginBasePath('/Filament/Pages'), for: 'Webkul\\Blog\\Filament\\Pages')
29+
->discoverClusters(in: $this->getPluginBasePath('/Filament/Clusters'), for: 'Webkul\\Blog\\Filament\\Clusters')
30+
->discoverWidgets(in: $this->getPluginBasePath('/Filament/Widgets'), for: 'Webkul\\Blog\\Filament\\Widgets');
3131
});
3232
}
3333
```
3434

3535
Now, generate a cluster using:
3636

3737
```sh
38-
php artisan make:filament-cluster Products
38+
php artisan make:filament-cluster Posts
3939
```
4040

41-
This creates a `Products` cluster in `Webkul\Inventory\Filament\Clusters`:
41+
This creates a `Products` cluster in `Webkul\Blog\Filament\Clusters`:
4242

4343
```php
4444
<?php
4545

46-
namespace Webkul\Inventory\Filament\Clusters;
46+
namespace Webkul\Blog\Filament\Clusters;
4747

4848
use Filament\Clusters\Cluster;
4949

50-
class Products extends Cluster
50+
class Posts extends Cluster
5151
{
52-
protected static ?string $slug = 'inventory/products';
52+
protected static ?string $slug = 'blog/posts';
5353

54-
protected static ?string $navigationIcon = 'heroicon-o-shopping-bag';
54+
protected static ?string $navigationIcon = 'heroicon-o-document-text';
5555

5656
protected static ?int $navigationSort = 2;
5757

5858
public static function getNavigationLabel(): string
5959
{
60-
return __('Products');
60+
return __('Posts');
6161
}
6262

6363
public static function getNavigationGroup(): string
6464
{
65-
return __('Inventory');
65+
return __('Blog');
6666
}
6767
}
68-
6968
```
7069

7170
You can customize the navigation using `$navigationLabel`, `$navigationSort`, and `$navigationGroup`.
@@ -75,9 +74,9 @@ You can customize the navigation using `$navigationLabel`, `$navigationSort`, an
7574
To assign a resource or page to a cluster, set the `$cluster` property:
7675

7776
```php
78-
use Webkul\Inventory\Filament\Clusters\Products;
77+
use Webkul\Blog\Filament\Clusters\Posts;
7978

80-
protected static ?string $cluster = Products::class;
79+
protected static ?string $cluster = Posts::class;
8180
```
8281

8382
## Recommended Code Structure
@@ -86,15 +85,15 @@ For better organization, store related resources and pages inside a directory ma
8685

8786
```
8887
+-- Clusters
89-
| +-- Products.php
90-
| +-- Products
88+
| +-- Posts.php
89+
| +-- Posts
9190
| | +-- Resources
92-
| | | +-- ProductResource.php
93-
| | | +-- ProductResource
91+
| | | +-- PostResource.php
92+
| | | +-- PostResource
9493
| | | | +-- Pages
95-
| | | | | +-- CreateProduct.php
96-
| | | | | +-- EditProduct.php
97-
| | | | | +-- ListProducts.php
94+
| | | | | +-- CreatePost.php
95+
| | | | | +-- EditPost.php
96+
| | | | | +-- ListPosts.php
9897
```
9998

10099
Filament will prompt whether to place new resources or pages inside a cluster when using `make:filament-resource` or `make:filament-page`.

src/master/getting-started/resources/listing-records.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ public function getTabs(): array
1717
'all' => Tab::make(__('All Products'))->badge(Product::count()),
1818
'archived' => Tab::make(__('Archived'))->badge(Product::onlyTrashed()->count())
1919
->modifyQueryUsing(fn ($query) => $query->onlyTrashed()),
20-
'out_of_stock' => Tab::make(__('Out of Stock'))->badge(Product::where('stock', 0)->count())
21-
->modifyQueryUsing(fn ($query) => $query->where('stock', 0)),
2220
];
2321
}
2422
```

0 commit comments

Comments
 (0)