Currently I have this "ContactLine" model that is extending from the User model
class ContactLine extends User
{
use HasFactory;
protected $table = 'users';
public function organizations(): BelongsToMany
{
return $this->belongsToMany(Organization::class);
}
}
I have written a test controller where I am trying to inject the ContactLine into the method via route model binding.
class TestContactlineControler extends Controller
{
public function __invoke(ContactLine $contact)
{
return $contact;
}
}
However I am currently getting this error whenever I try to hit the route for this controller
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'incidents.contact_line_id' in 'where clause' (SQL: select count(*) as aggregate from `incidents` where `incidents`.`contact_line_id` = 1 and `incidents`.`contact_line_id` is not null and `closed_at` is null and `incidents`.`deleted_at` is null)
However if I change the controller to inject the User model instead it works fine. In my user model I have this relationship which I think is causing the error.
public function incidents(): HasMany
{
return $this->hasMany(Incident::class);
}
However I thought setting the table to users in either User or ContactLine model should make it so it looks for incidents.user_id not incidents.contact_line_id