Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 1 year ago.
0

I don't really understand how i can use variable from controller in model?

public function getPostsTotalSumAttribute($start)
	{
		return $this->hasOne('invoiceRows','productId','id')->selectRaw('productId, sum(amount*quantity) as postsTotalSum')->where('created_at','>=',$start)->groupBy('productId')->orderBy('taxPercent','ASC');
	}

How i can set $start variable in controller?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

0lide 0lide Joined 13 May 2014

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.

© 2024 Laravel.io - All rights reserved.