mirror of
https://github.com/wearepixel/laravel-comments.git
synced 2026-11-14 14:02:04 +00:00
Update config with the new features
This commit is contained in:
@@ -47,7 +47,7 @@ php artisan vendor:publish --provider="BeyondCode\Comments\CommentsServiceProvid
|
|||||||
|
|
||||||
To let your models be able to receive comments, add the `HasComments` trait to the model classes.
|
To let your models be able to receive comments, add the `HasComments` trait to the model classes.
|
||||||
|
|
||||||
``` php
|
```php
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
@@ -146,10 +146,36 @@ $comment = BeyondCode\Comments\Comment::first();
|
|||||||
$comment->commentAsUser($user, "Hey there!");
|
$comment->commentAsUser($user, "Hey there!");
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Deleting Replies
|
||||||
|
|
||||||
|
When you delete a comment, you may optionally want to delete all it's nested comments (replies). To do optionally enable this feature, set the `delete_replies_along_comments` config property in the `configs/comments.php` file to `true`.
|
||||||
|
|
||||||
|
### Events
|
||||||
|
|
||||||
|
When a new comment is added the `BeyondCode\Comments\Events\CommentAdded` event will be dispatched.
|
||||||
|
When a comment is deleted the `BeyondCode\Comments\Events\CommentDeleted` event will be dispatched.
|
||||||
|
you can listen to these event and do other things as your requirements call for.
|
||||||
|
|
||||||
|
_App\Providers\EventServiceProvider_
|
||||||
|
|
||||||
|
```php
|
||||||
|
use BeyondCode\Comments\Events\CommentAdded;
|
||||||
|
use BeyondCode\Comments\Events\CommentDeleted;
|
||||||
|
use App\Listeners\InformAdmin;
|
||||||
|
|
||||||
|
protected $listen = [
|
||||||
|
CommentAdded::class => [
|
||||||
|
InformAdmin::class,
|
||||||
|
],
|
||||||
|
CommentDeleted::class => [
|
||||||
|
InformAdmin::class,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
```
|
||||||
|
|
||||||
### Testing
|
### Testing
|
||||||
|
|
||||||
``` bash
|
```bash
|
||||||
composer test
|
composer test
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -167,8 +193,8 @@ If you discover any security related issues, please email marcel@beyondco.de ins
|
|||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
- [Marcel Pociot](https://github.com/mpociot)
|
- [Marcel Pociot](https://github.com/mpociot)
|
||||||
- [All Contributors](../../contributors)
|
- [All Contributors](../../contributors)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -19,4 +19,4 @@ return [
|
|||||||
* Determines if replies will be deleted when comments are deleted
|
* Determines if replies will be deleted when comments are deleted
|
||||||
*/
|
*/
|
||||||
'delete_replies_along_comments' => false,
|
'delete_replies_along_comments' => false,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -19,4 +19,4 @@ class CommentAdded implements ShouldDispatchAfterCommit
|
|||||||
public Comment $comment,
|
public Comment $comment,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user