Industry & Types template pages (#226)

* Industry & Types template pages

* fix sitemap for templates
This commit is contained in:
formsdev
2023-10-25 00:25:15 +05:30
committed by GitHub
parent 4614dc0f18
commit 2d0d4a65c2
9 changed files with 618 additions and 54 deletions

View File

@@ -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);