Here is what I'm trying to do..
I have a enquiries
table where job enquiries are stored. This stores a start address, and a finish address. Also stores predictive_price
which is set to null when an enquiry is added.
The predictive_price
is calculated dynamically and once the enquiry has been confirmed, the predictive_price
is then stored within the table. This is because that during an enquiry lifetime, it could change addresses, distances or the tariffs that are set. I do not want to keep updating the predictive_price
in the table everytime something has changed, it just allows for errors.
This is what I've done so far:
Inside my model Enquiries
I have a function:
public function predictive_price() {
return $this::calculatePredictivePrice();
}
This is then calling a method inside a trait
where my model references such use EnquiriesHelper;
Inside the EnqEnquiriesHelper
I have the following:
public function scopeCalculatePredictivePrice()
{
return 1;
}
But when trying to output predictive_price
is just says null
which is what is stored within the database. Is there anyway (using methods) I can override what is being returned in predictive_price
?
$this::calculatePredictivePrice() to $this->calculatePredictivePrice() maybe ?
It shouldn't be a scope.Try removing the scope before the functions name
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.