Fix the template API (#234)
This commit is contained in:
parent
cf0e923650
commit
8de1c94291
|
@ -24,12 +24,18 @@ class TemplateController extends Controller
|
|||
}
|
||||
|
||||
$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) {
|
||||
->when(Auth::check(), function ($query) use ($onlyMy) {
|
||||
if ($onlyMy) {
|
||||
$query->where('creator_id', Auth::id());
|
||||
} else {
|
||||
$query->where(function ($query) {
|
||||
$query->where('publicly_listed', true)
|
||||
->orWhere('creator_id', Auth::id());
|
||||
});
|
||||
}
|
||||
})
|
||||
->when(!Auth::check(), function ($query) {
|
||||
return $query->publiclyListed();
|
||||
})
|
||||
->orderByDesc('created_at')
|
||||
->get();
|
||||
|
|
Loading…
Reference in New Issue