Model Binding/Extending

In my users resource, I am setting a fieldset for my relation to my Address model. However, the function address() exists on my project level User model, where as it's searching my auth package User. Is there a way to tell it which User model to use, I already have the binding in the AppServiceProvider of alravel
1 Reply
Jamie Cee
Jamie Cee7mo ago
For context... My UserResource
Fieldset::make('Address')
->relationship('address')
->schema([
Forms\Components\TextInput::make('city'),
Forms\Components\TextInput::make('state'),
Forms\Components\TextInput::make('zip'),
]),
Fieldset::make('Address')
->relationship('address')
->schema([
Forms\Components\TextInput::make('city'),
Forms\Components\TextInput::make('state'),
Forms\Components\TextInput::make('zip'),
]),
The function address() is on my extended model
class User extends ModelsUser
{
/**
* User has one address
*
* @return HasOne
*/
public function address(): HasOne
{
return $this->hasOne(Address::class);
}
class User extends ModelsUser
{
/**
* User has one address
*
* @return HasOne
*/
public function address(): HasOne
{
return $this->hasOne(Address::class);
}
But im getting:
Call to undefined method My\Package\Models\User::address()
Call to undefined method My\Package\Models\User::address()
May have found my answer... Gonna test everything else Didn't notice the defined model in my resource being the package User