Skip to content

Commit 76c6210

Browse files
committed
Adds readme
1 parent c288381 commit 76c6210

File tree

1 file changed

+125
-9
lines changed

1 file changed

+125
-9
lines changed

README.md

Lines changed: 125 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
# Add comments to your Filament Resources.
1+
# Filament Comments
22

33
[![Latest Version on Packagist](https://img.shields.io/packagist/v/parallax/filament-comments.svg?style=flat-square)](https://packagist.org/packages/parallax/filament-comments)
4-
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/parallax/filament-comments/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/parallax/filament-comments/actions?query=workflow%3Arun-tests+branch%3Amain)
5-
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/parallax/filament-comments/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/parallax/filament-comments/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
4+
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
65
[![Total Downloads](https://img.shields.io/packagist/dt/parallax/filament-comments.svg?style=flat-square)](https://packagist.org/packages/parallax/filament-comments)
76

7+
Add comments to your Filament Resources.
88

9-
10-
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
9+
![logo](/assets/filament-comments.jpg)
1110

1211
## Installation
1312

14-
You can install the package via composer:
13+
Install the package via composer:
1514

1615
```bash
1716
composer require parallax/filament-comments
1817
```
1918

20-
You can publish and run the migrations with:
19+
Publish and run the migrations:
2120

2221
```bash
2322
php artisan vendor:publish --tag="filament-comments-migrations"
@@ -30,15 +29,132 @@ You can publish the config file with:
3029
php artisan vendor:publish --tag="filament-comments-config"
3130
```
3231

32+
You can publish the language file with:
33+
34+
```bash
35+
php artisan vendor:publish --tag="filament-comments-lang"
36+
```
37+
3338
Optionally, you can publish the views using
3439

3540
```bash
3641
php artisan vendor:publish --tag="filament-comments-views"
3742
```
3843

39-
## Usage
44+
## Quickstart
45+
46+
### 1. Add model trait
47+
48+
First open the eloquent model you wish to add Filament Comments to.
49+
50+
```php
51+
namespace App\Models;
52+
53+
use Parallax\FilamentComments\Models\Traits\HasFilamentComments;
54+
55+
class Product extends Model
56+
{
57+
use HasFilamentComments;
58+
}
59+
```
60+
61+
### 2. Add comments to Filament Resource
62+
63+
There are 3 ways of using this plugin in your Filament Resources:
64+
65+
#### 1. Page actions
66+
67+
Open the page where you want the comments action to appear, this will most likely be the `View` resource page.
68+
69+
Add the `CommentsAction` to the `getHeaderActions()` method.
70+
71+
```php
72+
<?php
73+
74+
namespace App\Filament\Resources\ProductResource\Pages;
75+
76+
use Parallax\FilamentComments\Actions\CommentsAction;
77+
78+
class ViewProduct extends ViewRecord
79+
{
80+
protected function getHeaderActions(): array
81+
{
82+
return [
83+
CommentsAction::make(),
84+
];
85+
}
86+
}
87+
```
88+
89+
You may customise the page action as you would any other action.
90+
91+
#### 2. Table actions
4092

41-
TODO
93+
Open the resource where you want the comments table action to appear.
94+
95+
Add the `CommentsAction` to the `$table->actions()` method.
96+
97+
```php
98+
<?php
99+
100+
namespace App\Filament\Resources;
101+
102+
use Parallax\FilamentComments\Tables\Actions\CommentsAction;
103+
104+
class ProductResource extends Resource
105+
{
106+
public static function table(Table $table): Table
107+
{
108+
return $table
109+
->actions([
110+
CommentsAction::make(),
111+
]);
112+
}
113+
}
114+
```
115+
116+
You may customise the table action as you would any other action.
117+
118+
#### 3. Infolist entry
119+
120+
It's also possible to use the comments component within your infolist.
121+
122+
Add the `CommentsEntry` to the `$infolist->schema()` method.
123+
124+
```php
125+
<?php
126+
127+
namespace App\Filament\Resources;
128+
129+
use Parallax\FilamentComments\Infolists\Components\CommentsEntry;
130+
131+
class ProductResource extends Resource
132+
{
133+
public static function infolist(Infolist $infolist): Infolist
134+
{
135+
return $infolist
136+
->schema([
137+
CommentsEntry::make('filament_comments'),
138+
]);
139+
}
140+
}
141+
```
142+
143+
Please note that this cannot be used in combination with a comments action on the same page.
144+
145+
## Authorisation
146+
147+
By default, all users can view & create comments as well as only delete their own comments.
148+
149+
If you would like to change this behaviour you can create your own eloquent model policy for the `Parallax\FilamentComments\Models\FilamentComment` model.
150+
151+
You should define the policy class in the `filament-comments` config file.
152+
153+
```php
154+
return [
155+
'model_policy' => \Parallax\FilamentComments\Policies\FilamentCommentPolicy::class,
156+
];
157+
```
42158

43159
## Changelog
44160

0 commit comments

Comments
 (0)