Is it possible to call function from model into the controller in foreach loop?
This is my model
class Order extends Eloquent
{
public static function getData($data)
{
// function code
}
}
This is what I'm trying in my controller
$get = Order::all();
foreach ($get->getData($get->details) as $itemId => $details) {
dd($details);
}
This produce error
Error: Call to undefined method Illuminate\Database\Eloquent\Collection::getData()
I've tried exact same code in my blade and there is working without any issue.
So, how I'm suppose to call and use the function in my controller?