mirror of
https://github.com/wearepixel/laravel-comments.git
synced 2026-11-14 14:02:04 +00:00
Added example for nesting comments to Readme
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
# Add comments to your Laravel application
|
# Add comments to your Laravel application
|
||||||
|
|
||||||
[](https://packagist.org/packages/beyondcode/laravel-comments)
|
[](https://packagist.org/packages/beyondcode/laravel-comments)
|
||||||
[](https://travis-ci.org/beyondcode/laravel-comments)
|
|
||||||
[](https://scrutinizer-ci.com/g/beyondcode/laravel-comments)
|
|
||||||
[](https://packagist.org/packages/beyondcode/laravel-comments)
|
[](https://packagist.org/packages/beyondcode/laravel-comments)
|
||||||
|
|
||||||
Add the ability to associate comments to your Laravel Eloquent models. The comments can be approved and nested.
|
Add the ability to associate comments to your Laravel Eloquent models. The comments can be approved and nested.
|
||||||
@@ -115,9 +113,9 @@ class User extends Authenticatable implements Commentator
|
|||||||
*/
|
*/
|
||||||
public function needsCommentApproval($model): bool
|
public function needsCommentApproval($model): bool
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -139,6 +137,16 @@ $approved = $post->comments()->approved()->get();
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Nesting Comments
|
||||||
|
|
||||||
|
`BeyondCode\Comments\Comment` itself implements the `HasComments` trait, so you can comment on a comment and therefore nest them:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$comment = BeyondCode\Comments\Comment::first();
|
||||||
|
$comment->commentAsUser($user, "Hey there!");
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Testing
|
### Testing
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
|
|||||||
Reference in New Issue
Block a user