Answer the question
In order to leave comments, you need to log in
How to add an additional attribute to the model?
As an example, I give an elementary situation: it is necessary in the simplest form to calculate the difference between two fields of the table and display the result in a separate manual / virtual / non-existent attribute.
Something like this:
public function getSourceIncomingAttribute($item) {
$this->attributes['total_profit'] = $this->attributes['source_incoming'] - $this->attributes['source_selfcost'];
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question