I have column named receiver_ids with bigint array type and -sender_id- in PostgreSQL. Receiver_ids column contains ids of users.
Ex: {1,4,6,2,3}
I wanna create a many to many relationship to get received and sent mails of an user. I'm getting error with usage below. Some suggestions would be nice.
Mail model:
public function receivers()
{
return $this->belongsToMany('AppModelsUser');
}
public function sender()
{
return $this->belongsTo('AppModelsUser');
}
User model:
public function receivedmails()
{
return $this->hasMany('AppModelsMail', 'receiver_ids');
}
public function sentmails()
{
return $this->hasMany('AppModelsMail', 'sender_id');
}
UserController:
public function mails()
{
$action = User::with('receivedmails')->get();
return $action;
}
The error that i get:
Undefined function: 7 ERROR: operator does not exist: bigint[] = integer
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
question from:
https://stackoverflow.com/questions/65903687/laravel-eloquent-with-postgresql-which-ids-in-bigint-array 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…