Industry & Types template pages (#226)
* Industry & Types template pages * fix sitemap for templates
This commit is contained in:
@@ -21,7 +21,7 @@ class SitemapController extends Controller
|
||||
['/login', 0.4],
|
||||
['/register', 0.4],
|
||||
['/password/reset', 0.3],
|
||||
['/templates', 0.9],
|
||||
['/form-templates', 0.9],
|
||||
];
|
||||
|
||||
public function getSitemap(Request $request)
|
||||
@@ -31,6 +31,8 @@ class SitemapController extends Controller
|
||||
$sitemap->add($this->createUrl($url[0], $url[1]));
|
||||
}
|
||||
$this->addTemplatesUrls($sitemap);
|
||||
$this->addTemplatesTypesUrls($sitemap);
|
||||
$this->addTemplatesIndustriesUrls($sitemap);
|
||||
|
||||
return $sitemap->toResponse($request);
|
||||
}
|
||||
@@ -48,4 +50,20 @@ class SitemapController extends Controller
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private function addTemplatesTypesUrls(Sitemap $sitemap)
|
||||
{
|
||||
$types = json_decode(file_get_contents(resource_path('data/forms/templates/types.json')), true);
|
||||
foreach ($types as $type) {
|
||||
$sitemap->add($this->createUrl('/form-templates/types/' . $type['slug'], 0.7));
|
||||
}
|
||||
}
|
||||
|
||||
private function addTemplatesIndustriesUrls(Sitemap $sitemap)
|
||||
{
|
||||
$industries = json_decode(file_get_contents(resource_path('data/forms/templates/industries.json')), true);
|
||||
foreach ($industries as $industry) {
|
||||
$sitemap->add($this->createUrl('/form-templates/industries/' . $industry['slug'], 0.7));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,20 @@ class TemplateController extends Controller
|
||||
$limit = (int) $request->get('limit');
|
||||
}
|
||||
|
||||
$templates = Template::where('publicly_listed', true)
|
||||
->when(Auth::check(), function ($query) {
|
||||
$onlyMy = false;
|
||||
if ($request->offsetExists('onlymy') && $request->get('onlymy')) {
|
||||
$onlyMy = true;
|
||||
}
|
||||
|
||||
$templates = Template::limit($limit)
|
||||
->when(Auth::check() && !$onlyMy, function ($query) {
|
||||
$query->where('publicly_listed', true);
|
||||
$query->orWhere('creator_id', Auth::id());
|
||||
})
|
||||
->when(Auth::check() && $onlyMy, function ($query) {
|
||||
$query->where('creator_id', Auth::id());
|
||||
})
|
||||
->orderByDesc('created_at')
|
||||
->limit($limit)
|
||||
->get();
|
||||
|
||||
return FormTemplateResource::collection($templates);
|
||||
|
||||
Reference in New Issue
Block a user