Currently my database setup looks like this:
Users table (User model):
- id,
Discounts table (Coupon model)
- code
- amount
Now, I decided to create a pivot table, where I will store a discount value for a user. One user will have a single discount value. For this, I created PractitionerVoucher model with this table setup:
- voucher_id
- practitioner_id
Upon creating a Coupon record, I save the coupon_id (voucher_id in this case) and the user_id (practitioner_id in this case) values to PractitionerVoucher table. Now, my question is, how do I get the User record from the Coupon model? For example:
$coupon = Coupon::first();
$coupon->practitioner;
I tried to create hasOneThrough relation on Coupon model, but no luck so far. This is what I tried:
public function practitioner(){
return $this->hasOneThrough(User::class, PractitionerVoucher::class, 'practitioner_id', 'id');
}
Using this relation, I get no query results for the User model. This is how my database records look like:
What am I doing wrong here? Any help is appreciated.

