Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined relationship [sender] on model [Nahid\Talk\Messages\Message]. #100

Open
x1mdev opened this issue Nov 22, 2017 · 4 comments
Open

Comments

@x1mdev
Copy link
Contributor

x1mdev commented Nov 22, 2017

Hi, i'm trying to implement Talk into my project but i'm getting this error:

RelationNotFoundExceptionCall to undefined relationship [sender] on model [Nahid\Talk\Messages\Message].
--
in RelationNotFoundException.php (line 34)
at RelationNotFoundException::make(object(Message), 'sender')in Builder.php (line 546)
at Builder->Illuminate\Database\Eloquent\{closure}()
at call_user_func(object(Closure))in Relation.php (line 89)
at Relation::noConstraints(object(Closure))in Builder.php (line 548)
at Builder->getRelation('sender')in Builder.php (line 516)
at Builder->eagerLoadRelation(array(object(Message)), 'sender', object(Closure))in Builder.php (line 496)
at Builder->eagerLoadRelations(array(object(Message)))in Builder.php (line 464)
at Builder->get(array('*'))in Relation.php (line 154)
at Relation->get()in Relation.php (line 143)

This happens when I try to send a message to a user.

I could not find the issue in my project, so I installed a fresh nahid/talk-example and configured it as told.

The above error is copied from the error page I got in the talk-example application again trying to send a message->does not work-> refresh page-> get error.
It also happens when i return to /home (in talk-example) and try to send message to another user.

Anyone else had this issue?

@c2gahlot
Copy link

c2gahlot commented Nov 24, 2017

Same issue.

[2017-11-24 11:03:14] local.ERROR: Call to undefined relationship [sender] on model [Nahid\Talk\Messages\Message]. {"userId":1,"email":"[email protected]","exception":"[object] (Illuminate\Database\Eloquent\RelationNotFoundException(code: 0): Call to undefined relationship [sender] on model [Nahid\Talk\Messages\Message]. at /home/vagrant/store/vendor/laravel/framework/src/Illuminate/Database/Eloquent/RelationNotFoundException.php:34)

Please Help!

@ABwabsolute
Copy link

ABwabsolute commented Dec 6, 2017

Same here when i try to get all the messages by User id and pass them to view.

$myMessages = Talk::getMessagesByUserId(Auth::user()->id);
return view('messaging.list', compact('myMessages', 'myMessages'));

EDIT:
Found The Solution for my case:

Added to UserModel

  • use Illuminate\Database\Eloquent\SoftDeletes;
  • use SoftDeletes;
  • protected $dates = [..., 'deleted_at'];

Check this Docs https://laravel.com/docs/5.1/eloquent#soft-deleting

Don't forget the new migration for the SoftDeletes...

@shrihub
Copy link

shrihub commented Dec 13, 2017

Same issue. Kindly resolve.

@jtallinger
Copy link

If you dont want to use softdelete on your user model, then just add a dummy withTrash function in the user model:
public function scopeWithtrashed($query)
{
return $query;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants