I suggest you make your views as dumb as possible. What I mean by that is to do all calculations on the controller and only pass the finished data to the view. Ideally, your views contain as little logic as possible and should only concern themselves with presenting the data to the browser. Something like this should illustrate my point:
// Strive to make views as simple as this.@foreach($gradesas$grade){{$grade}}@endforeach// And do all the heavy lifting in the controllerpublicfunctionindex(){$grades=Grade::someQuery()->all();$computed=$grades->map(function($grade){/** do your work here */});returnview('grades.index',['grades'=>$computed]);}
If you'd like to share some code, we'd be happy to help some more!
I suggest you make your views as dumb as possible. What I mean by that is to do all calculations on the controller and only pass the finished data to the view. Ideally, your views contain as little logic as possible and should only concern themselves with presenting the data to the browser. Something like this should illustrate my point:
If you'd like to share some code, we'd be happy to help some more!
Thanks I added the code to the post.