I have a static method in my User model which counts something, i am using a raw statement:
static function countOrders($userId)
{
$sql = "SOME CUSTOM-COMPLICATED QUERY";
$result = \DB::select( \DB::raw( $sql ) );
return $result; // <-- toArray() ? returns Exception!
}
Somewhere in my controller:
$orders = User::countOrders(*USER-ID*);
How can I get an array with records as arrays and not objects without modifying the global configuration for the FETCH method?