(Update) Add Search By Uploader

- Faceted Torrent Search System now allows search by uploader and will
ONLY show torrents by that uploader that are NOT anonymous.
- closes #212
- Search by genre is not possible at this time until the meta data
system is reworked. Genre search is planned and will be added once meta
system is reworked.
This commit is contained in:
HDVinnie
2018-03-13 19:19:21 -04:00
parent 84f7eb1935
commit 2c0d080ff6
2 changed files with 25 additions and 1 deletions
@@ -363,6 +363,7 @@ class TorrentController extends Controller
{
$user = Auth::user();
$search = $request->get('search');
$uploader = $request->get('uploader');
$imdb = $request->get('imdb');
$tvdb = $request->get('tvdb');
$tmdb = $request->get('tmdb');
@@ -385,12 +386,23 @@ class TorrentController extends Controller
$search .= '%' . $term . '%';
}
$usernames = explode(' ', $uploader);
$uploader = '';
foreach ($usernames as $username) {
$uploader .= '%' . $username . '%';
}
$torrent = $torrent->newQuery();
if ($request->has('search') && $request->get('search') != null) {
$torrent->where('name', 'like', $search);
}
if ($request->has('uploader') && $request->get('uploader') != null) {
$match = User::where('username', 'like', $uploader)->firstOrFail();
$torrent->where('user_id', $match->id)->where('anon', 0);
}
if ($request->has('imdb') && $request->get('imdb') != null) {
$torrent->where('imdb', $imdb);
}
+13 -1
View File
@@ -31,6 +31,12 @@
{{ Form::text('search',null,['id'=>'search','placeholder'=>'Name or Title','class'=>'form-control']) }}
</div>
</div>
<div class="form-group">
<label for="uploader" class="col-sm-1 label label-default">Uploader</label>
<div class="col-sm-9">
{{ Form::text('uploader',null,['id'=>'uploader','placeholder'=>'Uploader Username','class'=>'form-control']) }}
</div>
</div>
<div class="form-group">
<label for="imdb" class="col-sm-1 label label-default">Number</label>
<div class="col-sm-2">
@@ -227,6 +233,7 @@
function faceted(page){
var csrf = "{{ csrf_token() }}";
var search = $("#search").val();
var uploader = $("#uploader").val();
var imdb = $("#imdb").val();
var tvdb = $("#tvdb").val();
var tmdb = $("#tmdb").val();
@@ -307,7 +314,7 @@
xhr = $.ajax({
url: 'filterTorrents',
data: {_token:csrf,search:search,imdb:imdb,tvdb:tvdb,tmdb:tmdb,mal:mal,categories:categories,types:types,freeleech:freeleech,doubleupload:doubleupload,featured:featured,stream:stream,highspeed:highspeed,sd:sd,alive:alive,dying:dying,dead:dead,sorting:sorting,direction:direction,page:page,qty:qty},
data: {_token:csrf,search:search,uploader:uploader,imdb:imdb,tvdb:tvdb,tmdb:tmdb,mal:mal,categories:categories,types:types,freeleech:freeleech,doubleupload:doubleupload,featured:featured,stream:stream,highspeed:highspeed,sd:sd,alive:alive,dying:dying,dead:dead,sorting:sorting,direction:direction,page:page,qty:qty},
type: 'get',
beforeSend:function(){
$("#result").html('<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i>')
@@ -331,6 +338,11 @@
faceted();
})
</script>
<script>
$("#uploader").keyup(function(){
faceted();
})
</script>
<script>
$("#imdb").keyup(function(){
faceted();