route()->getName()); $model = $route[1]; $class = 'App\\Models\\' .ucfirst($model); $errors = []; $instances = $class::fetchAll($request, $paginate); foreach ($instances as $i) { $i->setDataTree(); } return response()->json([$model => $instances, 'status' => 'OK'], 200); } catch (\Exception $e) { Log::debug($e->getMessage() . ' ' .$e->getFile() . ' ' .$e->getLine()); return response()->json(['status' => 'ERROR', 'message' => $e->getMessage(), 'errors' => $errors], 404); } } }