File: D:/HostingSpaces/SBogers79/artofeinstein.be/app/Komma/Routes/RouteRepository.php
<?php
namespace Komma\Routes;
class RouteRepository
{
/**
* @param array $groups
* @param float $weight_from
*/
public function routesForSitemap($minWeight = 0.1)
{
// Select from routes
$query = \DB::table('routes')
->select('routes.*',
'page_translations.page_id',
'page_translations.name as page_name'
);
// Join other tables
$query = $this->joinTranslation($query, 'page_translations', 'Komma\Kms\Pages\Models\PageTranslation');
// Get routes
return $query->where('sitemap_weight', '>=', $minWeight)
->orderBy('routes.sitemap_weight', 'desc')
->groupBy('route')
->get();
}
/**
* @param $query
* @return mixed
*/
private function joinTranslation($query, $table, $type)
{
return $query->leftJoin($table, function($join) use ($table,$type)
{
$join->on($table . '.id', '=', 'routes.routable_id')
->where('routes.routable_type', '=', $type);
});
}
}