mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-11 14:10:06 +01:00
fix: fix private pastes sometimes showing in archive
This commit is contained in:
parent
c42b22123e
commit
353991a6a8
2 changed files with 12 additions and 11 deletions
|
@ -23,12 +23,12 @@ $pastes = Paste::with([
|
|||
->where('hidden', false)
|
||||
->whereRaw("((expiry IS NULL) OR ((expiry != 'SELF') AND (expiry > NOW())))");
|
||||
|
||||
if (!empty($_GET['q']) && is_string($_GET['q'])) {
|
||||
$tags = explode(',', $_GET['q']);
|
||||
$pastes = $pastes->whereHas('tags', function($query) use ($tags) {
|
||||
$query->where('name', $tags);
|
||||
});
|
||||
}
|
||||
// if (!empty($_GET['q']) && is_string($_GET['q'])) {
|
||||
// $tags = explode(',', $_GET['q']);
|
||||
// $pastes = $pastes->whereHas('tags', function($query) use ($tags) {
|
||||
// $query->where('name', $tags);
|
||||
// });
|
||||
// }
|
||||
|
||||
$pastes = $pastes->orderBy('id', 'desc')->get();
|
||||
|
||||
|
|
|
@ -33,15 +33,16 @@ $pastes = Paste::with([
|
|||
->where('hidden', false)
|
||||
->whereRaw("((expiry IS NULL) OR ((expiry != 'SELF') AND (expiry > NOW())))");
|
||||
|
||||
|
||||
if (!empty($filter_value)) {
|
||||
if ($filter_value === 'untagged') {
|
||||
$pastes = $pastes->doesntHave('tags');
|
||||
} else {
|
||||
$pastes = $pastes->where('title', 'LIKE', '%' . escapeLikeQuery($filter_value) . '%')
|
||||
->orWhereHas('tags', function($q) use ($filter_value) {
|
||||
$q->where('name', 'LIKE', '%' . escapeLikeQuery($filter_value) . '%');
|
||||
});
|
||||
$pastes = $paste->where(function($query) {
|
||||
$query->where('title', 'LIKE', '%' . escapeLikeQuery($filter_value) . '%')
|
||||
->orWhereHas('tags', function($q) use ($filter_value) {
|
||||
$q->where('name', 'LIKE', '%' . escapeLikeQuery($filter_value) . '%');
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue