Support the ongoing development of Laravel.io →
posted 9 years ago
Eloquent

Hi there

I have two tables: Subscriptions and Partners.

How can I use Eloquent to multiply two fields from differente tables?

Subscription::with('partner')
->select('partner_id', DB::raw('SUM(amount)* <Partner Commission> AS total'))
->groupBy('partner_id')
->orderBy('total','desc')
->get();

How can I access the Commission fields from the Partner table?

Last updated 3 years ago.
0

if your column was called commission on the partner table just use table name . column

eg: partner.commission_column

0

Sign in to participate in this thread!

Eventy

Your banner here too?

jclaro jclaro Joined 28 Jun 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.