Skip to content

Commit ba86364

Browse files
committed
feat: update documentation and examples to reflect 'Post' terminology; rename classes and namespaces for consistency
1 parent 27aeb26 commit ba86364

File tree

3 files changed

+16
-21
lines changed

3 files changed

+16
-21
lines changed

src/master/getting-started/resources/creating-record.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ When creating record in Aureus ERP using Filament, you may need to modify form d
44

55
This method allows you to:
66

7-
- **Automatically assign user-related fields** (e.g., `creator_id`, `company_id`).
87
- **Set default values** for new records.
98
- **Modify or sanitize input data** before saving.
109

@@ -35,7 +34,6 @@ protected function mutateFormDataBeforeCreate(array $data): array
3534
$user = auth()->user();
3635

3736
$data['creator_id'] = $user->id;
38-
$data['company_id'] = $user->default_company_id;
3937
$data['created_at'] = now();
4038

4139
return $data;
@@ -45,7 +43,6 @@ protected function mutateFormDataBeforeCreate(array $data): array
4543
This ensures that:
4644

4745
- **The creator is assigned** (`creator_id`).
48-
- **The record belongs to the user's company** (`company_id`).
4946
- **The creation timestamp is set** (`created_at`).
5047

5148
## **Mutating Data in Modal Actions**
@@ -64,24 +61,24 @@ CreateAction::make()
6461
]);
6562
```
6663

67-
## **Example: Implementing CreateProduct**
64+
## **Example: Implementing CreatePost**
6865

69-
A `CreateProduct` class can be implemented using Filament’s `CreateRecord`.
66+
A `CreatePost` class can be implemented using Filament’s `CreateRecord`.
7067

7168
```php
7269
<?php
7370

74-
namespace Webkul\Inventory\Filament\Clusters\Products\Resources\ProductResource\Pages;
71+
namespace Webkul\Blog\Filament\Clusters\Posts\Resources\PostResource\Pages;
7572

7673
use Filament\Notifications\Notification;
7774
use Filament\Resources\Pages\CreateRecord;
7875
use Illuminate\Support\Facades\Auth;
79-
use Webkul\Inventory\Models\Product;
80-
use Webkul\Inventory\Filament\Clusters\Products\Resources\ProductResource;
76+
use Webkul\Blog\Models\Post;
77+
use Webkul\Blog\Filament\Clusters\Posts\Resources\PostResource;
8178

82-
class CreateProduct extends CreateRecord
79+
class CreatePost extends CreateRecord
8380
{
84-
protected static string $resource = ProductResource::class;
81+
protected static string $resource = PostResource::class;
8582

8683
protected function getRedirectUrl(): string
8784
{
@@ -92,33 +89,31 @@ class CreateProduct extends CreateRecord
9289
{
9390
return Notification::make()
9491
->success()
95-
->title(__('Product created'))
96-
->body(__('Product has been created successfully.'));
92+
->title(__('Post created'))
93+
->body(__('Post has been created successfully.'));
9794
}
9895

9996
protected function mutateFormDataBeforeCreate(array $data): array
10097
{
10198
$user = Auth::user();
10299

103100
$data['creator_id'] = $user->id;
104-
$data['company_id'] = $user->default_company_id;
105101
$data['created_at'] = now();
106102

107103
return $data;
108104
}
109105

110106
protected function afterCreate(): void
111107
{
112-
ProductResource::updateStockLevels($this->getRecord());
113108
}
114109
}
115110
```
116111

117112
## **Explanation**
118113

119-
- **Handles Product Creation**: This class ensures proper product creation, following best practices.
114+
- **Handles Post Creation**: This class ensures proper post creation, following best practices.
120115
- **Data Mutation**: Assigns the `creator_id` and `company_id` before saving.
121-
- **Post-Creation Processing**: Calls `updateStockLevels()` to recalculate stock availability after product creation.
122-
- **Redirection & Notifications**: Redirects to the product view and notifies the user on successful creation.
116+
- **Post-Creation Processing**: Calls `updateStockLevels()` to recalculate stock availability after post creation.
117+
- **Redirection & Notifications**: Redirects to the post view and notifies the user on successful creation.
123118

124119
For more details, check the **[Official Filament Documentation](https://filamentphp.com/docs/3.x/panels/resources/creating-records)**. 🚀

src/master/getting-started/resources/editing-record.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ A `EditPost` class can be implemented using Filament’s `EditRecord`.
4141
```php
4242
<?php
4343

44-
namespace Webkul\Post\Filament\Resources\PostResource\Pages;
44+
namespace Webkul\Blog\Filament\Resources\PostResource\Pages;
4545

4646
use Filament\Actions;
4747
use Filament\Forms;
@@ -50,7 +50,7 @@ use Filament\Pages\SubNavigationPosition;
5050
use Filament\Resources\Pages\EditRecord;
5151
use Illuminate\Support\Facades\Auth;
5252
use Webkul\Chatter\Filament\Actions\ChatterAction;
53-
use Webkul\Post\Filament\Resources\PostResource;
53+
use Webkul\Blog\Filament\Resources\PostResource;
5454

5555
class EditPost extends EditRecord
5656
{

src/master/getting-started/resources/viewing-record.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Actions\DeleteAction::make()
7070
```php
7171
<?php
7272

73-
namespace Webkul\Post\Filament\Resources\PostResource\Pages;
73+
namespace Webkul\Blog\Filament\Resources\PostResource\Pages;
7474

7575
use Barryvdh\DomPDF\Facade\Pdf;
7676
use Filament\Actions;
@@ -79,7 +79,7 @@ use Filament\Notifications\Notification;
7979
use Filament\Pages\SubNavigationPosition;
8080
use Filament\Resources\Pages\ViewRecord;
8181
use Webkul\Chatter\Filament\Actions\ChatterAction;
82-
use Webkul\Post\Filament\Resources\PostResource;
82+
use Webkul\Blog\Filament\Resources\PostResource;
8383

8484
class ViewPost extends ViewRecord
8585
{

0 commit comments

Comments
 (0)