Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
511 views
in Technique[技术] by (71.8m points)

php - Laravel Eloquent with PostgreSQL which ids in bigint array

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...