B
B
BonBon Slick2017-07-31 16:49:31
Laravel
BonBon Slick, 2017-07-31 16:49:31

Laravel relations, return dialog all participants?

protected $fillable = [
        'user_one',
        'user_two',
    ];

    public function participants()
    {
      return  $this->????(User::class); 
    }

Please tell me how to return the first and second user at once?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ramm, 2017-07-31
@BonBonSlick

protected $fillable = [
        'user_one',
        'user_two',
    ];

    public function userOne()
    {
      return  $this->belongsTo(User::class, 'user_one'); 
    }

    public function userTwo()
    {
      return  $this->belongsTo(User::class, 'user_two'); 
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question