astroanu said:
you forgot the get()
$maxVal = model::where(x)->max(column)->get();
That doesn't work. Max gives an integer result. And you can't call ->get() on a number. You get the error 'call to a member function get() on a non-object'.
I hate to bump, but I'm still lost on how to make this work a week later here.
I don't know if this is the 'right' solution or the best way. But it seems to work for me for now. So I'll post it in case it helps someone else. Pretty sure there has to be a better way, but maybe not.
What I did, was check if the results were numeric. If they are numeric, then add stuff, if not numeric (when it returns Builder), then I make different math.
if (is_numeric($maxVal)) {
$nextNum = $maxVal + 1;
} else {
$maxVal = 0;
$nextNum = 1;
If there is a better way, please feel free to chime in!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community