laravelista / comments

Native comments for your Laravel application.
MIT License
745 stars 144 forks source link

Comments on User Model #90

Closed dgillier closed 4 years ago

dgillier commented 4 years ago

Hello,

Just installed this package under Laravel 7.x, and trying to add comments to User model (users will comments other users...) but having errors...

Add the Commenter, Commentable in the User Model: class User extends Authenticatable implements HasMedia { use SoftDeletes, Notifiable, HasApiTokens, HasMediaTrait, Auditable, Commenter, Commentable;

But having the following errors ??? Any help will be appreciated... Thanks, Denis

in /home/vagrant/Code/BMS/vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php (line 183) in /home/vagrant/Code/BMS/vendor/filp/whoops/src/Whoops/Run.php -> handle (line 296) in /home/vagrant/Code/BMS/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php -> handleException (line 363) in /home/vagrant/Code/BMS/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php -> renderExceptionWithWhoops (line 342) in /home/vagrant/Code/BMS/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php -> renderExceptionContent (line 326) in /home/vagrant/Code/BMS/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php -> convertExceptionToResponse (line 305) in /home/vagrant/Code/BMS/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php -> prepareResponse (line 210) Handler->render() in /home/vagrant/Code/BMS/app/Exceptions/Handler.php (line 53)

mabasic commented 4 years ago

I haven't done that myself, but I assume that you can't have both traits (commenter and commentable) on the same model since they have the same method comments.

I can't figure out the error message that you sent...

If you need to be able to let users comment on users you would have to create a new model for the same db table (maybe call it CommentableUser.php) and add trait commentable to it. Then on the User model add just trait Commenter. I hope that you can figure the rest yourself.

Let me know if you manage to do this.

dgillier commented 4 years ago

Thanks a lot, works !!!

Created a new model : <?php

namespace App;

use Illuminate\Database\Eloquent\Model; use Laravelista\Comments\Commentable;

class CommentableUser extends Model { use Commentable;

public $table = 'users’;

}

On 20 Apr 2020, at 17:20, Mario Bašić notifications@github.com wrote:

I haven't done that myself, but I assume that you can't have both traits (commenter and commentable) on the same model since they have the same method comments.

I can't figure out the error message that you sent...

If you need to be able to let users comment on users you would have to create a new model for the same db table (maybe call it CommentableUser.php) and add trait commentable to it. Then on the User model add just trait Commenter. I hope that you can figure the rest yourself.

Let me know if you manage to do this.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.