-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
App\Models\User::name must return a relationship instance. #6
Comments
Does your user model already have a name() method or interface that returns a relationship? Mine only ever expects to return a string, so I find your error odd. Can you show more of your stack trace? I'd like to know if the error is being thrown from my package or your app in general. |
Yes, I only have one public function name() in App/Models/User Stacktrace :
|
Did you fix it? My package requires your provider models to implement my contract, which requires the |
I'm still working on it. No your fonction name() is the only one in my user's model.
|
Can you share your user model then? Also, what happens if you grab a user model and |
This is my user model : `<?php namespace App\Models; use Illuminate\Contracts\Auth\MustVerifyEmail; class User extends Authenticatable implements MessengerProvider, Searchable
} |
dd(strip_tags(ucwords($this->username))) works and return my username. |
What are these coming from?
|
I know nothing about jetstream, but looking at the stacktrace, my provider resource will return your base model, ( https://github.com/RTippin/messenger/blob/master/src/Http/Resources/ProviderResource.php#L77 ) and laravel is calling some jetstream code for your picture, which seems to reference name, which you do not even have on your model as you changed that (lname, fname, username). https://github.com/laravel/jetstream/blob/2.x/src/HasProfilePhoto.php#L69 |
InvalidArgumentException The given provider { App\Models\User } must implement the interface RTippin\Messenger\Contracts\MessengerProvider at vendor/rtippin/messenger/src/Messenger.php:92
2 app/Providers/MessengerServiceProvider.php:28
|
@tapang786 Please do not reply to old issues that have nothing in common with your issue at hand, on top of opening a new issue. |
Hi,
Thanks for you amazing work ! I trying to make it work on one of my project !
Sadly I get stuck with this error.
[2021-03-18 20:27:02] local.ERROR: App\Models\User::name must return a relationship instance. {"userId":26,"exception":"[object] (LogicException(code: 0): App\\Models\\User::name must return a relationship instance. at /Users/sylvain/Documents/dev/obpro/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php:464)
I put that in my User Model because I use Username instead of 'name'
public function name(): string { return strip_tags(ucwords($this->username)); }
Any idea ? Thanks
The text was updated successfully, but these errors were encountered: