Target [Illuminate\Database\Eloquent\Model] is not instantiable

I have the UserResource, which I guess, working all fine sometime before, however I find now I am not abe to create a new User (Target [Illuminate\Database\Eloquent\Model] is not instantiable.) The EditUser works fine though How to solve this? Please help asap
Solution:
I think the issue is this part: getLocationIdGroup(fn (Model $user): bool => $user->id == auth()->user()->id), What does that method to? Where/when is the callback evaluated? You are probably not passing the user model...
Jump to solution
8 Replies
Dennis Koch
Dennis Koch4mo ago
Can you share the full stack trace? And maybe the UserResource
bhattji
bhattjiOP4mo ago
This is my model <?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Spatie\Permission\Traits\HasRoles; use Illuminate\Database\Eloquent\SoftDeletes; class User extends Authenticatable { use HasFactory, Notifiable, HasRoles, SoftDeletes; /** * The attributes that are mass assignable. * * @var array<int, string> */ protected $fillable = [ 'country_id', 'state_id', 'city_id', 'name', 'email', 'is_disabled', 'isd', 'cell_number', 'password', 'avatar_url', 'original_avatar_url', 'area', 'pincode', 'address', 'landmark', 'birth_date', 'wedding_date', ];
bhattji
bhattjiOP4mo ago
Dennis Koch
Dennis Koch4mo ago
I was asking for a stack trace and the UserResource, not the User Model 🤷🏼‍♂️
bhattji
bhattjiOP4mo ago
Pardon me I don't know, what is stack trace, but here is the UserResource
Dennis Koch
Dennis Koch4mo ago
The stack trace is the thing that comes with the error message and tells us where it happened. If you are still on an older version of Laravel you have the Flare error page which has a share button. Otherwise you can use this plugin to share it: https://github.com/spatie/laravel-error-share
GitHub
GitHub - spatie/laravel-error-share: Share your Laravel errors
Share your Laravel errors. Contribute to spatie/laravel-error-share development by creating an account on GitHub.
Solution
Dennis Koch
Dennis Koch4mo ago
I think the issue is this part: getLocationIdGroup(fn (Model $user): bool => $user->id == auth()->user()->id), What does that method to? Where/when is the callback evaluated? You are probably not passing the user model
bhattji
bhattjiOP4mo ago
Excellent, that is the issue. The issue was/is, while in Create mode, it was not able to file the $user (and was working fine in Edit mode) How do determine, whether the state is Create or Edit? I guess there is some property, but I am not able to remember
Want results from more Discord servers?
Add your server