fix searching textures in skin library
This commit is contained in:
parent
5ea1187f2a
commit
55990f24be
@ -59,9 +59,12 @@ class SkinlibController extends Controller
|
||||
})
|
||||
->when($user, function (Builder $query, User $user) {
|
||||
if (!$user->isAdmin()) {
|
||||
return $query
|
||||
->where('public', true)
|
||||
->orWhere('uploader', $user->uid);
|
||||
// use closure-style `where` clause to lift up SQL priority
|
||||
return $query->where(function (Builder $query) use ($user) {
|
||||
$query
|
||||
->where('public', true)
|
||||
->orWhere('uploader', $user->uid);
|
||||
});
|
||||
}
|
||||
}, function (Builder $query) {
|
||||
// show public textures only to anonymous visitors
|
||||
|
@ -55,6 +55,11 @@ class SkinlibControllerTest extends TestCase
|
||||
['tid' => $steve->tid, 'nickname' => $steve->owner->nickname],
|
||||
],
|
||||
]);
|
||||
$user = factory(User::class)->create();
|
||||
$list = $this->actingAs($user)
|
||||
->getJson('/skinlib/list?keyword=a')
|
||||
->decodeResponseJson('data');
|
||||
$this->assertCount(1, $list);
|
||||
|
||||
// with uploader
|
||||
$this->getJson('/skinlib/list?uploader='.$steve->uploader)
|
||||
|
Loading…
Reference in New Issue
Block a user