Team-Tea-Time / laravel-forum

A slim, lean forum package designed for quick and easy integration in Laravel projects
https://laravel-forum.teamteatime.net/
MIT License
601 stars 165 forks source link

Working with Softdeleted Users. #169

Closed Sentences closed 6 years ago

Sentences commented 7 years ago

Hey there. Im using Laravel 5.1.46 When i work with softdeleted users, i get an Exception

Trying to get property of non-object

To solve this, i have updated the HasAuthor Trait from

return $this->belongsTo(config('forum.integration.user_model'));

to

return $this->belongsTo(config('forum.integration.user_model'))->withTrashed();

Please add this to the options.

Gummibeer commented 7 years ago

But it should be, better, something like:

$model = config('forum.integration.user_model');
if(method_exists($model, 'withTrashed')) {
    return $this->belongsTo($model)->withTrashed();
}
return $this->belongsTo($model);

Because if someone doesn't use the SoftDeletes trait it will crash cause of Call to undefined method.

Riari commented 6 years ago

Fixed in b46766e102537729424894a447c7d8f43f44316b.