mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-23 19:50:40 -05:00
Merge branch '7.x.x' into Refund-System
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author Roardom <roardom@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum Occupations: int
|
||||
{
|
||||
case CREATOR = 1;
|
||||
case DIRECTOR = 2;
|
||||
case WRITER = 3;
|
||||
case PRODUCER = 4;
|
||||
case COMPOSER = 5;
|
||||
case CINEMATOGRAPHER = 6;
|
||||
case EDITOR = 7;
|
||||
case PRODUCTION_DESIGNER = 8;
|
||||
case ART_DIRECTOR = 9;
|
||||
case ACTOR = 10;
|
||||
|
||||
public static function from_tmdb_job($job_name): ?static
|
||||
{
|
||||
return match ($job_name) {
|
||||
"Director" => static::DIRECTOR,
|
||||
"Screenplay" => static::WRITER,
|
||||
"Producer", "Co-Producer", "Associate Producer" => static::PRODUCER,
|
||||
"Original Music Composer" => static::COMPOSER,
|
||||
"Director of Photography" => static::CINEMATOGRAPHER,
|
||||
"Editor" => static::EDITOR,
|
||||
"Production Design" => static::PRODUCTION_DESIGNER,
|
||||
"Art Direction" => static::ART_DIRECTOR,
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,15 @@ use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of exceptions with their corresponding custom log levels.
|
||||
*
|
||||
* @var array<class-string<Throwable>, \Psr\Log\LogLevel::*>
|
||||
*/
|
||||
protected $levels = [
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
|
||||
+11
-7
@@ -112,15 +112,17 @@ if (! \function_exists('modal_style')) {
|
||||
if (! \function_exists('rating_color')) {
|
||||
function rating_color($number)
|
||||
{
|
||||
if ($number > 0 && $number <= 3.9) {
|
||||
$rating = round((float) $number);
|
||||
|
||||
if ($rating > 0 && $rating <= 4) {
|
||||
return 'text-danger';
|
||||
}
|
||||
|
||||
if ($number >= 4 && $number <= 6.9) {
|
||||
if ($rating >= 4 && $rating <= 7) {
|
||||
return 'text-warning';
|
||||
}
|
||||
|
||||
if ($number >= 7 && $number <= 10) {
|
||||
if ($rating >= 7 && $rating <= 10) {
|
||||
return 'text-success';
|
||||
}
|
||||
}
|
||||
@@ -133,15 +135,17 @@ if (! \function_exists('language_flag')) {
|
||||
'English', 'English (US)' => 'us',
|
||||
'English (GB)' => 'gb',
|
||||
'English (CA)' => 'can',
|
||||
'Albanian' => 'al',
|
||||
'English (AU)' => 'au',
|
||||
'Albanian', 'Albanian (AL)' => 'al',
|
||||
'Arabic', 'Arabic (001)' => 'ae',
|
||||
'Belarusian' => 'by',
|
||||
'Bengali' => 'bd',
|
||||
'Bosnian' => 'ba',
|
||||
'Bosnian', 'Bosnian (BA)' => 'ba',
|
||||
'Bulgarian', 'Bulgarian (BG)' => 'bg',
|
||||
'Catalan' => 'ca',
|
||||
'Chinese', 'Mandarin (Hans)', 'Mandarin (Hant)', 'Cantonese (Hant)', 'Chinese (Simplied)', 'Chinese (Traditional)' => 'cn',
|
||||
'Chinese', 'Mandarin (Hans)', 'Mandarin (Hant)', 'Cantonese', 'Cantonese (Hant)', 'Chinese (Simplied)', 'Chinese (Traditional)' => 'cn',
|
||||
'Chinese (HK)', 'Chinese-Hant-HK' => 'hk',
|
||||
'Chinese (Taiwan)' => 'tw',
|
||||
'Croatian', 'Croatian (HR)' => 'hr',
|
||||
'Czech', 'Czech (CZ)' => 'cz',
|
||||
'Danish', 'Danish (DK)' => 'dk',
|
||||
@@ -172,7 +176,7 @@ if (! \function_exists('language_flag')) {
|
||||
'Portuguese (BR)' => 'br',
|
||||
'Romanian', 'Romanian (RO)' => 'ro',
|
||||
'Russian', 'Russian (RU)' => 'ru',
|
||||
'Serbian', 'Serbian-Latn-RS' => 'rs',
|
||||
'Serbian', 'Serbian-Latn-RS', 'Serbian (RS)' => 'rs',
|
||||
'Slovak', 'Slovak (SK)' => 'sk',
|
||||
'Slovenian', 'Slovenian (SI)' => 'si',
|
||||
'Spanish', 'Spanish (ES)' => 'es',
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author HDVinnie <hdinnovations@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
* @credits Rhilip <https://github.com/Rhilip>
|
||||
*/
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
class Nfo
|
||||
{
|
||||
/**
|
||||
* Code for Viewing NFO file.
|
||||
*/
|
||||
public static function parseNfo(string $nfo): string
|
||||
{
|
||||
$cf = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 8962, 199, 252, 233, 226, 228, 224, 229, 231, 234, 235, 232, 239, 238, 236, 196, 197, 201, 230, 198, 244, 246, 242, 251, 249, 255, 214, 220, 162, 163, 165, 8359, 402, 225, 237, 243, 250, 241, 209, 170, 186, 191, 8976, 172, 189, 188, 161, 171, 187, 9617, 9618, 9619, 9474, 9508, 9569, 9570, 9558, 9557, 9571, 9553, 9559, 9565, 9564, 9563, 9488, 9492, 9524, 9516, 9500, 9472, 9532, 9566, 9567, 9562, 9556, 9577, 9574, 9568, 9552, 9580, 9575, 9576, 9572, 9573, 9561, 9560, 9554, 9555, 9579, 9578, 9496, 9484, 9608, 9604, 9612, 9616, 9600, 945, 223, 915, 960, 931, 963, 181, 964, 934, 920, 937, 948, 8734, 966, 949, 8745, 8801, 177, 8805, 8804, 8992, 8993, 247, 8776, 176, 8729, 183, 8730, 8319, 178, 9632, 160];
|
||||
$s = '';
|
||||
for ($c = 0, $cMax = \strlen($nfo); $c < $cMax; $c++) { // cyctle through the whole file doing a byte at a time.
|
||||
$byte = $nfo[$c];
|
||||
$ob = \ord($byte);
|
||||
if ($ob >= 127) { // is it in the normal ascii range
|
||||
$s .= '&#'.$cf[$ob].';';
|
||||
} else {
|
||||
$s .= $byte;
|
||||
}
|
||||
}
|
||||
|
||||
$s = str_replace( // Code windows to dos
|
||||
["\345", "\344", "\366", "\311", "\351"], // ['å','ä','ö','É','é']
|
||||
["\206", "\204", "\224", "\220", "\202"], // ['','','','','']
|
||||
$s);
|
||||
|
||||
$s = preg_replace(
|
||||
["/([ -~])\305([ -~])/", "/([ -~])\304([ -~])/", "/([ -~])\326([ -~])/"],
|
||||
["\\1\217\\2", "\\1\216\\2", "\\1\231\\2"],
|
||||
$s
|
||||
);
|
||||
|
||||
return mb_convert_encoding($s, 'UTF-8', 'ASCII');
|
||||
}
|
||||
}
|
||||
@@ -121,9 +121,7 @@ class SystemInformation
|
||||
return 'Unkown';
|
||||
}
|
||||
|
||||
$results = DB::select(DB::raw('select version()'));
|
||||
|
||||
return $results[0]->{'version()'};
|
||||
return DB::select('select version()')[0]->{'version()'};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -152,7 +152,8 @@ class RegisterController extends Controller
|
||||
$userActivation->user_id = $user->id;
|
||||
$userActivation->token = $token;
|
||||
$userActivation->save();
|
||||
$this->dispatch(new SendActivationMail($user, $token));
|
||||
dispatch(new SendActivationMail($user, $token));
|
||||
|
||||
// Select A Random Welcome Message
|
||||
$profileUrl = href_profile($user);
|
||||
$welcomeArray = [
|
||||
@@ -168,6 +169,7 @@ class RegisterController extends Controller
|
||||
$this->chatRepository->systemMessage(
|
||||
$welcomeArray[$selected]
|
||||
);
|
||||
|
||||
// Send Welcome PM
|
||||
$privateMessage = new PrivateMessage();
|
||||
$privateMessage->sender_id = 1;
|
||||
|
||||
@@ -14,13 +14,11 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests;
|
||||
use DispatchesJobs;
|
||||
use ValidatesRequests;
|
||||
}
|
||||
|
||||
@@ -18,10 +18,12 @@ use App\Models\Bookmark;
|
||||
use App\Models\FeaturedTorrent;
|
||||
use App\Models\FreeleechToken;
|
||||
use App\Models\Group;
|
||||
use App\Models\Movie;
|
||||
use App\Models\Poll;
|
||||
use App\Models\Post;
|
||||
use App\Models\Topic;
|
||||
use App\Models\Torrent;
|
||||
use App\Models\Tv;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -51,50 +53,240 @@ class HomeController extends Controller
|
||||
// Latest Articles/News Block
|
||||
$articles = cache()->remember('latest_article', $expiresAt, fn () => Article::latest()->take(1)->get());
|
||||
foreach ($articles as $article) {
|
||||
$article->newNews = ($user->updated_at->subDays(3)->getTimestamp() < $article->created_at->getTimestamp()) ? 1 : 0;
|
||||
$article->newNews = ($user->last_login->subDays(3)->getTimestamp() < $article->created_at->getTimestamp()) ? 1 : 0;
|
||||
}
|
||||
|
||||
// Latest Torrents Block
|
||||
$personalFreeleech = cache()->get('personal_freeleech:'.$user->id);
|
||||
|
||||
$newest = cache()->remember('newest_torrents', $expiresAt, fn () => Torrent::with(['user', 'category', 'type', 'resolution'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->latest()
|
||||
->take(5)
|
||||
->get());
|
||||
$newest = cache()->remember('newest_torrents', $expiresAt, function () {
|
||||
$newest = Torrent::with(['user', 'category', 'type', 'resolution'])
|
||||
->withExists([
|
||||
'bookmarks' => fn ($query) => $query->where('user_id', '=', auth()->id()),
|
||||
'freeleechTokens' => fn ($query) => $query->where('user_id', '=', auth()->id()),
|
||||
])
|
||||
->selectRaw("
|
||||
CASE
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `movie_meta` = 1) THEN 'movie'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `tv_meta` = 1) THEN 'tv'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `game_meta` = 1) THEN 'game'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `music_meta` = 1) THEN 'music'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `no_meta` = 1) THEN 'no'
|
||||
END as meta
|
||||
")
|
||||
->withCount(['thanks', 'comments'])
|
||||
->latest()
|
||||
->take(5)
|
||||
->get();
|
||||
|
||||
$seeded = cache()->remember('seeded_torrents', $expiresAt, fn () => Torrent::with(['user', 'category', 'type', 'resolution'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->latest('seeders')
|
||||
->take(5)
|
||||
->get());
|
||||
$movieIds = $newest->where('meta', '=', 'movie')->pluck('tmdb');
|
||||
$tvIds = $newest->where('meta', '=', 'tv')->pluck('tmdb');
|
||||
$gameIds = $newest->where('meta', '=', 'game')->pluck('igdb');
|
||||
|
||||
$leeched = cache()->remember('leeched_torrents', $expiresAt, fn () => Torrent::with(['user', 'category', 'type', 'resolution'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->latest('leechers')
|
||||
->take(5)
|
||||
->get());
|
||||
$movies = Movie::with('genres')->whereIntegerInRaw('id', $movieIds)->get()->keyBy('id');
|
||||
$tv = Tv::with('genres')->whereIntegerInRaw('id', $tvIds)->get()->keyBy('id');
|
||||
if ($gameIds->isNotEmpty()) {
|
||||
$games = \MarcReichel\IGDBLaravel\Models\Game::with(['cover' => ['url', 'image_id']])->whereIntegerInRaw('id', $gameIds);
|
||||
}
|
||||
|
||||
$dying = cache()->remember('dying_torrents', $expiresAt, fn () => Torrent::with(['user', 'category', 'type', 'resolution'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->where('seeders', '=', 1)
|
||||
->where('times_completed', '>=', 1)
|
||||
->latest('leechers')
|
||||
->take(5)
|
||||
->get());
|
||||
$newest = $newest->map(function ($torrent) use ($movies, $tv) {
|
||||
$torrent->meta = match ($torrent->meta) {
|
||||
'movie' => $movies[$torrent->tmdb] ?? null,
|
||||
'tv' => $tv[$torrent->tmdb] ?? null,
|
||||
'game' => $games[$torrent->igdb] ?? null,
|
||||
default => null,
|
||||
};
|
||||
|
||||
$dead = cache()->remember('dead_torrents', $expiresAt, fn () => Torrent::with(['user', 'category', 'type', 'resolution'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->where('seeders', '=', 0)
|
||||
->latest('leechers')
|
||||
->take(5)
|
||||
->get());
|
||||
return $torrent;
|
||||
});
|
||||
|
||||
return $newest;
|
||||
});
|
||||
|
||||
$seeded = cache()->remember('seeded_torrents', $expiresAt, function () {
|
||||
$seeded = Torrent::with(['user', 'category', 'type', 'resolution'])
|
||||
->withExists([
|
||||
'bookmarks' => fn ($query) => $query->where('user_id', '=', auth()->id()),
|
||||
'freeleechTokens' => fn ($query) => $query->where('user_id', '=', auth()->id()),
|
||||
])
|
||||
->selectRaw("
|
||||
CASE
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `movie_meta` = 1) THEN 'movie'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `tv_meta` = 1) THEN 'tv'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `game_meta` = 1) THEN 'game'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `music_meta` = 1) THEN 'music'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `no_meta` = 1) THEN 'no'
|
||||
END as meta
|
||||
")
|
||||
->withCount(['thanks', 'comments'])
|
||||
->latest('seeders')
|
||||
->take(5)
|
||||
->get();
|
||||
|
||||
$movieIds = $seeded->where('meta', '=', 'movie')->pluck('tmdb');
|
||||
$tvIds = $seeded->where('meta', '=', 'tv')->pluck('tmdb');
|
||||
$gameIds = $seeded->where('meta', '=', 'game')->pluck('igdb');
|
||||
|
||||
$movies = Movie::with('genres')->whereIntegerInRaw('id', $movieIds)->get()->keyBy('id');
|
||||
$tv = Tv::with('genres')->whereIntegerInRaw('id', $tvIds)->get()->keyBy('id');
|
||||
if ($gameIds->isNotEmpty()) {
|
||||
$games = \MarcReichel\IGDBLaravel\Models\Game::with(['cover' => ['url', 'image_id']])->whereIntegerInRaw('id', $gameIds);
|
||||
}
|
||||
|
||||
$seeded = $seeded->map(function ($torrent) use ($movies, $tv) {
|
||||
$torrent->meta = match ($torrent->meta) {
|
||||
'movie' => $movies[$torrent->tmdb] ?? null,
|
||||
'tv' => $tv[$torrent->tmdb] ?? null,
|
||||
'game' => $games[$torrent->igdb] ?? null,
|
||||
default => null,
|
||||
};
|
||||
|
||||
return $torrent;
|
||||
});
|
||||
|
||||
return $seeded;
|
||||
});
|
||||
|
||||
$leeched = cache()->remember('leeched_torrents', $expiresAt, function () {
|
||||
$leeched = Torrent::with(['user', 'category', 'type', 'resolution'])
|
||||
->withExists([
|
||||
'bookmarks' => fn ($query) => $query->where('user_id', '=', auth()->id()),
|
||||
'freeleechTokens' => fn ($query) => $query->where('user_id', '=', auth()->id()),
|
||||
])
|
||||
->selectRaw("
|
||||
CASE
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `movie_meta` = 1) THEN 'movie'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `tv_meta` = 1) THEN 'tv'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `game_meta` = 1) THEN 'game'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `music_meta` = 1) THEN 'music'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `no_meta` = 1) THEN 'no'
|
||||
END as meta
|
||||
")
|
||||
->withCount(['thanks', 'comments'])
|
||||
->latest('leechers')
|
||||
->take(5)
|
||||
->get();
|
||||
|
||||
$movieIds = $leeched->where('meta', '=', 'movie')->pluck('tmdb');
|
||||
$tvIds = $leeched->where('meta', '=', 'tv')->pluck('tmdb');
|
||||
$gameIds = $leeched->where('meta', '=', 'game')->pluck('igdb');
|
||||
|
||||
$movies = Movie::with('genres')->whereIntegerInRaw('id', $movieIds)->get()->keyBy('id');
|
||||
$tv = Tv::with('genres')->whereIntegerInRaw('id', $tvIds)->get()->keyBy('id');
|
||||
if ($gameIds->isNotEmpty()) {
|
||||
$games = \MarcReichel\IGDBLaravel\Models\Game::with(['cover' => ['url', 'image_id']])->whereIntegerInRaw('id', $gameIds);
|
||||
}
|
||||
|
||||
$leeched = $leeched->map(function ($torrent) use ($movies, $tv) {
|
||||
$torrent->meta = match ($torrent->meta) {
|
||||
'movie' => $movies[$torrent->tmdb] ?? null,
|
||||
'tv' => $tv[$torrent->tmdb] ?? null,
|
||||
'game' => $games[$torrent->igdb] ?? null,
|
||||
default => null,
|
||||
};
|
||||
|
||||
return $torrent;
|
||||
});
|
||||
|
||||
return $leeched;
|
||||
});
|
||||
|
||||
$dying = cache()->remember('dying_torrents', $expiresAt, function () {
|
||||
$dying = Torrent::with(['user', 'category', 'type', 'resolution'])
|
||||
->withExists([
|
||||
'bookmarks' => fn ($query) => $query->where('user_id', '=', auth()->id()),
|
||||
'freeleechTokens' => fn ($query) => $query->where('user_id', '=', auth()->id()),
|
||||
])
|
||||
->selectRaw("
|
||||
CASE
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `movie_meta` = 1) THEN 'movie'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `tv_meta` = 1) THEN 'tv'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `game_meta` = 1) THEN 'game'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `music_meta` = 1) THEN 'music'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `no_meta` = 1) THEN 'no'
|
||||
END as meta
|
||||
")
|
||||
->withCount(['thanks', 'comments'])
|
||||
->where('seeders', '=', 1)
|
||||
->where('times_completed', '>=', 1)
|
||||
->latest('leechers')
|
||||
->take(5)
|
||||
->get();
|
||||
|
||||
$movieIds = $dying->where('meta', '=', 'movie')->pluck('tmdb');
|
||||
$tvIds = $dying->where('meta', '=', 'tv')->pluck('tmdb');
|
||||
$gameIds = $dying->where('meta', '=', 'game')->pluck('igdb');
|
||||
|
||||
$movies = Movie::with('genres')->whereIntegerInRaw('id', $movieIds)->get()->keyBy('id');
|
||||
$tv = Tv::with('genres')->whereIntegerInRaw('id', $tvIds)->get()->keyBy('id');
|
||||
if ($gameIds->isNotEmpty()) {
|
||||
$games = \MarcReichel\IGDBLaravel\Models\Game::with(['cover' => ['url', 'image_id']])->whereIntegerInRaw('id', $gameIds);
|
||||
}
|
||||
|
||||
$dying = $dying->map(function ($torrent) use ($movies, $tv) {
|
||||
$torrent->meta = match ($torrent->meta) {
|
||||
'movie' => $movies[$torrent->tmdb] ?? null,
|
||||
'tv' => $tv[$torrent->tmdb] ?? null,
|
||||
'game' => $games[$torrent->igdb] ?? null,
|
||||
default => null,
|
||||
};
|
||||
|
||||
return $torrent;
|
||||
});
|
||||
|
||||
return $dying;
|
||||
});
|
||||
|
||||
$dead = cache()->remember('dead_torrents', $expiresAt, function () {
|
||||
$dead = Torrent::with(['user', 'category', 'type', 'resolution'])
|
||||
->withExists([
|
||||
'bookmarks' => fn ($query) => $query->where('user_id', '=', auth()->id()),
|
||||
'freeleechTokens' => fn ($query) => $query->where('user_id', '=', auth()->id()),
|
||||
])
|
||||
->selectRaw("
|
||||
CASE
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `movie_meta` = 1) THEN 'movie'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `tv_meta` = 1) THEN 'tv'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `game_meta` = 1) THEN 'game'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `music_meta` = 1) THEN 'music'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `no_meta` = 1) THEN 'no'
|
||||
END as meta
|
||||
")
|
||||
->withCount(['thanks', 'comments'])
|
||||
->where('seeders', '=', 0)
|
||||
->latest('leechers')
|
||||
->take(5)
|
||||
->get();
|
||||
|
||||
$movieIds = $dead->where('meta', '=', 'movie')->pluck('tmdb');
|
||||
$tvIds = $dead->where('meta', '=', 'tv')->pluck('tmdb');
|
||||
$gameIds = $dead->where('meta', '=', 'game')->pluck('igdb');
|
||||
|
||||
$movies = Movie::with('genres')->whereIntegerInRaw('id', $movieIds)->get()->keyBy('id');
|
||||
$tv = Tv::with('genres')->whereIntegerInRaw('id', $tvIds)->get()->keyBy('id');
|
||||
if ($gameIds->isNotEmpty()) {
|
||||
$games = \MarcReichel\IGDBLaravel\Models\Game::with(['cover' => ['url', 'image_id']])->whereIntegerInRaw('id', $gameIds);
|
||||
}
|
||||
|
||||
$dead = $dead->map(function ($torrent) use ($movies, $tv) {
|
||||
$torrent->meta = match ($torrent->meta) {
|
||||
'movie' => $movies[$torrent->tmdb] ?? null,
|
||||
'tv' => $tv[$torrent->tmdb] ?? null,
|
||||
'game' => $games[$torrent->igdb] ?? null,
|
||||
default => null,
|
||||
};
|
||||
|
||||
return $torrent;
|
||||
});
|
||||
|
||||
return $dead;
|
||||
});
|
||||
|
||||
// Latest Topics Block
|
||||
$topics = cache()->remember('latest_topics', $expiresAt, fn () => Topic::with('forum')->latest()->take(5)->get());
|
||||
|
||||
// Latest Posts Block
|
||||
$posts = cache()->remember('latest_posts', $expiresAt, fn () => Post::with('topic', 'user')->latest()->take(5)->get());
|
||||
$posts = cache()->remember('latest_posts', $expiresAt, fn () => Post::with('topic', 'user')->withCount('authorPosts', 'authorTopics')->latest()->take(5)->get());
|
||||
|
||||
// Online Block
|
||||
$users = cache()->remember('online_users', $expiresAt, fn () => User::with('group', 'privacy')
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
namespace App\Http\Controllers\MediaHub;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Company;
|
||||
|
||||
class CompanyController extends Controller
|
||||
{
|
||||
@@ -25,20 +24,4 @@ class CompanyController extends Controller
|
||||
{
|
||||
return view('mediahub.company.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show A Company.
|
||||
*/
|
||||
public function show(int $id): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
{
|
||||
$company = Company::withCount('tv', 'movie')->findOrFail($id);
|
||||
$shows = $company->tv()->has('torrents')->oldest('name')->paginate(25, ['*'], 'showsPage');
|
||||
$movies = $company->movie()->has('torrents')->oldest('title')->paginate(25, ['*'], 'moviesPage');
|
||||
|
||||
return view('mediahub.company.show', [
|
||||
'company' => $company,
|
||||
'shows' => $shows,
|
||||
'movies' => $movies,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,20 +27,4 @@ class GenreController extends Controller
|
||||
|
||||
return view('mediahub.genre.index', ['genres' => $genres]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show A Genre.
|
||||
*/
|
||||
public function show(int $id): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
{
|
||||
$genre = Genre::withCount(['tv', 'movie'])->findOrFail($id);
|
||||
$shows = $genre->tv()->has('torrents')->oldest('name')->paginate(25, ['*'], 'showsPage');
|
||||
$movies = $genre->movie()->has('torrents')->oldest('title')->paginate(25, ['*'], 'moviesPage');
|
||||
|
||||
return view('mediahub.genre.show', [
|
||||
'genre' => $genre,
|
||||
'shows' => $shows,
|
||||
'movies' => $movies,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
namespace App\Http\Controllers\MediaHub;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Category;
|
||||
use App\Models\Collection;
|
||||
use App\Models\Company;
|
||||
use App\Models\Genre;
|
||||
@@ -37,14 +38,17 @@ class HomeController extends Controller
|
||||
$networks = Network::count();
|
||||
$companies = Company::count();
|
||||
|
||||
$movieCategoryIds = Category::where('movie_meta', '=', 1)->pluck('id')->toArray();
|
||||
|
||||
return view('mediahub.index', [
|
||||
'tv' => $tv,
|
||||
'movies' => $movies,
|
||||
'collections' => $collections,
|
||||
'persons' => $persons,
|
||||
'genres' => $genres,
|
||||
'networks' => $networks,
|
||||
'companies' => $companies,
|
||||
'tv' => $tv,
|
||||
'movies' => $movies,
|
||||
'movieCategoryIds' => $movieCategoryIds,
|
||||
'collections' => $collections,
|
||||
'persons' => $persons,
|
||||
'genres' => $genres,
|
||||
'networks' => $networks,
|
||||
'companies' => $companies,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author HDVinnie <hdinnovations@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers\MediaHub;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Movie;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class MovieController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display All Movies.
|
||||
*/
|
||||
public function index(): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
{
|
||||
return view('mediahub.movie.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show A Movie.
|
||||
*/
|
||||
public function show(Request $request, int $id): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
{
|
||||
$user = $request->user();
|
||||
$personalFreeleech = cache()->get('personal_freeleech:'.$user->id);
|
||||
$movie = Movie::with(['cast', 'collection', 'genres', 'companies'])->findOrFail($id);
|
||||
|
||||
return view('mediahub.movie.show', [
|
||||
'movie' => $movie,
|
||||
'user' => $user,
|
||||
'personal_freeleech' => $personalFreeleech,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@
|
||||
namespace App\Http\Controllers\MediaHub;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Network;
|
||||
|
||||
class NetworkController extends Controller
|
||||
{
|
||||
@@ -25,18 +24,4 @@ class NetworkController extends Controller
|
||||
{
|
||||
return view('mediahub.network.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show A Network.
|
||||
*/
|
||||
public function show(int $id): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
{
|
||||
$network = Network::withCount('tv')->findOrFail($id);
|
||||
$shows = $network->tv()->has('torrents')->oldest('name')->paginate(25);
|
||||
|
||||
return view('mediahub.network.show', [
|
||||
'network' => $network,
|
||||
'shows' => $shows,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
namespace App\Http\Controllers\MediaHub;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Category;
|
||||
use App\Models\Person;
|
||||
|
||||
class PersonController extends Controller
|
||||
@@ -38,6 +39,14 @@ class PersonController extends Controller
|
||||
'movie.genres'
|
||||
])->findOrFail($id);
|
||||
|
||||
return view('mediahub.person.show', ['person' => $person]);
|
||||
|
||||
$movieCategoryIds = Category::where('movie_meta', '=', 1)->pluck('id')->toArray();
|
||||
$tvCategoryIds = Category::where('tv_meta', '=', 1)->pluck('id')->toArray();
|
||||
|
||||
return view('mediahub.person.show', [
|
||||
'person' => $person,
|
||||
'movieCategoryIds' => $movieCategoryIds,
|
||||
'tvCategoryIds' => $tvCategoryIds
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ class PlaylistController extends Controller
|
||||
}
|
||||
|
||||
if ($torrent->category->movie_meta && ($torrent->tmdb || $torrent->tmdb != 0)) {
|
||||
$meta = Movie::with('genres', 'cast', 'companies', 'collection')->where('id', '=', $torrent->tmdb)->first();
|
||||
$meta = Movie::with('genres', 'companies', 'collection')->where('id', '=', $torrent->tmdb)->first();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ class RequestController extends Controller
|
||||
*/
|
||||
public function request(Request $request, int $id): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
{
|
||||
$torrentRequest = TorrentRequest::findOrFail($id);
|
||||
$torrentRequest = TorrentRequest::with('category')->findOrFail($id);
|
||||
$user = $request->user();
|
||||
$torrentRequestClaim = TorrentRequestClaim::where('request_id', '=', $id)->first();
|
||||
$voters = $torrentRequest->requestBounty()->get();
|
||||
@@ -74,11 +74,25 @@ class RequestController extends Controller
|
||||
|
||||
$meta = null;
|
||||
if ($torrentRequest->category->tv_meta && ($torrentRequest->tmdb || $torrentRequest->tmdb != 0)) {
|
||||
$meta = Tv::with('genres', 'networks', 'seasons')->where('id', '=', $torrentRequest->tmdb)->first();
|
||||
$meta = Tv::with([
|
||||
'genres',
|
||||
'credits' => ['person', 'occupation'],
|
||||
'networks',
|
||||
'seasons'
|
||||
])
|
||||
->where('id', '=', $torrentRequest->tmdb)
|
||||
->first();
|
||||
}
|
||||
|
||||
if ($torrentRequest->category->movie_meta && ($torrentRequest->tmdb || $torrentRequest->tmdb != 0)) {
|
||||
$meta = Movie::with('genres', 'cast', 'companies', 'collection')->where('id', '=', $torrentRequest->tmdb)->first();
|
||||
$meta = Movie::with([
|
||||
'genres',
|
||||
'credits' => ['person', 'occupation'],
|
||||
'companies',
|
||||
'collection'
|
||||
])
|
||||
->where('id', '=', $torrentRequest->tmdb)
|
||||
->first();
|
||||
}
|
||||
|
||||
if ($torrentRequest->category->game_meta && ($torrentRequest->igdb || $torrentRequest->igdb != 0)) {
|
||||
@@ -106,7 +120,7 @@ class RequestController extends Controller
|
||||
/**
|
||||
* Torrent Request Add Form.
|
||||
*/
|
||||
public function addRequestForm(Request $request, string $title = '', int $imdb = 0, int $tmdb = 0): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
public function addRequestForm(Request $request): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
@@ -115,9 +129,13 @@ class RequestController extends Controller
|
||||
'types' => Type::all()->sortBy('position'),
|
||||
'resolutions' => Resolution::all()->sortBy('position'),
|
||||
'user' => $user,
|
||||
'title' => $title,
|
||||
'imdb' => str_replace('tt', '', $imdb),
|
||||
'tmdb' => $tmdb,
|
||||
'category_id' => $request->category_id,
|
||||
'title' => urldecode($request->title),
|
||||
'imdb' => $request->imdb,
|
||||
'tmdb' => $request->tmdb,
|
||||
'mal' => $request->mal,
|
||||
'tvdb' => $request->tvdb,
|
||||
'igdb' => $request->igdb,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,9 +13,12 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\Movie;
|
||||
use App\Models\Torrent;
|
||||
use App\Models\Tv;
|
||||
use MarcReichel\IGDBLaravel\Models\Game;
|
||||
use MarcReichel\IGDBLaravel\Models\PlatformLogo;
|
||||
|
||||
class SimilarTorrentController extends Controller
|
||||
{
|
||||
@@ -24,26 +27,73 @@ class SimilarTorrentController extends Controller
|
||||
*/
|
||||
public function show(int $categoryId, int $tmdbId): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application
|
||||
{
|
||||
$torrent = Torrent::where('category_id', '=', $categoryId)
|
||||
->where('tmdb', '=', $tmdbId)
|
||||
->first();
|
||||
$category = Category::query()->findOrFail($categoryId);
|
||||
|
||||
abort_if(! $torrent || $torrent->count() === 0, 404, 'No Similar Torrents Found');
|
||||
switch (true) {
|
||||
case $category->movie_meta:
|
||||
$hasTorrents = Torrent::query()->where('category_id', '=', $categoryId)->where('tmdb', '=', $tmdbId)->exists();
|
||||
|
||||
$meta = null;
|
||||
if ($torrent->category->tv_meta) {
|
||||
$meta = Tv::with('genres', 'cast', 'networks', 'seasons')->where('id', '=', $tmdbId)->first();
|
||||
abort_unless($hasTorrents, 404, 'No Similar Torrents Found');
|
||||
|
||||
$meta = Movie::with([
|
||||
'genres',
|
||||
'credits' => ['person', 'occupation'],
|
||||
'companies'
|
||||
])
|
||||
->find($tmdbId);
|
||||
$trailer = ( new \App\Services\Tmdb\Client\Movie($tmdbId))->get_trailer();
|
||||
$tmdb = $tmdbId;
|
||||
break;
|
||||
case $category->tv_meta:
|
||||
$hasTorrents = Torrent::query()->where('category_id', '=', $categoryId)->where('tmdb', '=', $tmdbId)->exists();
|
||||
|
||||
abort_unless($hasTorrents, 404, 'No Similar Torrents Found');
|
||||
|
||||
$meta = Tv::with([
|
||||
'genres',
|
||||
'credits' => ['person', 'occupation'],
|
||||
'companies',
|
||||
'networks'
|
||||
])
|
||||
->find($tmdbId);
|
||||
$trailer = ( new \App\Services\Tmdb\Client\TV($tmdbId))->get_trailer();
|
||||
$tmdb = $tmdbId;
|
||||
break;
|
||||
case $category->game_meta:
|
||||
$hasTorrents = Torrent::query()->where('category_id', '=', $categoryId)->where('igdb', '=', $tmdbId)->exists();
|
||||
|
||||
abort_unless($hasTorrents, 404, 'No Similar Torrents Found');
|
||||
|
||||
$meta = Game::with([
|
||||
'cover' => ['url', 'image_id'],
|
||||
'artworks' => ['url', 'image_id'],
|
||||
'genres' => ['name'],
|
||||
'videos' => ['video_id', 'name'],
|
||||
'involved_companies.company',
|
||||
'involved_companies.company.logo',
|
||||
'platforms',
|
||||
])
|
||||
->find($tmdbId);
|
||||
$link = collect($meta->videos)->take(1)->pluck('video_id');
|
||||
$trailer = isset($link[0]) ? 'https://www.youtube.com/embed/'.$link[0] : '/img/no-video.png';
|
||||
$platforms = PlatformLogo::whereIn('id', collect($meta->platforms)->pluck('platform_logo')->toArray())->get();
|
||||
$igdb = $tmdbId;
|
||||
break;
|
||||
default:
|
||||
abort(404, 'No Similar Torrents Found');
|
||||
break;
|
||||
}
|
||||
|
||||
if ($torrent->category->movie_meta) {
|
||||
$meta = Movie::with('genres', 'cast', 'companies', 'collection')->where('id', '=', $tmdbId)->first();
|
||||
}
|
||||
$personalFreeleech = cache()->get('personal_freeleech:'.auth()->user()->id);
|
||||
|
||||
return view('torrent.similar', [
|
||||
'meta' => $meta,
|
||||
'torrent' => $torrent,
|
||||
'categoryId' => $categoryId,
|
||||
'tmdbId' => $tmdbId,
|
||||
'meta' => $meta,
|
||||
'personal_freeleech' => $personalFreeleech,
|
||||
'trailer' => $trailer,
|
||||
'platforms' => $platforms ?? null,
|
||||
'category' => $category,
|
||||
'tmdb' => $tmdb ?? null,
|
||||
'igdb' => $igdb ?? null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-6
@@ -7,19 +7,21 @@
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author HDVinnie <hdinnovations@protonmail.com>
|
||||
* @author Roardom <roardom@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
class TorrentCardController extends Controller
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class PeerController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* Display All Pages.
|
||||
*/
|
||||
public function index(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application
|
||||
public function index(): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
{
|
||||
return view('torrent.cards');
|
||||
return view('Staff.peer.index');
|
||||
}
|
||||
}
|
||||
@@ -215,11 +215,13 @@ class TopicController extends Controller
|
||||
$topic = Topic::findOrFail($id);
|
||||
|
||||
abort_unless($user->group->is_modo || $user->id === $topic->first_post_user_id, 403);
|
||||
$topic->name = $request->name;
|
||||
$forum = Forum::findOrFail($request->forum_id);
|
||||
|
||||
$forum = Forum::findOrFail($request->input('forum_id'));
|
||||
|
||||
if ($forum->getPermission()->start_topic) {
|
||||
$topic->forum_id = $request->forum->id;
|
||||
$topic->name = $request->input('name');
|
||||
$topic->forum_id = $forum->id;
|
||||
$topic->save();
|
||||
} else {
|
||||
return to_route('forums.index')
|
||||
->withErrors('You Cannot Start A New Topic Here!');
|
||||
|
||||
@@ -84,7 +84,10 @@ class TorrentController extends Controller
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
$torrent = Torrent::withAnyStatus()->with(['user', 'comments', 'category', 'type', 'resolution', 'subtitles', 'playlists'])->findOrFail($id);
|
||||
$torrent = Torrent::withAnyStatus()
|
||||
->with(['user', 'comments', 'category', 'type', 'resolution', 'subtitles', 'playlists'])
|
||||
->withExists(['bookmarks' => fn ($query) => $query->where('user_id', '=', $user->id)])
|
||||
->findOrFail($id);
|
||||
$freeleechToken = cache()->get('freeleech_token:'.$user->id.':'.$torrent->id);
|
||||
$personalFreeleech = cache()->get('personal_freeleech:'.$user->id);
|
||||
$totalTips = BonTransactions::where('torrent_id', '=', $id)->sum('cost');
|
||||
@@ -96,12 +99,25 @@ class TorrentController extends Controller
|
||||
$trailer = null;
|
||||
$platforms = null;
|
||||
if ($torrent->category->tv_meta && $torrent->tmdb && $torrent->tmdb != 0) {
|
||||
$meta = Tv::with('genres', 'cast', 'companies', 'networks', 'recommendations')->where('id', '=', $torrent->tmdb)->first();
|
||||
$meta = Tv::with([
|
||||
'genres',
|
||||
'credits' => ['person', 'occupation'],
|
||||
'companies',
|
||||
'networks',
|
||||
'recommendations'
|
||||
])->where('id', '=', $torrent->tmdb)->first();
|
||||
$trailer = ( new \App\Services\Tmdb\Client\TV($torrent->tmdb))->get_trailer();
|
||||
}
|
||||
|
||||
if ($torrent->category->movie_meta && $torrent->tmdb && $torrent->tmdb != 0) {
|
||||
$meta = Movie::with('genres', 'cast', 'companies', 'collection', 'recommendations')->where('id', '=', $torrent->tmdb)->first();
|
||||
$meta = Movie::with([
|
||||
'genres',
|
||||
'credits' => ['person', 'occupation'],
|
||||
'companies',
|
||||
'collection',
|
||||
'recommendations'
|
||||
])
|
||||
->where('id', '=', $torrent->tmdb)->first();
|
||||
$trailer = ( new \App\Services\Tmdb\Client\Movie($torrent->tmdb))->get_trailer();
|
||||
}
|
||||
|
||||
@@ -378,7 +394,7 @@ class TorrentController extends Controller
|
||||
/**
|
||||
* Torrent Upload Form.
|
||||
*/
|
||||
public function create(Request $request, int $categoryId = 0, string $title = '', string $imdb = '0', string $tmdb = '0'): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
public function create(Request $request): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
{
|
||||
$user = $request->user();
|
||||
$categories = [];
|
||||
@@ -404,10 +420,13 @@ class TorrentController extends Controller
|
||||
'regions' => Region::all()->sortBy('position'),
|
||||
'distributors' => Distributor::all()->sortBy('position'),
|
||||
'user' => $user,
|
||||
'category_id' => $categoryId,
|
||||
'title' => $title,
|
||||
'imdb' => str_replace('tt', '', $imdb),
|
||||
'tmdb' => $tmdb,
|
||||
'category_id' => $request->category_id,
|
||||
'title' => urldecode($request->title),
|
||||
'imdb' => $request->imdb,
|
||||
'tmdb' => $request->tmdb,
|
||||
'mal' => $request->mal,
|
||||
'tvdb' => $request->tvdb,
|
||||
'igdb' => $request->igdb,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author HDVinnie <hdinnovations@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
class TorrentGroupController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application
|
||||
{
|
||||
return view('torrent.group');
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ class GeneralSettingController extends Controller
|
||||
'style' => 'required|numeric',
|
||||
'custom_css' => 'nullable|url',
|
||||
'standalone_css' => 'nullable|url',
|
||||
'torrent_layout' => ['required', Rule::in([0])],
|
||||
'torrent_layout' => ['required', Rule::in([0, 1, 2])],
|
||||
'show_poster' => 'required|boolean',
|
||||
'ratings' => ['required', Rule::in([0, 1])],
|
||||
]);
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@ class Kernel extends HttpKernel
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
//\App\Http\Middleware\TrustProxies::class,
|
||||
\Fruitcake\Cors\HandleCors::class,
|
||||
\Illuminate\Http\Middleware\HandleCors::class,
|
||||
|
||||
// Extra
|
||||
\HDVinnie\SecureHeaders\SecureHeadersMiddleware::class,
|
||||
@@ -75,7 +75,7 @@ class Kernel extends HttpKernel
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
protected $middlewareAliases = [
|
||||
'admin' => \App\Http\Middleware\CheckForAdmin::class,
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
|
||||
@@ -14,40 +14,32 @@
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\Torrent;
|
||||
use App\Models\User;
|
||||
use Livewire\Component;
|
||||
|
||||
class BookmarkButton extends Component
|
||||
{
|
||||
public $torrent;
|
||||
|
||||
public ?\Illuminate\Contracts\Auth\Authenticatable $user = null;
|
||||
|
||||
final public function mount($torrent): void
|
||||
{
|
||||
$this->user = auth()->user();
|
||||
$this->torrent = Torrent::withAnyStatus()->findOrFail($torrent);
|
||||
}
|
||||
|
||||
final public function getIsBookmarkedProperty(): int
|
||||
{
|
||||
return $this->torrent->bookmarked() ? 1 : 0;
|
||||
}
|
||||
public Torrent $torrent;
|
||||
public User $user;
|
||||
public bool $isBookmarked;
|
||||
|
||||
final public function store(): void
|
||||
{
|
||||
if ($this->user->isBookmarked($this->torrent->id)) {
|
||||
if ($this->user->bookmarks()->where('torrent_id', '=', $this->torrent->id)->exists()) {
|
||||
$this->dispatchBrowserEvent('error', ['type' => 'error', 'message' => 'Torrent Has Already Been Bookmarked!']);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->user->bookmarks()->attach($this->torrent->id);
|
||||
$this->isBookmarked = true;
|
||||
$this->dispatchBrowserEvent('success', ['type' => 'success', 'message' => 'Torrent Has Been Bookmarked Successfully!']);
|
||||
}
|
||||
|
||||
final public function destroy(): void
|
||||
{
|
||||
$this->user->bookmarks()->detach($this->torrent->id);
|
||||
$this->isBookmarked = false;
|
||||
$this->dispatchBrowserEvent('success', ['type' => 'success', 'message' => 'Torrent Has Been Unbookmarked Successfully!']);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author HDVinnie <hdinnovations@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\Movie;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
class MovieSearch extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public $search;
|
||||
|
||||
final public function paginationView(): string
|
||||
{
|
||||
return 'vendor.pagination.livewire-pagination';
|
||||
}
|
||||
|
||||
final public function updatedPage(): void
|
||||
{
|
||||
$this->emit('paginationChanged');
|
||||
}
|
||||
|
||||
final public function updatingSearch(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
final public function getMoviesProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
{
|
||||
return Movie::query()
|
||||
->with(['companies', 'genres'])
|
||||
->when($this->search, fn ($query) => $query->where('title', 'LIKE', '%'.$this->search.'%'))
|
||||
->oldest('title')
|
||||
->paginate(30);
|
||||
}
|
||||
|
||||
final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application
|
||||
{
|
||||
return view('livewire.movie-search', [
|
||||
'movies' => $this->movies,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -78,6 +78,8 @@ class NotificationSearch extends Component
|
||||
final public function getNotificationsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
{
|
||||
return auth()->user()->notifications()
|
||||
->select('*')
|
||||
->selectRaw("CASE WHEN read_at IS NULL THEN 'FALSE' ELSE 'TRUE' END as is_read")
|
||||
->when($this->bon_gifts, function ($query): void {
|
||||
$query->where('type', '=', \App\Notifications\NewBon::class);
|
||||
})
|
||||
@@ -135,6 +137,8 @@ class NotificationSearch extends Component
|
||||
->when($this->uploads, function ($query): void {
|
||||
$query->where('type', '=', \App\Notifications\NewUpload::class);
|
||||
})
|
||||
->reorder()
|
||||
->orderBy('is_read')
|
||||
->orderBy($this->sortField, $this->sortDirection)
|
||||
->paginate($this->perPage);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,225 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author Roardom <roardom@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\Peer;
|
||||
use App\Models\Torrent;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
class PeerSearch extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public bool $duplicateIpsOnly = false;
|
||||
public bool $includeSeedsize = false;
|
||||
public int $perPage = 25;
|
||||
public string $ip = '';
|
||||
public string $port = '';
|
||||
public string $agent = '';
|
||||
public string $torrent = '';
|
||||
public string $connectivity = 'any';
|
||||
public string $groupBy = 'none';
|
||||
public string $sortField = 'created_at';
|
||||
public string $sortDirection = 'desc';
|
||||
|
||||
protected $queryString = [
|
||||
'page' => ['except' => 1],
|
||||
'perPage' => ['except' => ''],
|
||||
'duplicateIpsOnly' => ['except' => false],
|
||||
'includeSeedsize' => ['except' => false],
|
||||
'perPage' => ['except' => 25],
|
||||
'ip' => ['except' => ''],
|
||||
'port' => ['except' => ''],
|
||||
'agent' => ['except' => ''],
|
||||
'torrent' => ['except' => ''],
|
||||
'connectivity' => ['except' => 'any'],
|
||||
'groupBy' => ['except' => 'none'],
|
||||
'sortField' => ['except' => 'created_at'],
|
||||
'sortDirection' => ['except' => 'desc'],
|
||||
];
|
||||
|
||||
final public function paginationView(): string
|
||||
{
|
||||
return 'vendor.pagination.livewire-pagination';
|
||||
}
|
||||
|
||||
final public function updatedPage(): void
|
||||
{
|
||||
$this->emit('paginationChanged');
|
||||
}
|
||||
|
||||
final public function updatingIp(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
final public function updatingPort(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
final public function updatingAgent(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
final public function updatingTorrent(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
final public function updatingGroupBy(): void
|
||||
{
|
||||
if ($this->groupBy === 'none' && $this->sortField === 'size') {
|
||||
$this->sortField = 'created_at';
|
||||
}
|
||||
}
|
||||
|
||||
final public function getPeersProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
{
|
||||
return Peer::query()
|
||||
->when(
|
||||
$this->groupBy === 'none',
|
||||
fn ($query) => $query
|
||||
->select([
|
||||
'peers.torrent_id',
|
||||
'peers.user_id',
|
||||
'peers.uploaded',
|
||||
'peers.downloaded',
|
||||
'peers.left',
|
||||
'peers.port',
|
||||
'peers.agent',
|
||||
'peers.created_at',
|
||||
'peers.updated_at',
|
||||
'peers.seeder',
|
||||
'peers.connectable',
|
||||
])
|
||||
->selectRaw('INET6_NTOA(peers.ip) as ip')
|
||||
->with(['user', 'user.group', 'torrent:id,name,size'])
|
||||
)
|
||||
->when(
|
||||
$this->groupBy === 'user_session',
|
||||
fn ($query) => $query
|
||||
->select(['peers.user_id', 'peers.port', 'peers.agent'])
|
||||
->selectRaw('COUNT(DISTINCT(peers.torrent_id)) as torrent_id')
|
||||
->selectRaw('INET6_NTOA(peers.ip) as ip')
|
||||
->selectRaw('SUM(peers.uploaded) as uploaded')
|
||||
->selectRaw('SUM(peers.downloaded) as downloaded')
|
||||
->selectRaw('SUM(peers.`left`) as `left`')
|
||||
->selectRaw('MIN(peers.created_at) as created_at')
|
||||
->selectRaw('MAX(peers.updated_at) as updated_at')
|
||||
->selectRaw('COUNT(DISTINCT(peers.id)) as peer_count')
|
||||
->selectRaw('SUM(peers.connectable = 1) as connectable_count')
|
||||
->selectRaw('SUM(peers.connectable = 0) as unconnectable_count')
|
||||
->groupBy(['peers.user_id', 'peers.agent', 'peers.ip', 'peers.port'])
|
||||
->with(['user', 'user.group'])
|
||||
)
|
||||
->when(
|
||||
$this->groupBy === 'user_ip',
|
||||
fn ($query) => $query
|
||||
->select(['peers.user_id'])
|
||||
->selectRaw('COUNT(DISTINCT(peers.torrent_id)) as torrent_id')
|
||||
->selectRaw('COUNT(DISTINCT(peers.agent)) as agent')
|
||||
->selectRaw('INET6_NTOA(peers.ip) as ip')
|
||||
->selectRaw('COUNT(DISTINCT(peers.port)) as port')
|
||||
->selectRaw('SUM(peers.uploaded) as uploaded')
|
||||
->selectRaw('SUM(peers.downloaded) as downloaded')
|
||||
->selectRaw('SUM(`left`) as `left`')
|
||||
->selectRaw('MIN(peers.created_at) as created_at')
|
||||
->selectRaw('MAX(peers.updated_at) as updated_at')
|
||||
->selectRaw('COUNT(*) as peer_count')
|
||||
->selectRaw('SUM(peers.connectable = 1) as connectable_count')
|
||||
->selectRaw('SUM(peers.connectable = 0) as unconnectable_count')
|
||||
->groupBy(['peers.user_id', 'peers.ip'])
|
||||
->with(['user', 'user.group'])
|
||||
)
|
||||
->when(
|
||||
$this->groupBy === 'user',
|
||||
fn ($query) => $query
|
||||
->select(['peers.user_id'])
|
||||
->selectRaw('COUNT(DISTINCT(peers.torrent_id)) as torrent_id')
|
||||
->selectRaw('COUNT(DISTINCT(peers.agent)) as agent')
|
||||
->selectRaw('COUNT(DISTINCT(peers.ip)) as ip')
|
||||
->selectRaw('COUNT(DISTINCT(peers.port)) as port')
|
||||
->selectRaw('SUM(peers.uploaded) as uploaded')
|
||||
->selectRaw('SUM(peers.downloaded) as downloaded')
|
||||
->selectRaw('SUM(`left`) as `left`')
|
||||
->selectRaw('MIN(peers.created_at) as created_at')
|
||||
->selectRaw('MAX(peers.updated_at) as updated_at')
|
||||
->selectRaw('COUNT(*) as peer_count')
|
||||
->selectRaw('SUM(peers.connectable = 1) as connectable_count')
|
||||
->selectRaw('SUM(peers.connectable = 0) as unconnectable_count')
|
||||
->groupBy(['peers.user_id'])
|
||||
->with(['user', 'user.group'])
|
||||
)
|
||||
->when(
|
||||
$this->duplicateIpsOnly,
|
||||
fn ($query) => $query
|
||||
->whereIn(
|
||||
'peers.ip',
|
||||
Peer::query()
|
||||
->select('ip')
|
||||
->fromSub(Peer::select('ip', 'user_id')->distinct(), 'distinct_ips')
|
||||
->groupBy('ip')
|
||||
->havingRaw('COUNT(*) > 1')
|
||||
)
|
||||
)
|
||||
->when(
|
||||
$this->includeSeedsize,
|
||||
fn ($query) => $query
|
||||
->join('torrents', 'peers.torrent_id', '=', 'torrents.id')
|
||||
->when(
|
||||
$this->groupBy === 'none',
|
||||
fn ($query) => $query
|
||||
->selectRaw('torrents.size as size')
|
||||
->selectRaw('IF(peers.connectable = 1, torrents.size, 0) as connectable_size')
|
||||
->selectRaw('IF(peers.connectable = 0, torrents.size, 0) as unconnectable_size'),
|
||||
fn ($query) => $query
|
||||
->selectRaw('SUM(torrents.size) as size')
|
||||
->selectRaw('SUM(IF(peers.connectable = 1, torrents.size, 0)) as connectable_size')
|
||||
->selectRaw('SUM(IF(peers.connectable = 0, torrents.size, 0)) as unconnectable_size')
|
||||
)
|
||||
)
|
||||
->when($this->ip !== '', fn ($query) => $query->having('ip', 'LIKE', '%'.$this->ip.'%'))
|
||||
->when($this->port !== '', fn ($query) => $query->where('peers.port', '=', $this->port))
|
||||
->when($this->agent !== '', fn ($query) => $query->where('peers.agent', 'LIKE', '%'.$this->agent.'%'))
|
||||
->when($this->torrent !== '', fn ($query) => $query->whereIn(
|
||||
'torrents.name',
|
||||
Torrent::select('id')->where('name', 'LIKE', '%'.str_replace(' ', '%', $this->torrent).'%')
|
||||
))
|
||||
->when($this->connectivity === 'connectable', fn ($query) => $query->where('connectable', '=', 1))
|
||||
->when($this->connectivity === 'unconnectable', fn ($query) => $query->where('connectable', '=', 0))
|
||||
->orderBy($this->sortField, $this->sortDirection)
|
||||
->paginate($this->perPage);
|
||||
}
|
||||
|
||||
final public function sortBy($field): void
|
||||
{
|
||||
if ($this->sortField === $field) {
|
||||
$this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc';
|
||||
} else {
|
||||
$this->sortDirection = 'asc';
|
||||
}
|
||||
|
||||
$this->sortField = $field;
|
||||
}
|
||||
|
||||
final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application
|
||||
{
|
||||
return view('livewire.peer-search', [
|
||||
'peers' => $this->peers,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -27,13 +27,16 @@ use App\Models\TorrentFile;
|
||||
use App\Models\Tv;
|
||||
use App\Models\Warning;
|
||||
use Livewire\Component;
|
||||
use MarcReichel\IGDBLaravel\Models\Game;
|
||||
|
||||
class SimilarTorrent extends Component
|
||||
{
|
||||
public $categoryId;
|
||||
public Category $category;
|
||||
|
||||
public $tmdbId;
|
||||
|
||||
public $igdbId;
|
||||
|
||||
public $reason;
|
||||
|
||||
public $checked = [];
|
||||
@@ -71,24 +74,27 @@ class SimilarTorrent extends Component
|
||||
|
||||
final public function getTorrentsProperty(): \Illuminate\Support\Collection
|
||||
{
|
||||
$category = Category::findOrFail($this->categoryId);
|
||||
|
||||
$query = Torrent::query();
|
||||
$query = $query->with(['user:id,username,group_id', 'category', 'type', 'resolution'])
|
||||
->withCount(['thanks', 'comments']);
|
||||
if ($category->movie_meta) {
|
||||
->withCount(['thanks', 'comments'])
|
||||
->withExists(['bookmarks' => fn ($query) => $query->where('user_id', '=', auth()->id())]);
|
||||
if ($this->category->movie_meta) {
|
||||
$query = $query->whereHas('category', function ($q): void {
|
||||
$q->where('movie_meta', '=', true);
|
||||
});
|
||||
}
|
||||
|
||||
if ($category->tv_meta) {
|
||||
if ($this->category->tv_meta) {
|
||||
$query = $query->whereHas('category', function ($q): void {
|
||||
$q->where('tv_meta', '=', true);
|
||||
});
|
||||
}
|
||||
|
||||
$query = $query->where('tmdb', '=', $this->tmdbId);
|
||||
if ($this->category->tv_meta || $this->category->movie_meta) {
|
||||
$query = $query->where('tmdb', '=', $this->tmdbId);
|
||||
} else {
|
||||
$query = $query->where('igdb', '=', $this->igdbId);
|
||||
}
|
||||
$query = $query->orderBy($this->sortField, $this->sortDirection);
|
||||
|
||||
return $query->get();
|
||||
@@ -122,8 +128,13 @@ class SimilarTorrent extends Component
|
||||
$torrents = Torrent::whereKey($this->checked)->get();
|
||||
$names = [];
|
||||
$users = [];
|
||||
$titleids = [];
|
||||
$titles = [];
|
||||
$title = match (1) {
|
||||
$this->category->movie_meta => ($movie = Movie::find($this->tmdbId))->name.' ('.$movie->release_date.')',
|
||||
$this->category->tv_meta => ($tv = Tv::find($this->tmdbId))->name.' ('.$tv->first_air_date.')',
|
||||
$this->category->game_meta => ($game = Game::find($this->igdbId))->name.' ('.$game->first_release_date.')',
|
||||
default => $torrents->pluck('name')->join(', '),
|
||||
};
|
||||
|
||||
foreach ($torrents as $torrent) {
|
||||
$names[] = $torrent->name;
|
||||
foreach (History::where('torrent_id', '=', $torrent->id)->get() as $pm) {
|
||||
@@ -132,32 +143,6 @@ class SimilarTorrent extends Component
|
||||
}
|
||||
}
|
||||
|
||||
if (! \in_array($torrent->tmdb, $titleids)) {
|
||||
$titleids[] = $torrent->tmdb;
|
||||
$title = null;
|
||||
$cat = $torrent->category;
|
||||
$meta = 'none';
|
||||
|
||||
if ($cat->tv_meta === 1) {
|
||||
$meta = 'tv';
|
||||
} elseif ($cat->movie_meta === 1) {
|
||||
$meta = 'movie';
|
||||
}
|
||||
|
||||
switch ($meta) {
|
||||
case 'movie':
|
||||
$title = Movie::find($torrent->tmdb);
|
||||
$titles[] = $title->title.' ('.substr($title->release_date, 0, 4).')';
|
||||
break;
|
||||
case 'tv':
|
||||
$title = Tv::find($torrent->tmdb);
|
||||
$titles[] = $title->name.' ('.substr($title->first_air_date, 0, 4).')';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Reset Requests
|
||||
$torrent->requests()->update([
|
||||
'filled_by' => null,
|
||||
@@ -183,11 +168,12 @@ class SimilarTorrent extends Component
|
||||
$torrent->delete();
|
||||
}
|
||||
|
||||
|
||||
foreach ($users as $user) {
|
||||
$pmuser = new PrivateMessage();
|
||||
$pmuser->sender_id = 1;
|
||||
$pmuser->receiver_id = $user;
|
||||
$pmuser->subject = 'Bulk Torrents Deleted - '.implode(', ', $titles).'! ';
|
||||
$pmuser->subject = 'Bulk Torrents Deleted - '.$title.'! ';
|
||||
$pmuser->message = '[b]Attention: [/b] The following torrents have been removed from our site.
|
||||
[list]
|
||||
[*]'.implode(' [*]', $names).'
|
||||
|
||||
@@ -14,40 +14,32 @@
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\Torrent;
|
||||
use App\Models\User;
|
||||
use Livewire\Component;
|
||||
|
||||
class SmallBookmarkButton extends Component
|
||||
{
|
||||
public $torrent;
|
||||
|
||||
public ?\Illuminate\Contracts\Auth\Authenticatable $user = null;
|
||||
|
||||
final public function mount($torrent): void
|
||||
{
|
||||
$this->user = auth()->user();
|
||||
$this->torrent = Torrent::withAnyStatus()->findOrFail($torrent);
|
||||
}
|
||||
|
||||
final public function getIsBookmarkedProperty(): int
|
||||
{
|
||||
return $this->torrent->bookmarked() ? 1 : 0;
|
||||
}
|
||||
public Torrent $torrent;
|
||||
public bool $isBookmarked;
|
||||
public User $user;
|
||||
|
||||
final public function store(): void
|
||||
{
|
||||
if ($this->user->isBookmarked($this->torrent->id)) {
|
||||
if ($this->user->bookmarks()->where('torrent_id', '=', $this->torrent->id)->exists()) {
|
||||
$this->dispatchBrowserEvent('error', ['type' => 'error', 'message' => 'Torrent Has Already Been Bookmarked!']);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->user->bookmarks()->attach($this->torrent->id);
|
||||
$this->isBookmarked = true;
|
||||
$this->dispatchBrowserEvent('success', ['type' => 'success', 'message' => 'Torrent Has Been Bookmarked Successfully!']);
|
||||
}
|
||||
|
||||
final public function destroy(): void
|
||||
{
|
||||
$this->user->bookmarks()->detach($this->torrent->id);
|
||||
$this->isBookmarked = false;
|
||||
$this->dispatchBrowserEvent('success', ['type' => 'success', 'message' => 'Torrent Has Been Unbookmarked Successfully!']);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,15 +65,21 @@ class Top10 extends Component
|
||||
->get());
|
||||
}
|
||||
|
||||
final public function getPersonalFreeleechProperty()
|
||||
{
|
||||
return cache()->get('personal_freeleech:'.auth()->user()->id);
|
||||
}
|
||||
|
||||
final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application
|
||||
{
|
||||
return view('livewire.top10', [
|
||||
'user' => auth()->user(),
|
||||
'torrentsDay' => $this->torrentsDay,
|
||||
'torrentsWeek' => $this->torrentsWeek,
|
||||
'torrentsMonth' => $this->torrentsMonth,
|
||||
'torrentsYear' => $this->torrentsYear,
|
||||
'torrentsAll' => $this->torrentsAll,
|
||||
'user' => auth()->user(),
|
||||
'torrentsDay' => $this->torrentsDay,
|
||||
'torrentsWeek' => $this->torrentsWeek,
|
||||
'torrentsMonth' => $this->torrentsMonth,
|
||||
'torrentsYear' => $this->torrentsYear,
|
||||
'torrentsAll' => $this->torrentsAll,
|
||||
'personalFreeleech' => $this->personalFreeleech,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ class TopicPostSearch extends Component
|
||||
'likes' => fn ($query) => $query->where('like', '=', 1),
|
||||
'likes as dislike_count' => fn ($query) => $query->where('dislike', '=', 1),
|
||||
])
|
||||
->withSum('tips', 'cost')
|
||||
->where('topic_id', '=', $this->topic->id)
|
||||
->join('topics', 'topics.id', '=', 'posts.topic_id')
|
||||
->join(
|
||||
|
||||
@@ -1,256 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author HDVinnie <hdinnovations@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\Torrent;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
class TorrentCardSearch extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public string $name = '';
|
||||
|
||||
public string $description = '';
|
||||
|
||||
public string $mediainfo = '';
|
||||
|
||||
public string $uploader = '';
|
||||
|
||||
public string $keywords = '';
|
||||
|
||||
public string $startYear = '';
|
||||
|
||||
public string $endYear = '';
|
||||
|
||||
public array $categories = [];
|
||||
|
||||
public array $types = [];
|
||||
|
||||
public array $resolutions = [];
|
||||
|
||||
public array $genres = [];
|
||||
|
||||
public array $regions = [];
|
||||
|
||||
public array $distributors = [];
|
||||
|
||||
public string $tmdbId = '';
|
||||
|
||||
public string $imdbId = '';
|
||||
|
||||
public string $tvdbId = '';
|
||||
|
||||
public string $malId = '';
|
||||
|
||||
public string $playlistId = '';
|
||||
|
||||
public string $collectionId = '';
|
||||
|
||||
public array $free = [];
|
||||
|
||||
public bool $doubleup = false;
|
||||
|
||||
public bool $featured = false;
|
||||
|
||||
public bool $stream = false;
|
||||
|
||||
public bool $sd = false;
|
||||
|
||||
public bool $highspeed = false;
|
||||
|
||||
public bool $bookmarked = false;
|
||||
|
||||
public bool $wished = false;
|
||||
|
||||
public bool $internal = false;
|
||||
|
||||
public bool $personalRelease = false;
|
||||
|
||||
public bool $alive = false;
|
||||
|
||||
public bool $dying = false;
|
||||
|
||||
public bool $dead = false;
|
||||
|
||||
public bool $notDownloaded = false;
|
||||
|
||||
public bool $downloaded = false;
|
||||
|
||||
public bool $seeding = false;
|
||||
|
||||
public bool $leeching = false;
|
||||
|
||||
public bool $incomplete = false;
|
||||
|
||||
public int $perPage = 24;
|
||||
|
||||
public string $sortField = 'bumped_at';
|
||||
|
||||
public string $sortDirection = 'desc';
|
||||
|
||||
protected $queryString = [
|
||||
'name' => ['except' => ''],
|
||||
'description' => ['except' => ''],
|
||||
'mediainfo' => ['except' => ''],
|
||||
'uploader' => ['except' => ''],
|
||||
'keywords' => ['except' => ''],
|
||||
'startYear' => ['except' => ''],
|
||||
'endYear' => ['except' => ''],
|
||||
'categories' => ['except' => []],
|
||||
'types' => ['except' => []],
|
||||
'resolutions' => ['except' => []],
|
||||
'genres' => ['except' => []],
|
||||
'regions' => ['except' => []],
|
||||
'distributors' => ['except' => []],
|
||||
'tmdbId' => ['except' => ''],
|
||||
'imdbId' => ['except' => ''],
|
||||
'tvdbId' => ['except' => ''],
|
||||
'malId' => ['except' => ''],
|
||||
'playlistId' => ['except' => ''],
|
||||
'collectionId' => ['except' => ''],
|
||||
'free' => ['except' => []],
|
||||
'doubleup' => ['except' => false],
|
||||
'featured' => ['except' => false],
|
||||
'stream' => ['except' => false],
|
||||
'sd' => ['except' => false],
|
||||
'highspeed' => ['except' => false],
|
||||
'bookmarked' => ['except' => false],
|
||||
'wished' => ['except' => false],
|
||||
'internal' => ['except' => false],
|
||||
'personalRelease' => ['except' => false],
|
||||
'alive' => ['except' => false],
|
||||
'dying' => ['except' => false],
|
||||
'dead' => ['except' => false],
|
||||
'downloaded' => ['except' => false],
|
||||
'seeding' => ['except' => false],
|
||||
'leeching' => ['except' => false],
|
||||
'incomplete' => ['except' => false],
|
||||
'sortField' => ['except' => 'bumped_at'],
|
||||
'sortDirection' => ['except' => 'desc'],
|
||||
'page' => ['except' => 1],
|
||||
'perPage' => ['except' => ''],
|
||||
];
|
||||
|
||||
protected array $rules = [
|
||||
'genres.*' => 'exists:genres,id',
|
||||
];
|
||||
|
||||
final public function paginationView(): string
|
||||
{
|
||||
return 'vendor.pagination.livewire-pagination';
|
||||
}
|
||||
|
||||
final public function updatedPage(): void
|
||||
{
|
||||
$this->emit('paginationChanged');
|
||||
}
|
||||
|
||||
final public function updatingName(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
final public function getTorrentsStatProperty(): ?object
|
||||
{
|
||||
return DB::table('torrents')
|
||||
->selectRaw('count(*) as total')
|
||||
->selectRaw('count(case when seeders > 0 then 1 end) as alive')
|
||||
->selectRaw('count(case when seeders = 0 then 1 end) as dead')
|
||||
->first();
|
||||
}
|
||||
|
||||
final public function getPersonalFreeleechProperty()
|
||||
{
|
||||
return cache()->get('personal_freeleech:'.auth()->user()->id);
|
||||
}
|
||||
|
||||
final public function getTorrentsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
{
|
||||
$user = auth()->user();
|
||||
$isRegexAllowed = $user->group->is_modo;
|
||||
$isRegex = fn ($field) => $isRegexAllowed
|
||||
&& \strlen($field) > 2
|
||||
&& $field[0] === '/'
|
||||
&& $field[-1] === '/'
|
||||
&& @preg_match($field, 'Validate regex') !== false;
|
||||
|
||||
return Torrent::with(['user:id,username,group_id', 'user.group', 'category', 'type', 'resolution'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->when($this->name !== '', fn ($query) => $query->ofName($this->name, $isRegex($this->name)))
|
||||
->when($this->description !== '', fn ($query) => $query->ofDescription($this->description, $isRegex($this->description)))
|
||||
->when($this->mediainfo !== '', fn ($query) => $query->ofMediainfo($this->mediainfo, $isRegex($this->mediainfo)))
|
||||
->when($this->uploader !== '', fn ($query) => $query->ofUploader($this->uploader))
|
||||
->when($this->keywords !== '', fn ($query) => $query->ofKeyword(array_map('trim', explode(',', $this->keywords))))
|
||||
->when($this->startYear !== '', fn ($query) => $query->releasedAfterOrIn((int) $this->startYear))
|
||||
->when($this->endYear !== '', fn ($query) => $query->releasedBeforeOrIn((int) $this->endYear))
|
||||
->when($this->categories !== [], fn ($query) => $query->ofCategory($this->categories))
|
||||
->when($this->types !== [], fn ($query) => $query->ofType($this->types))
|
||||
->when($this->resolutions !== [], fn ($query) => $query->ofResolution($this->resolutions))
|
||||
->when($this->genres !== [], fn ($query) => $query->ofGenre($this->genres))
|
||||
->when($this->regions !== [], fn ($query) => $query->ofRegion($this->regions))
|
||||
->when($this->distributors !== [], fn ($query) => $query->ofDistributor($this->distributors))
|
||||
->when($this->tmdbId !== '', fn ($query) => $query->ofTmdb((int) $this->tmdbId))
|
||||
->when($this->imdbId !== '', fn ($query) => $query->ofImdb((int) (preg_match('/tt0*(?=(\d{7,}))/', $this->imdbId, $matches) ? $matches[1] : $this->imdbId)))
|
||||
->when($this->tvdbId !== '', fn ($query) => $query->ofTvdb((int) $this->tvdbId))
|
||||
->when($this->malId !== '', fn ($query) => $query->ofMal((int) $this->malId))
|
||||
->when($this->playlistId !== '', fn ($query) => $query->ofPlaylist((int) $this->playlistId))
|
||||
->when($this->collectionId !== '', fn ($query) => $query->ofCollection((int) $this->collectionId))
|
||||
->when($this->free !== [], fn ($query) => $query->ofFreeleech($this->free))
|
||||
->when($this->doubleup !== false, fn ($query) => $query->doubleup())
|
||||
->when($this->featured !== false, fn ($query) => $query->featured())
|
||||
->when($this->stream !== false, fn ($query) => $query->streamOptimized())
|
||||
->when($this->sd !== false, fn ($query) => $query->sd())
|
||||
->when($this->highspeed !== false, fn ($query) => $query->highspeed())
|
||||
->when($this->bookmarked !== false, fn ($query) => $query->bookmarkedBy($user))
|
||||
->when($this->wished !== false, fn ($query) => $query->wishedBy($user))
|
||||
->when($this->internal !== false, fn ($query) => $query->internal())
|
||||
->when($this->personalRelease !== false, fn ($query) => $query->personalRelease())
|
||||
->when($this->alive !== false, fn ($query) => $query->alive())
|
||||
->when($this->dying !== false, fn ($query) => $query->dying())
|
||||
->when($this->dead !== false, fn ($query) => $query->dead())
|
||||
->when($this->notDownloaded !== false, fn ($query) => $query->notDownloadedBy($user))
|
||||
->when($this->downloaded !== false, fn ($query) => $query->downloadedBy($user))
|
||||
->when($this->seeding !== false, fn ($query) => $query->seededBy($user))
|
||||
->when($this->leeching !== false, fn ($query) => $query->leechedBy($user))
|
||||
->when($this->incomplete !== false, fn ($query) => $query->uncompletedBy($user))
|
||||
->latest('sticky')
|
||||
->orderBy($this->sortField, $this->sortDirection)
|
||||
->paginate($this->perPage);
|
||||
}
|
||||
|
||||
final public function sortBy($field): void
|
||||
{
|
||||
if ($this->sortField === $field) {
|
||||
$this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc';
|
||||
} else {
|
||||
$this->sortDirection = 'asc';
|
||||
}
|
||||
|
||||
$this->sortField = $field;
|
||||
}
|
||||
|
||||
final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application
|
||||
{
|
||||
return view('livewire.torrent-card-search', [
|
||||
'user' => User::with(['history:id,seeder,active,completed_at,torrent_id,user_id', 'group'])->findOrFail(auth()->user()->id),
|
||||
'torrents' => $this->torrents,
|
||||
'torrentsStat' => $this->torrentsStat,
|
||||
'personalFreeleech' => $this->personalFreeleech,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,247 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.tx
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author HDVinnie <hdinnovations@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\Torrent;
|
||||
use App\Models\User;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
class TorrentGroupSearch extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public string $name = '';
|
||||
|
||||
public string $description = '';
|
||||
|
||||
public string $mediainfo = '';
|
||||
|
||||
public string $uploader = '';
|
||||
|
||||
public string $keywords = '';
|
||||
|
||||
public string $startYear = '';
|
||||
|
||||
public string $endYear = '';
|
||||
|
||||
public array $categories = [];
|
||||
|
||||
public array $types = [];
|
||||
|
||||
public array $resolutions = [];
|
||||
|
||||
public array $genres = [];
|
||||
|
||||
public array $regions = [];
|
||||
|
||||
public array $distributors = [];
|
||||
|
||||
public string $tmdbId = '';
|
||||
|
||||
public string $imdbId = '';
|
||||
|
||||
public string $tvdbId = '';
|
||||
|
||||
public string $malId = '';
|
||||
|
||||
public string $playlistId = '';
|
||||
|
||||
public string $collectionId = '';
|
||||
|
||||
public array $free = [];
|
||||
|
||||
public bool $doubleup = false;
|
||||
|
||||
public bool $featured = false;
|
||||
|
||||
public bool $stream = false;
|
||||
|
||||
public bool $sd = false;
|
||||
|
||||
public bool $highspeed = false;
|
||||
|
||||
public bool $bookmarked = false;
|
||||
|
||||
public bool $wished = false;
|
||||
|
||||
public bool $internal = false;
|
||||
|
||||
public bool $personalRelease = false;
|
||||
|
||||
public bool $alive = false;
|
||||
|
||||
public bool $dying = false;
|
||||
|
||||
public bool $dead = false;
|
||||
|
||||
public bool $notDownloaded = false;
|
||||
|
||||
public bool $downloaded = false;
|
||||
|
||||
public bool $seeding = false;
|
||||
|
||||
public bool $leeching = false;
|
||||
|
||||
public bool $incomplete = false;
|
||||
|
||||
public int $perPage = 25;
|
||||
|
||||
public string $sortField = 'bumped_at';
|
||||
|
||||
public string $sortDirection = 'desc';
|
||||
|
||||
protected $queryString = [
|
||||
'name' => ['except' => ''],
|
||||
'description' => ['except' => ''],
|
||||
'mediainfo' => ['except' => ''],
|
||||
'uploader' => ['except' => ''],
|
||||
'keywords' => ['except' => ''],
|
||||
'startYear' => ['except' => ''],
|
||||
'endYear' => ['except' => ''],
|
||||
'categories' => ['except' => []],
|
||||
'types' => ['except' => []],
|
||||
'resolutions' => ['except' => []],
|
||||
'genres' => ['except' => []],
|
||||
'regions' => ['except' => []],
|
||||
'distributors' => ['except' => []],
|
||||
'tmdbId' => ['except' => ''],
|
||||
'imdbId' => ['except' => ''],
|
||||
'tvdbId' => ['except' => ''],
|
||||
'malId' => ['except' => ''],
|
||||
'playlistId' => ['except' => ''],
|
||||
'collectionId' => ['except' => ''],
|
||||
'free' => ['except' => []],
|
||||
'doubleup' => ['except' => false],
|
||||
'featured' => ['except' => false],
|
||||
'stream' => ['except' => false],
|
||||
'sd' => ['except' => false],
|
||||
'highspeed' => ['except' => false],
|
||||
'bookmarked' => ['except' => false],
|
||||
'wished' => ['except' => false],
|
||||
'internal' => ['except' => false],
|
||||
'personalRelease' => ['except' => false],
|
||||
'alive' => ['except' => false],
|
||||
'dying' => ['except' => false],
|
||||
'dead' => ['except' => false],
|
||||
'downloaded' => ['except' => false],
|
||||
'seeding' => ['except' => false],
|
||||
'leeching' => ['except' => false],
|
||||
'incomplete' => ['except' => false],
|
||||
'sortField' => ['except' => 'bumped_at'],
|
||||
'sortDirection' => ['except' => 'desc'],
|
||||
'page' => ['except' => 1],
|
||||
'perPage' => ['except' => ''],
|
||||
];
|
||||
|
||||
protected array $rules = [
|
||||
'genres.*' => 'exists:genres,id',
|
||||
];
|
||||
|
||||
final public function paginationView(): string
|
||||
{
|
||||
return 'vendor.pagination.livewire-pagination';
|
||||
}
|
||||
|
||||
final public function updatedPage(): void
|
||||
{
|
||||
$this->emit('paginationChanged');
|
||||
}
|
||||
|
||||
final public function updatingName(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
final public function getPersonalFreeleechProperty()
|
||||
{
|
||||
return cache()->get('personal_freeleech:'.auth()->user()->id);
|
||||
}
|
||||
|
||||
final public function getTorrentsProperty()
|
||||
{
|
||||
$user = auth()->user();
|
||||
$isRegexAllowed = $user->group->is_modo;
|
||||
$isRegex = fn ($field) => $isRegexAllowed
|
||||
&& \strlen($field) > 2
|
||||
&& $field[0] === '/'
|
||||
&& $field[-1] === '/'
|
||||
&& @preg_match($field, 'Validate regex') !== false;
|
||||
|
||||
return Torrent::with(['user:id,username,group_id', 'user.group', 'category', 'type', 'resolution'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->where('imdb', '!=', '0')
|
||||
->when($this->name !== '', fn ($query) => $query->ofName($this->name, $isRegex($this->name)))
|
||||
->when($this->description !== '', fn ($query) => $query->ofDescription($this->description, $isRegex($this->description)))
|
||||
->when($this->mediainfo !== '', fn ($query) => $query->ofMediainfo($this->mediainfo, $isRegex($this->mediainfo)))
|
||||
->when($this->uploader !== '', fn ($query) => $query->ofUploader($this->uploader))
|
||||
->when($this->keywords !== '', fn ($query) => $query->ofKeyword(array_map('trim', explode(',', $this->keywords))))
|
||||
->when($this->startYear !== '', fn ($query) => $query->releasedAfterOrIn((int) $this->startYear))
|
||||
->when($this->endYear !== '', fn ($query) => $query->releasedBeforeOrIn((int) $this->endYear))
|
||||
->when($this->categories !== [], fn ($query) => $query->ofCategory($this->categories))
|
||||
->when($this->types !== [], fn ($query) => $query->ofType($this->types))
|
||||
->when($this->resolutions !== [], fn ($query) => $query->ofResolution($this->resolutions))
|
||||
->when($this->genres !== [], fn ($query) => $query->ofGenre($this->genres))
|
||||
->when($this->regions !== [], fn ($query) => $query->ofRegion($this->regions))
|
||||
->when($this->distributors !== [], fn ($query) => $query->ofDistributor($this->distributors))
|
||||
->when($this->tmdbId !== '', fn ($query) => $query->ofTmdb((int) $this->tmdbId))
|
||||
->when($this->imdbId !== '', fn ($query) => $query->ofImdb((int) (preg_match('/tt0*(?=(\d{7,}))/', $this->imdbId, $matches) ? $matches[1] : $this->imdbId)))
|
||||
->when($this->tvdbId !== '', fn ($query) => $query->ofTvdb((int) $this->tvdbId))
|
||||
->when($this->malId !== '', fn ($query) => $query->ofMal((int) $this->malId))
|
||||
->when($this->playlistId !== '', fn ($query) => $query->ofPlaylist((int) $this->playlistId))
|
||||
->when($this->collectionId !== '', fn ($query) => $query->ofCollection((int) $this->collectionId))
|
||||
->when($this->free !== [], fn ($query) => $query->ofFreeleech($this->free))
|
||||
->when($this->doubleup !== false, fn ($query) => $query->doubleup())
|
||||
->when($this->featured !== false, fn ($query) => $query->featured())
|
||||
->when($this->stream !== false, fn ($query) => $query->streamOptimized())
|
||||
->when($this->sd !== false, fn ($query) => $query->sd())
|
||||
->when($this->highspeed !== false, fn ($query) => $query->highspeed())
|
||||
->when($this->bookmarked !== false, fn ($query) => $query->bookmarkedBy($user))
|
||||
->when($this->wished !== false, fn ($query) => $query->wishedBy($user))
|
||||
->when($this->internal !== false, fn ($query) => $query->internal())
|
||||
->when($this->personalRelease !== false, fn ($query) => $query->personalRelease())
|
||||
->when($this->alive !== false, fn ($query) => $query->alive())
|
||||
->when($this->dying !== false, fn ($query) => $query->dying())
|
||||
->when($this->dead !== false, fn ($query) => $query->dead())
|
||||
->when($this->notDownloaded !== false, fn ($query) => $query->notDownloadedBy($user))
|
||||
->when($this->downloaded !== false, fn ($query) => $query->downloadedBy($user))
|
||||
->when($this->seeding !== false, fn ($query) => $query->seededBy($user))
|
||||
->when($this->leeching !== false, fn ($query) => $query->leechedBy($user))
|
||||
->when($this->incomplete !== false, fn ($query) => $query->uncompletedBy($user))
|
||||
->latest('sticky')
|
||||
->lastPerGroup(['imdb'])
|
||||
->orderBy($this->sortField, $this->sortDirection)
|
||||
->paginate($this->perPage);
|
||||
}
|
||||
|
||||
final public function sortBy($field): void
|
||||
{
|
||||
if ($this->sortField === $field) {
|
||||
$this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc';
|
||||
} else {
|
||||
$this->sortDirection = 'asc';
|
||||
}
|
||||
|
||||
$this->sortField = $field;
|
||||
}
|
||||
|
||||
final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application
|
||||
{
|
||||
return view('livewire.torrent-group-search', [
|
||||
'user' => User::with(['group'])->findOrFail(auth()->user()->id),
|
||||
'medias' => $this->torrents,
|
||||
'personalFreeleech' => $this->personalFreeleech,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,245 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author HDVinnie <hdinnovations@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\Torrent;
|
||||
use App\Models\User;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
class TorrentListSearch extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public string $name = '';
|
||||
|
||||
public string $description = '';
|
||||
|
||||
public string $mediainfo = '';
|
||||
|
||||
public string $uploader = '';
|
||||
|
||||
public string $keywords = '';
|
||||
|
||||
public string $startYear = '';
|
||||
|
||||
public string $endYear = '';
|
||||
|
||||
public array $categories = [];
|
||||
|
||||
public array $types = [];
|
||||
|
||||
public array $resolutions = [];
|
||||
|
||||
public array $genres = [];
|
||||
|
||||
public array $regions = [];
|
||||
|
||||
public array $distributors = [];
|
||||
|
||||
public string $tmdbId = '';
|
||||
|
||||
public string $imdbId = '';
|
||||
|
||||
public string $tvdbId = '';
|
||||
|
||||
public string $malId = '';
|
||||
|
||||
public string $playlistId = '';
|
||||
|
||||
public string $collectionId = '';
|
||||
|
||||
public array $free = [];
|
||||
|
||||
public bool $doubleup = false;
|
||||
|
||||
public bool $featured = false;
|
||||
|
||||
public bool $stream = false;
|
||||
|
||||
public bool $sd = false;
|
||||
|
||||
public bool $highspeed = false;
|
||||
|
||||
public bool $bookmarked = false;
|
||||
|
||||
public bool $wished = false;
|
||||
|
||||
public bool $internal = false;
|
||||
|
||||
public bool $personalRelease = false;
|
||||
|
||||
public bool $alive = false;
|
||||
|
||||
public bool $dying = false;
|
||||
|
||||
public bool $dead = false;
|
||||
|
||||
public bool $notDownloaded = false;
|
||||
|
||||
public bool $downloaded = false;
|
||||
|
||||
public bool $seeding = false;
|
||||
|
||||
public bool $leeching = false;
|
||||
|
||||
public bool $incomplete = false;
|
||||
|
||||
public int $perPage = 25;
|
||||
|
||||
public string $sortField = 'bumped_at';
|
||||
|
||||
public string $sortDirection = 'desc';
|
||||
|
||||
protected $queryString = [
|
||||
'name' => ['except' => ''],
|
||||
'description' => ['except' => ''],
|
||||
'mediainfo' => ['except' => ''],
|
||||
'uploader' => ['except' => ''],
|
||||
'keywords' => ['except' => ''],
|
||||
'startYear' => ['except' => ''],
|
||||
'endYear' => ['except' => ''],
|
||||
'categories' => ['except' => []],
|
||||
'types' => ['except' => []],
|
||||
'resolutions' => ['except' => []],
|
||||
'genres' => ['except' => []],
|
||||
'regions' => ['except' => []],
|
||||
'distributors' => ['except' => []],
|
||||
'tmdbId' => ['except' => ''],
|
||||
'imdbId' => ['except' => ''],
|
||||
'tvdbId' => ['except' => ''],
|
||||
'malId' => ['except' => ''],
|
||||
'playlistId' => ['except' => ''],
|
||||
'collectionId' => ['except' => ''],
|
||||
'free' => ['except' => []],
|
||||
'doubleup' => ['except' => false],
|
||||
'featured' => ['except' => false],
|
||||
'stream' => ['except' => false],
|
||||
'sd' => ['except' => false],
|
||||
'highspeed' => ['except' => false],
|
||||
'bookmarked' => ['except' => false],
|
||||
'wished' => ['except' => false],
|
||||
'internal' => ['except' => false],
|
||||
'personalRelease' => ['except' => false],
|
||||
'alive' => ['except' => false],
|
||||
'dying' => ['except' => false],
|
||||
'dead' => ['except' => false],
|
||||
'downloaded' => ['except' => false],
|
||||
'seeding' => ['except' => false],
|
||||
'leeching' => ['except' => false],
|
||||
'incomplete' => ['except' => false],
|
||||
'sortField' => ['except' => 'bumped_at'],
|
||||
'sortDirection' => ['except' => 'desc'],
|
||||
'page' => ['except' => 1],
|
||||
'perPage' => ['except' => ''],
|
||||
];
|
||||
|
||||
protected array $rules = [
|
||||
'genres.*' => 'exists:genres,id',
|
||||
];
|
||||
|
||||
final public function paginationView(): string
|
||||
{
|
||||
return 'vendor.pagination.livewire-pagination';
|
||||
}
|
||||
|
||||
final public function updatedPage(): void
|
||||
{
|
||||
$this->emit('paginationChanged');
|
||||
}
|
||||
|
||||
final public function updatingName(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
final public function getPersonalFreeleechProperty()
|
||||
{
|
||||
return cache()->get('personal_freeleech:'.auth()->user()->id);
|
||||
}
|
||||
|
||||
final public function getTorrentsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
{
|
||||
$user = auth()->user();
|
||||
$isRegexAllowed = $user->group->is_modo;
|
||||
$isRegex = fn ($field) => $isRegexAllowed
|
||||
&& \strlen($field) > 2
|
||||
&& $field[0] === '/'
|
||||
&& $field[-1] === '/'
|
||||
&& @preg_match($field, 'Validate regex') !== false;
|
||||
|
||||
return Torrent::with(['user:id,username,group_id', 'user.group', 'category', 'type', 'resolution'])
|
||||
->withCount(['thanks', 'comments'])
|
||||
->when($this->name !== '', fn ($query) => $query->ofName($this->name, $isRegex($this->name)))
|
||||
->when($this->description !== '', fn ($query) => $query->ofDescription($this->description, $isRegex($this->description)))
|
||||
->when($this->mediainfo !== '', fn ($query) => $query->ofMediainfo($this->mediainfo, $isRegex($this->mediainfo)))
|
||||
->when($this->uploader !== '', fn ($query) => $query->ofUploader($this->uploader))
|
||||
->when($this->keywords !== '', fn ($query) => $query->ofKeyword(array_map('trim', explode(',', $this->keywords))))
|
||||
->when($this->startYear !== '', fn ($query) => $query->releasedAfterOrIn((int) $this->startYear))
|
||||
->when($this->endYear !== '', fn ($query) => $query->releasedBeforeOrIn((int) $this->endYear))
|
||||
->when($this->categories !== [], fn ($query) => $query->ofCategory($this->categories))
|
||||
->when($this->types !== [], fn ($query) => $query->ofType($this->types))
|
||||
->when($this->resolutions !== [], fn ($query) => $query->ofResolution($this->resolutions))
|
||||
->when($this->genres !== [], fn ($query) => $query->ofGenre($this->genres))
|
||||
->when($this->regions !== [], fn ($query) => $query->ofRegion($this->regions))
|
||||
->when($this->distributors !== [], fn ($query) => $query->ofDistributor($this->distributors))
|
||||
->when($this->tmdbId !== '', fn ($query) => $query->ofTmdb((int) $this->tmdbId))
|
||||
->when($this->imdbId !== '', fn ($query) => $query->ofImdb((int) (preg_match('/tt0*(?=(\d{7,}))/', $this->imdbId, $matches) ? $matches[1] : $this->imdbId)))
|
||||
->when($this->tvdbId !== '', fn ($query) => $query->ofTvdb((int) $this->tvdbId))
|
||||
->when($this->malId !== '', fn ($query) => $query->ofMal((int) $this->malId))
|
||||
->when($this->playlistId !== '', fn ($query) => $query->ofPlaylist((int) $this->playlistId))
|
||||
->when($this->collectionId !== '', fn ($query) => $query->ofCollection((int) $this->collectionId))
|
||||
->when($this->free !== [], fn ($query) => $query->ofFreeleech($this->free))
|
||||
->when($this->doubleup !== false, fn ($query) => $query->doubleup())
|
||||
->when($this->featured !== false, fn ($query) => $query->featured())
|
||||
->when($this->stream !== false, fn ($query) => $query->streamOptimized())
|
||||
->when($this->sd !== false, fn ($query) => $query->sd())
|
||||
->when($this->highspeed !== false, fn ($query) => $query->highspeed())
|
||||
->when($this->bookmarked !== false, fn ($query) => $query->bookmarkedBy($user))
|
||||
->when($this->wished !== false, fn ($query) => $query->wishedBy($user))
|
||||
->when($this->internal !== false, fn ($query) => $query->internal())
|
||||
->when($this->personalRelease !== false, fn ($query) => $query->personalRelease())
|
||||
->when($this->alive !== false, fn ($query) => $query->alive())
|
||||
->when($this->dying !== false, fn ($query) => $query->dying())
|
||||
->when($this->dead !== false, fn ($query) => $query->dead())
|
||||
->when($this->notDownloaded !== false, fn ($query) => $query->notDownloadedBy($user))
|
||||
->when($this->downloaded !== false, fn ($query) => $query->downloadedBy($user))
|
||||
->when($this->seeding !== false, fn ($query) => $query->seededBy($user))
|
||||
->when($this->leeching !== false, fn ($query) => $query->leechedBy($user))
|
||||
->when($this->incomplete !== false, fn ($query) => $query->uncompletedBy($user))
|
||||
->latest('sticky')
|
||||
->orderBy($this->sortField, $this->sortDirection)
|
||||
->paginate($this->perPage);
|
||||
}
|
||||
|
||||
final public function sortBy($field): void
|
||||
{
|
||||
if ($this->sortField === $field) {
|
||||
$this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc';
|
||||
} else {
|
||||
$this->sortDirection = 'asc';
|
||||
}
|
||||
|
||||
$this->sortField = $field;
|
||||
}
|
||||
|
||||
final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application
|
||||
{
|
||||
return view('livewire.torrent-list-search', [
|
||||
'user' => User::with(['group'])->findOrFail(auth()->user()->id),
|
||||
'torrents' => $this->torrents,
|
||||
'personalFreeleech' => $this->personalFreeleech,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,6 @@ namespace App\Http\Livewire;
|
||||
use App\Models\TorrentRequest;
|
||||
use App\Models\TorrentRequestBounty;
|
||||
use App\Models\TorrentRequestClaim;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
@@ -128,46 +127,25 @@ class TorrentRequestSearch extends Component
|
||||
|
||||
final public function getTorrentRequestsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
{
|
||||
$user = auth()->user();
|
||||
$isRegexAllowed = $user->group->is_modo;
|
||||
$isRegex = fn ($field) => $isRegexAllowed
|
||||
&& \strlen($field) > 2
|
||||
&& $field[0] === '/'
|
||||
&& $field[-1] === '/'
|
||||
&& @preg_match($field, 'Validate regex') !== false;
|
||||
|
||||
return TorrentRequest::with(['category', 'type', 'resolution'])
|
||||
->withCount(['comments'])
|
||||
->when($this->name, function ($query): void {
|
||||
$query->where('name', 'LIKE', '%'.$this->name.'%');
|
||||
})
|
||||
->when($this->requestor, function ($query): void {
|
||||
$match = User::where('username', 'LIKE', '%'.$this->requestor.'%')->oldest('username')->first();
|
||||
if ($match) {
|
||||
$query
|
||||
->where('user_id', '=', $match->id)
|
||||
->when(! (auth()->user()->group->is_modo || auth()->user()->id === $match->id), function ($query): void {
|
||||
$query->where('anon', '=', 0);
|
||||
});
|
||||
}
|
||||
})
|
||||
->when($this->categories, function ($query): void {
|
||||
$query->whereIntegerInRaw('category_id', $this->categories);
|
||||
})
|
||||
->when($this->types, function ($query): void {
|
||||
$query->whereIntegerInRaw('type_id', $this->types);
|
||||
})
|
||||
->when($this->resolutions, function ($query): void {
|
||||
$query->whereIntegerInRaw('resolution_id', $this->resolutions);
|
||||
})
|
||||
->when($this->tmdbId, function ($query): void {
|
||||
$query->where('tmdb', '=', $this->tmdbId);
|
||||
})
|
||||
->when($this->imdbId, function ($query): void {
|
||||
if (preg_match('/tt0*?(?=(\d{7,8}))/', $this->imdbId, $matches)) {
|
||||
$query->where('imdb', '=', $matches[1]);
|
||||
} else {
|
||||
$query->where('imdb', '=', $this->imdbId);
|
||||
}
|
||||
})
|
||||
->when($this->tvdbId, function ($query): void {
|
||||
$query->where('tvdb', '=', $this->tvdbId);
|
||||
})
|
||||
->when($this->malId, function ($query): void {
|
||||
$query->where('mal', '=', $this->malId);
|
||||
})
|
||||
->when($this->name !== '', fn ($query) => $query->ofName($this->name, $isRegex($this->name)))
|
||||
->when($this->requestor !== '', fn ($query) => $query->ofUploader($this->requestor))
|
||||
->when($this->categories !== [], fn ($query) => $query->ofCategory($this->categories))
|
||||
->when($this->types !== [], fn ($query) => $query->ofType($this->types))
|
||||
->when($this->resolutions !== [], fn ($query) => $query->ofResolution($this->resolutions))
|
||||
->when($this->tmdbId !== '', fn ($query) => $query->ofTmdb((int) $this->tmdbId))
|
||||
->when($this->imdbId !== '', fn ($query) => $query->ofImdb((int) (preg_match('/tt0*(?=(\d{7,}))/', $this->imdbId, $matches) ? $matches[1] : $this->imdbId)))
|
||||
->when($this->tvdbId !== '', fn ($query) => $query->ofTvdb((int) $this->tvdbId))
|
||||
->when($this->malId !== '', fn ($query) => $query->ofMal((int) $this->malId))
|
||||
->when($this->unfilled || $this->claimed || $this->pending || $this->filled, function ($query): void {
|
||||
$query->where(function ($query): void {
|
||||
$query->where(function ($query): void {
|
||||
@@ -192,19 +170,19 @@ class TorrentRequestSearch extends Component
|
||||
});
|
||||
});
|
||||
})
|
||||
->when($this->myRequests, function ($query): void {
|
||||
$query->where('user_id', '=', auth()->user()->id);
|
||||
->when($this->myRequests, function ($query) use ($user): void {
|
||||
$query->where('user_id', '=', $user->id);
|
||||
})
|
||||
->when($this->myClaims, function ($query): void {
|
||||
$requestClaims = TorrentRequestClaim::where('username', '=', auth()->user()->username)->pluck('request_id');
|
||||
->when($this->myClaims, function ($query) use ($user): void {
|
||||
$requestClaims = TorrentRequestClaim::where('username', '=', $user->username)->pluck('request_id');
|
||||
$query->whereIntegerInRaw('id', $requestClaims)->whereNull('torrent_id')->whereNull('approved_by');
|
||||
})
|
||||
->when($this->myVoted, function ($query): void {
|
||||
$requestVotes = TorrentRequestBounty::where('user_id', '=', auth()->user()->id)->pluck('requests_id');
|
||||
->when($this->myVoted, function ($query) use ($user): void {
|
||||
$requestVotes = TorrentRequestBounty::where('user_id', '=', $user->id)->pluck('requests_id');
|
||||
$query->whereIntegerInRaw('id', $requestVotes);
|
||||
})
|
||||
->when($this->myFilled, function ($query): void {
|
||||
$query->where('filled_by', '=', auth()->user()->id);
|
||||
->when($this->myFilled, function ($query) use ($user): void {
|
||||
$query->where('filled_by', '=', $user->id);
|
||||
})
|
||||
->orderBy($this->sortField, $this->sortDirection)
|
||||
->paginate($this->perPage);
|
||||
|
||||
@@ -0,0 +1,585 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.tx
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author HDVinnie <hdinnovations@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\Movie;
|
||||
use App\Models\Torrent;
|
||||
use App\Models\Tv;
|
||||
use App\Models\User;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
class TorrentSearch extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public string $name = '';
|
||||
|
||||
public string $description = '';
|
||||
|
||||
public string $mediainfo = '';
|
||||
|
||||
public string $uploader = '';
|
||||
|
||||
public string $keywords = '';
|
||||
|
||||
public string $startYear = '';
|
||||
|
||||
public string $endYear = '';
|
||||
|
||||
public array $categories = [];
|
||||
|
||||
public array $types = [];
|
||||
|
||||
public array $resolutions = [];
|
||||
|
||||
public array $genres = [];
|
||||
|
||||
public array $regions = [];
|
||||
|
||||
public array $distributors = [];
|
||||
|
||||
public string $tmdbId = '';
|
||||
|
||||
public string $imdbId = '';
|
||||
|
||||
public string $tvdbId = '';
|
||||
|
||||
public string $malId = '';
|
||||
|
||||
public string $playlistId = '';
|
||||
|
||||
public string $collectionId = '';
|
||||
|
||||
public string $networkId = '';
|
||||
|
||||
public string $companyId = '';
|
||||
|
||||
public array $free = [];
|
||||
|
||||
public bool $doubleup = false;
|
||||
|
||||
public bool $featured = false;
|
||||
|
||||
public bool $stream = false;
|
||||
|
||||
public bool $sd = false;
|
||||
|
||||
public bool $highspeed = false;
|
||||
|
||||
public bool $bookmarked = false;
|
||||
|
||||
public bool $wished = false;
|
||||
|
||||
public bool $internal = false;
|
||||
|
||||
public bool $personalRelease = false;
|
||||
|
||||
public bool $alive = false;
|
||||
|
||||
public bool $dying = false;
|
||||
|
||||
public bool $dead = false;
|
||||
|
||||
public bool $notDownloaded = false;
|
||||
|
||||
public bool $downloaded = false;
|
||||
|
||||
public bool $seeding = false;
|
||||
|
||||
public bool $leeching = false;
|
||||
|
||||
public bool $incomplete = false;
|
||||
|
||||
public int $perPage = 25;
|
||||
|
||||
public string $sortField = 'bumped_at';
|
||||
|
||||
public string $sortDirection = 'desc';
|
||||
|
||||
public string $view = 'list';
|
||||
|
||||
protected $queryString = [
|
||||
'name' => ['except' => ''],
|
||||
'description' => ['except' => ''],
|
||||
'mediainfo' => ['except' => ''],
|
||||
'uploader' => ['except' => ''],
|
||||
'keywords' => ['except' => ''],
|
||||
'startYear' => ['except' => ''],
|
||||
'endYear' => ['except' => ''],
|
||||
'categories' => ['except' => []],
|
||||
'types' => ['except' => []],
|
||||
'resolutions' => ['except' => []],
|
||||
'genres' => ['except' => []],
|
||||
'regions' => ['except' => []],
|
||||
'distributors' => ['except' => []],
|
||||
'tmdbId' => ['except' => ''],
|
||||
'imdbId' => ['except' => ''],
|
||||
'tvdbId' => ['except' => ''],
|
||||
'malId' => ['except' => ''],
|
||||
'playlistId' => ['except' => ''],
|
||||
'collectionId' => ['except' => ''],
|
||||
'companyId' => ['except' => ''],
|
||||
'networkId' => ['except' => ''],
|
||||
'free' => ['except' => []],
|
||||
'doubleup' => ['except' => false],
|
||||
'featured' => ['except' => false],
|
||||
'stream' => ['except' => false],
|
||||
'sd' => ['except' => false],
|
||||
'highspeed' => ['except' => false],
|
||||
'bookmarked' => ['except' => false],
|
||||
'wished' => ['except' => false],
|
||||
'internal' => ['except' => false],
|
||||
'personalRelease' => ['except' => false],
|
||||
'alive' => ['except' => false],
|
||||
'dying' => ['except' => false],
|
||||
'dead' => ['except' => false],
|
||||
'downloaded' => ['except' => false],
|
||||
'seeding' => ['except' => false],
|
||||
'leeching' => ['except' => false],
|
||||
'incomplete' => ['except' => false],
|
||||
'page' => ['except' => 1],
|
||||
'perPage' => ['except' => ''],
|
||||
'view' => ['except' => 'list'],
|
||||
];
|
||||
|
||||
final public function paginationView(): string
|
||||
{
|
||||
return 'vendor.pagination.livewire-pagination';
|
||||
}
|
||||
|
||||
final public function updatedPage(): void
|
||||
{
|
||||
$this->emit('paginationChanged');
|
||||
}
|
||||
|
||||
final public function updatingName(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
final public function updatedView(): void
|
||||
{
|
||||
$this->perPage = $this->view === 'card' ? 24 : 25;
|
||||
}
|
||||
|
||||
final public function getPersonalFreeleechProperty()
|
||||
{
|
||||
return cache()->get('personal_freeleech:'.auth()->user()->id);
|
||||
}
|
||||
|
||||
final public function getTorrentsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||
{
|
||||
$user = auth()->user();
|
||||
$isRegexAllowed = $user->group->is_modo;
|
||||
$isRegex = fn ($field) => $isRegexAllowed
|
||||
&& \strlen($field) > 2
|
||||
&& $field[0] === '/'
|
||||
&& $field[-1] === '/'
|
||||
&& @preg_match($field, 'Validate regex') !== false;
|
||||
|
||||
$torrents = Torrent::with(['user:id,username,group_id', 'user.group', 'category', 'type', 'resolution'])
|
||||
->when($this->view === 'list', fn ($query) => $query->withCount(['thanks', 'comments']))
|
||||
->withExists([
|
||||
'bookmarks' => fn ($query) => $query->where('user_id', '=', auth()->id()),
|
||||
'freeleechTokens' => fn ($query) => $query->where('user_id', '=', auth()->id()),
|
||||
])
|
||||
->selectRaw("
|
||||
CASE
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `movie_meta` = 1) THEN 'movie'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `tv_meta` = 1) THEN 'tv'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `game_meta` = 1) THEN 'game'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `music_meta` = 1) THEN 'music'
|
||||
WHEN category_id IN (SELECT `id` from `categories` where `no_meta` = 1) THEN 'no'
|
||||
END as meta
|
||||
")
|
||||
->when($this->name !== '', fn ($query) => $query->ofName($this->name, $isRegex($this->name)))
|
||||
->when($this->description !== '', fn ($query) => $query->ofDescription($this->description, $isRegex($this->description)))
|
||||
->when($this->mediainfo !== '', fn ($query) => $query->ofMediainfo($this->mediainfo, $isRegex($this->mediainfo)))
|
||||
->when($this->uploader !== '', fn ($query) => $query->ofUploader($this->uploader))
|
||||
->when($this->keywords !== '', fn ($query) => $query->ofKeyword(array_map('trim', explode(',', $this->keywords))))
|
||||
->when($this->startYear !== '', fn ($query) => $query->releasedAfterOrIn((int) $this->startYear))
|
||||
->when($this->endYear !== '', fn ($query) => $query->releasedBeforeOrIn((int) $this->endYear))
|
||||
->when($this->categories !== [], fn ($query) => $query->ofCategory($this->categories))
|
||||
->when($this->types !== [], fn ($query) => $query->ofType($this->types))
|
||||
->when($this->resolutions !== [], fn ($query) => $query->ofResolution($this->resolutions))
|
||||
->when($this->genres !== [], fn ($query) => $query->ofGenre($this->genres))
|
||||
->when($this->regions !== [], fn ($query) => $query->ofRegion($this->regions))
|
||||
->when($this->distributors !== [], fn ($query) => $query->ofDistributor($this->distributors))
|
||||
->when($this->tmdbId !== '', fn ($query) => $query->ofTmdb((int) $this->tmdbId))
|
||||
->when($this->imdbId !== '', fn ($query) => $query->ofImdb((int) (preg_match('/tt0*(?=(\d{7,}))/', $this->imdbId, $matches) ? $matches[1] : $this->imdbId)))
|
||||
->when($this->tvdbId !== '', fn ($query) => $query->ofTvdb((int) $this->tvdbId))
|
||||
->when($this->malId !== '', fn ($query) => $query->ofMal((int) $this->malId))
|
||||
->when($this->playlistId !== '', fn ($query) => $query->ofPlaylist((int) $this->playlistId))
|
||||
->when($this->collectionId !== '', fn ($query) => $query->ofCollection((int) $this->collectionId))
|
||||
->when($this->free !== [], fn ($query) => $query->ofFreeleech($this->free))
|
||||
->when($this->doubleup !== false, fn ($query) => $query->doubleup())
|
||||
->when($this->featured !== false, fn ($query) => $query->featured())
|
||||
->when($this->stream !== false, fn ($query) => $query->streamOptimized())
|
||||
->when($this->sd !== false, fn ($query) => $query->sd())
|
||||
->when($this->highspeed !== false, fn ($query) => $query->highspeed())
|
||||
->when($this->bookmarked !== false, fn ($query) => $query->bookmarkedBy($user))
|
||||
->when($this->wished !== false, fn ($query) => $query->wishedBy($user))
|
||||
->when($this->internal !== false, fn ($query) => $query->internal())
|
||||
->when($this->personalRelease !== false, fn ($query) => $query->personalRelease())
|
||||
->when($this->alive !== false, fn ($query) => $query->alive())
|
||||
->when($this->dying !== false, fn ($query) => $query->dying())
|
||||
->when($this->dead !== false, fn ($query) => $query->dead())
|
||||
->when($this->notDownloaded !== false, fn ($query) => $query->notDownloadedBy($user))
|
||||
->when($this->downloaded !== false, fn ($query) => $query->downloadedBy($user))
|
||||
->when($this->seeding !== false, fn ($query) => $query->seededBy($user))
|
||||
->when($this->leeching !== false, fn ($query) => $query->leechedBy($user))
|
||||
->when($this->incomplete !== false, fn ($query) => $query->uncompletedBy($user))
|
||||
->latest('sticky')
|
||||
->orderBy($this->sortField, $this->sortDirection)
|
||||
->paginate($this->perPage);
|
||||
|
||||
$movieIds = $torrents->getCollection()->where('meta', '=', 'movie')->pluck('tmdb');
|
||||
$tvIds = $torrents->getCollection()->where('meta', '=', 'tv')->pluck('tmdb');
|
||||
$gameIds = $torrents->getCollection()->where('meta', '=', 'game')->pluck('igdb');
|
||||
|
||||
$movies = Movie::with('genres')->whereIntegerInRaw('id', $movieIds)->get()->keyBy('id');
|
||||
$tv = Tv::with('genres')->whereIntegerInRaw('id', $tvIds)->get()->keyBy('id');
|
||||
$games = [];
|
||||
|
||||
foreach ($gameIds as $gameId) {
|
||||
$games[] = \MarcReichel\IGDBLaravel\Models\Game::with(['cover' => ['url', 'image_id']])->find($gameId);
|
||||
}
|
||||
|
||||
$torrents = $torrents->through(function ($torrent) use ($movies, $tv) {
|
||||
$torrent->meta = match ($torrent->meta) {
|
||||
'movie' => $movies[$torrent->tmdb] ?? null,
|
||||
'tv' => $tv[$torrent->tmdb] ?? null,
|
||||
'game' => $games[$torrent->igdb] ?? null,
|
||||
default => null,
|
||||
};
|
||||
|
||||
return $torrent;
|
||||
});
|
||||
|
||||
return $torrents;
|
||||
}
|
||||
|
||||
final public function getGroupedTorrentsProperty()
|
||||
{
|
||||
$user = auth()->user();
|
||||
$isRegexAllowed = $user->group->is_modo;
|
||||
$isRegex = fn ($field) => $isRegexAllowed
|
||||
&& \strlen($field) > 2
|
||||
&& $field[0] === '/'
|
||||
&& $field[-1] === '/'
|
||||
&& @preg_match($field, 'Validate regex') !== false;
|
||||
|
||||
$groups = Torrent::query()
|
||||
->select('tmdb')
|
||||
->selectRaw('MAX(sticky) as sticky')
|
||||
->selectRaw('MAX(bumped_at) as bumped_at')
|
||||
->selectRaw("CASE WHEN category_id IN (SELECT `id` from `categories` where `movie_meta` = 1) THEN 'movie' WHEN category_id IN (SELECT `id` from `categories` where `tv_meta` = 1) THEN 'tv' END as meta")
|
||||
->havingNotNull('meta')
|
||||
->where('tmdb', '!=', 0)
|
||||
->when($this->name !== '', fn ($query) => $query->ofName($this->name, $isRegex($this->name)))
|
||||
->when($this->description !== '', fn ($query) => $query->ofDescription($this->description, $isRegex($this->description)))
|
||||
->when($this->mediainfo !== '', fn ($query) => $query->ofMediainfo($this->mediainfo, $isRegex($this->mediainfo)))
|
||||
->when($this->uploader !== '', fn ($query) => $query->ofUploader($this->uploader))
|
||||
->when($this->keywords !== '', fn ($query) => $query->ofKeyword(array_map('trim', explode(',', $this->keywords))))
|
||||
->when($this->startYear !== '', fn ($query) => $query->releasedAfterOrIn((int) $this->startYear))
|
||||
->when($this->endYear !== '', fn ($query) => $query->releasedBeforeOrIn((int) $this->endYear))
|
||||
->when($this->categories !== [], fn ($query) => $query->ofCategory($this->categories))
|
||||
->when($this->types !== [], fn ($query) => $query->ofType($this->types))
|
||||
->when($this->resolutions !== [], fn ($query) => $query->ofResolution($this->resolutions))
|
||||
->when($this->genres !== [], fn ($query) => $query->ofGenre($this->genres))
|
||||
->when($this->regions !== [], fn ($query) => $query->ofRegion($this->regions))
|
||||
->when($this->distributors !== [], fn ($query) => $query->ofDistributor($this->distributors))
|
||||
->when($this->tmdbId !== '', fn ($query) => $query->ofTmdb((int) $this->tmdbId))
|
||||
->when($this->imdbId !== '', fn ($query) => $query->ofImdb((int) (preg_match('/tt0*(?=(\d{7,}))/', $this->imdbId, $matches) ? $matches[1] : $this->imdbId)))
|
||||
->when($this->tvdbId !== '', fn ($query) => $query->ofTvdb((int) $this->tvdbId))
|
||||
->when($this->malId !== '', fn ($query) => $query->ofMal((int) $this->malId))
|
||||
->when($this->playlistId !== '', fn ($query) => $query->ofPlaylist((int) $this->playlistId))
|
||||
->when($this->collectionId !== '', fn ($query) => $query->ofCollection((int) $this->collectionId))
|
||||
->when($this->companyId !== '', fn ($query) => $query->ofCompany((int) $this->companyId))
|
||||
->when($this->networkId !== '', fn ($query) => $query->ofNetwork((int) $this->networkId))
|
||||
->when($this->free !== [], fn ($query) => $query->ofFreeleech($this->free))
|
||||
->when($this->doubleup !== false, fn ($query) => $query->doubleup())
|
||||
->when($this->featured !== false, fn ($query) => $query->featured())
|
||||
->when($this->stream !== false, fn ($query) => $query->streamOptimized())
|
||||
->when($this->sd !== false, fn ($query) => $query->sd())
|
||||
->when($this->highspeed !== false, fn ($query) => $query->highspeed())
|
||||
->when($this->bookmarked !== false, fn ($query) => $query->bookmarkedBy($user))
|
||||
->when($this->wished !== false, fn ($query) => $query->wishedBy($user))
|
||||
->when($this->internal !== false, fn ($query) => $query->internal())
|
||||
->when($this->personalRelease !== false, fn ($query) => $query->personalRelease())
|
||||
->when($this->alive !== false, fn ($query) => $query->alive())
|
||||
->when($this->dying !== false, fn ($query) => $query->dying())
|
||||
->when($this->dead !== false, fn ($query) => $query->dead())
|
||||
->when($this->notDownloaded !== false, fn ($query) => $query->notDownloadedBy($user))
|
||||
->when($this->downloaded !== false, fn ($query) => $query->downloadedBy($user))
|
||||
->when($this->seeding !== false, fn ($query) => $query->seededBy($user))
|
||||
->when($this->leeching !== false, fn ($query) => $query->leechedBy($user))
|
||||
->when($this->incomplete !== false, fn ($query) => $query->uncompletedBy($user))
|
||||
->groupBy('tmdb', 'meta')
|
||||
->latest('sticky')
|
||||
->orderByDesc('bumped_at')
|
||||
->paginate($this->perPage);
|
||||
|
||||
$movieIds = $groups->getCollection()->where('meta', '=', 'movie')->pluck('tmdb');
|
||||
$tvIds = $groups->getCollection()->where('meta', '=', 'tv')->pluck('tmdb');
|
||||
|
||||
$movies = Movie::with('genres', 'directors')->whereIntegerInRaw('id', $movieIds)->get()->keyBy('id');
|
||||
$tv = Tv::with('genres', 'creators')->whereIntegerInRaw('id', $tvIds)->get()->keyBy('id');
|
||||
|
||||
$torrents = Torrent::query()
|
||||
->with('type:id,name,position', 'resolution:id,name,position')
|
||||
->withExists([
|
||||
'freeleechTokens' => fn ($query) => $query->where('user_id', '=', auth()->id()),
|
||||
])
|
||||
->select([
|
||||
'id',
|
||||
'name',
|
||||
'info_hash',
|
||||
'size',
|
||||
'leechers',
|
||||
'seeders',
|
||||
'times_completed',
|
||||
'category_id',
|
||||
'user_id',
|
||||
'season_number',
|
||||
'episode_number',
|
||||
'tmdb',
|
||||
'stream',
|
||||
'free',
|
||||
'doubleup',
|
||||
'highspeed',
|
||||
'featured',
|
||||
'sticky',
|
||||
'sd',
|
||||
'internal',
|
||||
'created_at',
|
||||
'bumped_at',
|
||||
'type_id',
|
||||
'resolution_id',
|
||||
'personal_release',
|
||||
])
|
||||
->selectRaw("CASE WHEN category_id IN (SELECT `id` from `categories` where `movie_meta` = 1) THEN 'movie' WHEN category_id IN (SELECT `id` from `categories` where `tv_meta` = 1) THEN 'tv' END as meta")
|
||||
->where(
|
||||
fn ($query) => $query
|
||||
->where(
|
||||
fn ($query) => $query
|
||||
->whereIn('category_id', Category::select('id')->where('movie_meta', '=', 1))
|
||||
->whereIntegerInRaw('tmdb', $movieIds)
|
||||
)
|
||||
->orWhere(
|
||||
fn ($query) => $query
|
||||
->whereIn('category_id', Category::select('id')->where('tv_meta', '=', 1))
|
||||
->whereIntegerInRaw('tmdb', $tvIds)
|
||||
)
|
||||
)
|
||||
->when($this->name !== '', fn ($query) => $query->ofName($this->name, $isRegex($this->name)))
|
||||
->when($this->description !== '', fn ($query) => $query->ofDescription($this->description, $isRegex($this->description)))
|
||||
->when($this->mediainfo !== '', fn ($query) => $query->ofMediainfo($this->mediainfo, $isRegex($this->mediainfo)))
|
||||
->when($this->uploader !== '', fn ($query) => $query->ofUploader($this->uploader))
|
||||
->when($this->keywords !== '', fn ($query) => $query->ofKeyword(array_map('trim', explode(',', $this->keywords))))
|
||||
->when($this->startYear !== '', fn ($query) => $query->releasedAfterOrIn((int) $this->startYear))
|
||||
->when($this->endYear !== '', fn ($query) => $query->releasedBeforeOrIn((int) $this->endYear))
|
||||
->when($this->categories !== [], fn ($query) => $query->ofCategory($this->categories))
|
||||
->when($this->types !== [], fn ($query) => $query->ofType($this->types))
|
||||
->when($this->resolutions !== [], fn ($query) => $query->ofResolution($this->resolutions))
|
||||
->when($this->genres !== [], fn ($query) => $query->ofGenre($this->genres))
|
||||
->when($this->regions !== [], fn ($query) => $query->ofRegion($this->regions))
|
||||
->when($this->distributors !== [], fn ($query) => $query->ofDistributor($this->distributors))
|
||||
->when($this->tmdbId !== '', fn ($query) => $query->ofTmdb((int) $this->tmdbId))
|
||||
->when($this->imdbId !== '', fn ($query) => $query->ofImdb((int) (preg_match('/tt0*(?=(\d{7,}))/', $this->imdbId, $matches) ? $matches[1] : $this->imdbId)))
|
||||
->when($this->tvdbId !== '', fn ($query) => $query->ofTvdb((int) $this->tvdbId))
|
||||
->when($this->malId !== '', fn ($query) => $query->ofMal((int) $this->malId))
|
||||
->when($this->playlistId !== '', fn ($query) => $query->ofPlaylist((int) $this->playlistId))
|
||||
->when($this->collectionId !== '', fn ($query) => $query->ofCollection((int) $this->collectionId))
|
||||
->when($this->companyId !== '', fn ($query) => $query->ofCompany((int) $this->companyId))
|
||||
->when($this->networkId !== '', fn ($query) => $query->ofNetwork((int) $this->networkId))
|
||||
->when($this->free !== [], fn ($query) => $query->ofFreeleech($this->free))
|
||||
->when($this->doubleup !== false, fn ($query) => $query->doubleup())
|
||||
->when($this->featured !== false, fn ($query) => $query->featured())
|
||||
->when($this->stream !== false, fn ($query) => $query->streamOptimized())
|
||||
->when($this->sd !== false, fn ($query) => $query->sd())
|
||||
->when($this->highspeed !== false, fn ($query) => $query->highspeed())
|
||||
->when($this->bookmarked !== false, fn ($query) => $query->bookmarkedBy($user))
|
||||
->when($this->wished !== false, fn ($query) => $query->wishedBy($user))
|
||||
->when($this->internal !== false, fn ($query) => $query->internal())
|
||||
->when($this->personalRelease !== false, fn ($query) => $query->personalRelease())
|
||||
->when($this->alive !== false, fn ($query) => $query->alive())
|
||||
->when($this->dying !== false, fn ($query) => $query->dying())
|
||||
->when($this->dead !== false, fn ($query) => $query->dead())
|
||||
->when($this->notDownloaded !== false, fn ($query) => $query->notDownloadedBy($user))
|
||||
->when($this->downloaded !== false, fn ($query) => $query->downloadedBy($user))
|
||||
->when($this->seeding !== false, fn ($query) => $query->seededBy($user))
|
||||
->when($this->leeching !== false, fn ($query) => $query->leechedBy($user))
|
||||
->when($this->incomplete !== false, fn ($query) => $query->uncompletedBy($user))
|
||||
->get()
|
||||
->groupBy('meta')
|
||||
->map(fn ($movieOrTv, $key) => match ($key) {
|
||||
'movie' => $movieOrTv
|
||||
->groupBy('tmdb')
|
||||
->map(
|
||||
function ($movie) {
|
||||
$category_id = $movie->first()->category_id;
|
||||
$movie = $movie
|
||||
->sortBy('type.position')
|
||||
->values()
|
||||
->groupBy(fn ($torrent) => $torrent->type->name)
|
||||
->map(
|
||||
fn ($torrentsByType) => $torrentsByType
|
||||
->sortBy([
|
||||
['resolution.position', 'asc'],
|
||||
['internal', 'desc'],
|
||||
['size', 'desc']
|
||||
])
|
||||
->values()
|
||||
);
|
||||
$movie->put('category_id', $category_id);
|
||||
|
||||
return $movie;
|
||||
}
|
||||
),
|
||||
'tv' => $movieOrTv
|
||||
->groupBy([
|
||||
fn ($torrent) => $torrent->tmdb,
|
||||
])
|
||||
->map(
|
||||
function ($tv) {
|
||||
$category_id = $tv->first()->category_id;
|
||||
$tv = $tv
|
||||
->groupBy(fn ($torrent) => $torrent->season_number === 0 ? ($torrent->episode_number === 0 ? 'Complete Pack' : 'Specials') : 'Seasons')
|
||||
->map(fn ($packOrSpecialOrSeasons, $key) => match ($key) {
|
||||
'Complete Pack' => $packOrSpecialOrSeasons
|
||||
->sortBy('type.position')
|
||||
->values()
|
||||
->groupBy(fn ($torrent) => $torrent->type->name)
|
||||
->map(
|
||||
fn ($torrentsByType) => $torrentsByType
|
||||
->sortBy([
|
||||
['resolution.position', 'asc'],
|
||||
['internal', 'desc'],
|
||||
['size', 'desc']
|
||||
])
|
||||
->values()
|
||||
),
|
||||
'Specials' => $packOrSpecialOrSeasons
|
||||
->groupBy(fn ($torrent) => 'Special '.$torrent->episode_number)
|
||||
->map(
|
||||
fn ($episode) => $episode
|
||||
->sortBy('type.position')
|
||||
->values()
|
||||
->groupBy(fn ($torrent) => $torrent->type->name)
|
||||
->map(
|
||||
fn ($torrentsByType) => $torrentsByType
|
||||
->sortBy([
|
||||
['resolution.position', 'asc'],
|
||||
['internal', 'desc'],
|
||||
['size', 'desc']
|
||||
])
|
||||
->values()
|
||||
)
|
||||
),
|
||||
'Seasons' => $packOrSpecialOrSeasons
|
||||
->groupBy(fn ($torrent) => 'Season '.$torrent->season_number)
|
||||
->map(
|
||||
fn ($season) => $season
|
||||
->sortKeys(SORT_NATURAL)
|
||||
->groupBy(fn ($torrent) => $torrent->episode_number === 0 ? 'Season Pack' : 'Episodes')
|
||||
->map(fn ($packOrEpisodes, $key) => match ($key) {
|
||||
'Season Pack' => $packOrEpisodes
|
||||
->sortBy('type.position')
|
||||
->values()
|
||||
->groupBy(fn ($torrent) => $torrent->type->name)
|
||||
->map(
|
||||
fn ($torrentsByType) => $torrentsByType
|
||||
->sortBy([
|
||||
['resolution.position', 'asc'],
|
||||
['internal', 'desc'],
|
||||
['size', 'desc']
|
||||
])
|
||||
->values()
|
||||
),
|
||||
'Episodes' => $packOrEpisodes
|
||||
->groupBy(fn ($torrent) => 'Episode '.$torrent->episode_number)
|
||||
->sortKeys(SORT_NATURAL)
|
||||
->map(
|
||||
fn ($episode) => $episode
|
||||
->sortBy('type.position')
|
||||
->values()
|
||||
->groupBy(fn ($torrent) => $torrent->type->name)
|
||||
->map(
|
||||
fn ($torrentsBytype) => $torrentsBytype
|
||||
->sortBy([
|
||||
['resolution.position', 'asc'],
|
||||
['internal', 'desc'],
|
||||
['size', 'desc']
|
||||
])
|
||||
->values()
|
||||
)
|
||||
),
|
||||
})
|
||||
),
|
||||
});
|
||||
$tv->put('category_id', $category_id);
|
||||
|
||||
return $tv;
|
||||
}
|
||||
),
|
||||
});
|
||||
|
||||
$medias = $groups->through(function ($group) use ($torrents, $movies, $tv) {
|
||||
$media = collect(['meta' => 'no']);
|
||||
|
||||
switch ($group->meta) {
|
||||
case 'movie':
|
||||
$media = $movies[$group->tmdb] ?? collect();
|
||||
$media->meta = 'movie';
|
||||
$media->torrents = $torrents['movie'][$group->tmdb] ?? collect();
|
||||
$media->category_id = $media->torrents->pop();
|
||||
break;
|
||||
|
||||
case 'tv':
|
||||
$media = $tv[$group->tmdb] ?? collect();
|
||||
$media->meta = 'tv';
|
||||
$media->torrents = $torrents['tv'][$group->tmdb] ?? collect();
|
||||
$media->category_id = $media->torrents->pop();
|
||||
break;
|
||||
}
|
||||
|
||||
return $media;
|
||||
});
|
||||
|
||||
return $medias;
|
||||
}
|
||||
|
||||
final public function sortBy($field): void
|
||||
{
|
||||
if ($this->sortField === $field) {
|
||||
$this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc';
|
||||
} else {
|
||||
$this->sortDirection = 'asc';
|
||||
}
|
||||
|
||||
$this->sortField = $field;
|
||||
}
|
||||
|
||||
final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application
|
||||
{
|
||||
return view('livewire.torrent-search', [
|
||||
'user' => User::with(['group'])->findOrFail(auth()->user()->id),
|
||||
'personalFreeleech' => $this->personalFreeleech,
|
||||
'torrents' => $this->view === 'group' ? $this->groupedTorrents : $this->torrents,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -14,16 +14,15 @@
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*/
|
||||
protected function redirectTo($request)
|
||||
protected function redirectTo(Request $request): ?string
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
return route('login');
|
||||
}
|
||||
return $request->expectsJson() ? null : route('login');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class RedirectIfAuthenticated
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, ...$guards): mixed
|
||||
public function handle(Request $request, Closure $next, string ...$guards): mixed
|
||||
{
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
|
||||
|
||||
class ValidateSignature extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the query string parameters that should be ignored.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
// 'fbclid',
|
||||
// 'utm_campaign',
|
||||
// 'utm_content',
|
||||
// 'utm_medium',
|
||||
// 'utm_source',
|
||||
// 'utm_term',
|
||||
];
|
||||
}
|
||||
@@ -32,13 +32,13 @@ class StoreGroupRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|unique:groups',
|
||||
'position' => 'required|integer',
|
||||
'level' => 'required|integer',
|
||||
'download_slots' => 'integer',
|
||||
'color' => 'required',
|
||||
'icon' => 'required',
|
||||
'effect',
|
||||
'name' => 'required|string|unique:groups',
|
||||
'position' => 'required|integer',
|
||||
'level' => 'required|integer',
|
||||
'download_slots' => 'integer',
|
||||
'color' => 'required',
|
||||
'icon' => 'required',
|
||||
'effect' => 'sometimes',
|
||||
'is_internal' => 'required|boolean',
|
||||
'is_modo' => 'required|boolean',
|
||||
'is_admin' => 'required|boolean',
|
||||
|
||||
@@ -32,13 +32,13 @@ class UpdateGroupRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string',
|
||||
'position' => 'required|integer',
|
||||
'level' => 'required|integer',
|
||||
'download_slots' => 'integer',
|
||||
'color' => 'required',
|
||||
'icon' => 'required',
|
||||
'effect',
|
||||
'name' => 'required|string',
|
||||
'position' => 'required|integer',
|
||||
'level' => 'required|integer',
|
||||
'download_slots' => 'integer',
|
||||
'color' => 'required',
|
||||
'icon' => 'required',
|
||||
'effect' => 'sometimes',
|
||||
'is_internal' => 'required|boolean',
|
||||
'is_modo' => 'required|boolean',
|
||||
'is_admin' => 'required|boolean',
|
||||
|
||||
@@ -13,10 +13,9 @@
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Cast;
|
||||
use App\Enums\Occupations;
|
||||
use App\Models\Collection;
|
||||
use App\Models\Company;
|
||||
use App\Models\Crew;
|
||||
use App\Models\Genre;
|
||||
use App\Models\Movie;
|
||||
use App\Models\Person;
|
||||
@@ -88,24 +87,45 @@ class ProcessMovieJob implements ShouldQueue
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->movie['credits']['cast'])) {
|
||||
foreach ($this->movie['credits']['cast'] as $cast) {
|
||||
Cast::updateOrCreate(['id' => $cast['id']], $tmdb->cast_array($cast))->movie()->syncWithoutDetaching([$this->movie['id']]);
|
||||
Person::updateOrCreate(['id' => $cast['id']], $tmdb->person_array($cast))->movie()->syncWithoutDetaching([$this->movie['id']]);
|
||||
$people_ids = [];
|
||||
$credits = [];
|
||||
|
||||
foreach ($this->movie['credits']['cast'] ?? [] as $person) {
|
||||
$credits[] = [
|
||||
'movie_id' => $this->movie['id'],
|
||||
'person_id' => $person['id'],
|
||||
'occupation_id' => Occupations::ACTOR->value,
|
||||
'character' => $person['character'] ?? '',
|
||||
'order' => $person['order'] ?? null
|
||||
];
|
||||
$people_ids[] = $person['id'];
|
||||
}
|
||||
|
||||
foreach ($this->movie['credits']['crew'] ?? [] as $person) {
|
||||
$job = Occupations::from_tmdb_job($person['job']);
|
||||
|
||||
if ($job !== null) {
|
||||
$credits[] = [
|
||||
'movie_id' => $this->movie['id'],
|
||||
'person_id' => $person['id'],
|
||||
'occupation_id' => $job->value,
|
||||
'order' => null
|
||||
];
|
||||
$people_ids[] = $person['id'];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->movie['credits']['crew'])) {
|
||||
foreach ($this->movie['credits']['crew'] as $crew) {
|
||||
Crew::updateOrCreate(['id' => $crew['id']], $tmdb->person_array($crew))
|
||||
->movie()
|
||||
->syncWithoutDetaching([$this->movie['id'] => [
|
||||
'department' => $crew['department'] ?? null,
|
||||
'job' => $crew['job'] ?? null,
|
||||
]]);
|
||||
}
|
||||
$people = [];
|
||||
|
||||
foreach (array_unique($people_ids) as $person_id) {
|
||||
$client = new Client\Person($person_id);
|
||||
$person = $client->getData();
|
||||
$people[] = $tmdb->person_array($person);
|
||||
}
|
||||
|
||||
Person::upsert($people, 'id');
|
||||
Movie::find($this->movie['id'])->people()->sync($credits);
|
||||
|
||||
if (isset($this->movie['recommendations'])) {
|
||||
foreach ($this->movie['recommendations']['results'] as $recommendation) {
|
||||
if (Movie::where('id', '=', $recommendation['id'])->count() !== 0) {
|
||||
|
||||
+49
-51
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
@@ -13,12 +14,10 @@
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Cast;
|
||||
use App\Enums\Occupations;
|
||||
use App\Models\Company;
|
||||
use App\Models\Crew;
|
||||
use App\Models\Episode;
|
||||
use App\Models\Genre;
|
||||
use App\Models\GuestStar;
|
||||
use App\Models\Network;
|
||||
use App\Models\Person;
|
||||
use App\Models\Recommendation;
|
||||
@@ -65,12 +64,6 @@ class ProcessTvJob implements ShouldQueue
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->tv['created_by'] as $person) {
|
||||
if (isset($person['id'])) {
|
||||
Person::updateOrCreate(['id' => $person['id']], $tmdb->person_array($person))->tv()->syncWithoutDetaching([$this->id]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->tv['networks'] as $network) {
|
||||
$client = new Client\Network($network['id']);
|
||||
$network = $client->getData();
|
||||
@@ -98,24 +91,59 @@ class ProcessTvJob implements ShouldQueue
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->tv['credits']['cast'])) {
|
||||
foreach ($this->tv['credits']['cast'] as $cast) {
|
||||
Cast::updateOrCreate(['id' => $cast['id']], $tmdb->cast_array($cast))->tv()->syncWithoutDetaching([$this->tv['id']]);
|
||||
Person::updateOrCreate(['id' => $cast['id']], $tmdb->person_array($cast))->tv()->syncWithoutDetaching([$this->tv['id']]);
|
||||
$people_ids = [];
|
||||
$credits = [];
|
||||
|
||||
foreach ($this->tv['aggregate_credits']['cast'] ?? [] as $person) {
|
||||
foreach ($person['roles'] as $role) {
|
||||
$credits[] = [
|
||||
'tv_id' => $this->tv['id'],
|
||||
'person_id' => $person['id'],
|
||||
'occupation_id' => Occupations::ACTOR->value,
|
||||
'character' => $role['character'] ?? '',
|
||||
'order' => $person['order'] ?? null
|
||||
];
|
||||
$people_ids[] = $person['id'];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->tv['credits']['crew'])) {
|
||||
foreach ($this->tv['credits']['crew'] as $crew) {
|
||||
Crew::updateOrCreate(['id' => $crew['id']], $tmdb->person_array($crew))
|
||||
->tv()
|
||||
->syncWithoutDetaching([$this->tv['id'] => [
|
||||
'department' => $crew['department'] ?? null,
|
||||
'job' => $crew['job'] ?? null,
|
||||
]]);
|
||||
foreach ($this->tv['aggregate_credits']['crew'] ?? [] as $person) {
|
||||
foreach ($person['jobs'] as $job) {
|
||||
$occupation = Occupations::from_tmdb_job($job['job']);
|
||||
|
||||
if ($occupation !== null) {
|
||||
$credits[] = [
|
||||
'tv_id' => $this->tv['id'],
|
||||
'person_id' => $person['id'],
|
||||
'occupation_id' => $occupation->value,
|
||||
'order' => null,
|
||||
];
|
||||
$people_ids[] = $person['id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->tv['created_by'] ?? [] as $person) {
|
||||
$credits[] = [
|
||||
'tv_id' => $this->tv['id'],
|
||||
'person_id' => $person['id'],
|
||||
'occupation_id' => Occupations::CREATOR->value,
|
||||
'order' => null,
|
||||
];
|
||||
$people_ids[] = $person['id'];
|
||||
}
|
||||
|
||||
$people = [];
|
||||
|
||||
foreach (array_unique($people_ids) as $person_id) {
|
||||
$client = new Client\Person($person_id);
|
||||
$person = $client->getData();
|
||||
$people[] = $tmdb->person_array($person);
|
||||
}
|
||||
|
||||
Person::upsert($people, 'id');
|
||||
Tv::find($this->tv['id'])->people()->sync($credits);
|
||||
|
||||
foreach ($this->tv['seasons'] as $season) {
|
||||
$client = new Client\Season($this->id, sprintf('%02d', $season['season_number']));
|
||||
$season = $client->getData();
|
||||
@@ -150,36 +178,6 @@ class ProcessTvJob implements ShouldQueue
|
||||
];
|
||||
|
||||
Episode::updateOrCreate(['id' => $episode['id']], $episodeArray)->season();
|
||||
|
||||
foreach ($episode['credits']['guest_stars'] as $person) {
|
||||
if (isset($person['id'])) {
|
||||
GuestStar::updateOrCreate(['id' => $person['id']], $tmdb->person_array($person))->episode()->syncWithoutDetaching([$episode['id']]);
|
||||
Person::updateOrCreate(['id' => $person['id']], $tmdb->person_array($person))->tv()->syncWithoutDetaching([$this->id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($season['credits']['cast'] as $person) {
|
||||
if (isset($person['id'])) {
|
||||
Cast::updateOrCreate(['id' => $person['id']], $tmdb->cast_array($person))->season()->syncWithoutDetaching([$season['id']]);
|
||||
Cast::updateOrCreate(['id' => $person['id']], $tmdb->cast_array($person))->tv()->syncWithoutDetaching([$this->id]);
|
||||
Person::updateOrCreate(['id' => $person['id']], $tmdb->person_array($person))->tv()->syncWithoutDetaching([$this->id]);
|
||||
$client = new Client\Person($person['id']);
|
||||
$people = $client->getData();
|
||||
Crew::updateOrCreate(['id' => $people['id']], $tmdb->person_array($people))->season()->syncWithoutDetaching([$season['id']]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($season['credits']['crew'] as $crew) {
|
||||
if (isset($crew['id'])) {
|
||||
Crew::updateOrCreate(['id' => $crew['id']], $tmdb->person_array($crew))
|
||||
->season()
|
||||
->syncWithoutDetaching([$season['id'] => [
|
||||
'department' => $season['department'] ?? null,
|
||||
'job' => $season['job'] ?? null,
|
||||
]]);
|
||||
Person::updateOrCreate(['id' => $crew['id']], $tmdb->person_array($crew))->tv()->syncWithoutDetaching([$this->id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author HDVinnie <hdinnovations@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Cast extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public $table = 'cast';
|
||||
|
||||
public function tv(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Tv::class, 'cast_tv', 'tv_id', 'cast_id');
|
||||
}
|
||||
|
||||
public function season(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Season::class, 'cast_season', 'season_id', 'cast_id');
|
||||
}
|
||||
|
||||
public function episode(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Episode::class, 'cast_episode', 'episode_id', 'cast_id');
|
||||
}
|
||||
|
||||
public function movie(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Movie::class, 'cast_movie', 'movie_id', 'cast_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author Roardom <roardom@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Credit extends Model
|
||||
{
|
||||
/**
|
||||
* Indicates if the IDs are auto-incrementing.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $incrementing = true;
|
||||
|
||||
/**
|
||||
* Indicates If The Model Should Be Timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
public function occupation(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Occupation::class, 'occupation_id');
|
||||
}
|
||||
|
||||
public function person(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Person::class);
|
||||
}
|
||||
|
||||
public function tv(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Tv::class);
|
||||
}
|
||||
|
||||
public function movie(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Movie::class);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author HDVinnie <hdinnovations@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Crew extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public $table = 'person';
|
||||
|
||||
public function tv(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Tv::class, 'crew_tv', 'tv_id', 'person_id');
|
||||
}
|
||||
|
||||
public function season(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Season::class, 'crew_season', 'season_id', 'person_id');
|
||||
}
|
||||
|
||||
public function episode(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Episode::class, 'crew_episode', 'episode_id', 'person_id');
|
||||
}
|
||||
|
||||
public function movie(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Movie::class, 'crew_movie', 'movie_id', 'person_id');
|
||||
}
|
||||
}
|
||||
@@ -31,25 +31,4 @@ class Episode extends Model
|
||||
->oldest('season_id')
|
||||
->oldest('episode_id');
|
||||
}
|
||||
|
||||
public function person(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Person::class);
|
||||
}
|
||||
|
||||
public function cast(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Cast::class)
|
||||
->oldest('order');
|
||||
}
|
||||
|
||||
public function crew(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Crew::class, 'crew_episode', 'person_id', 'episode_id');
|
||||
}
|
||||
|
||||
public function guest_star(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(GuestStar::class, 'episode_guest_star', 'person_id', 'episode_id');
|
||||
}
|
||||
}
|
||||
|
||||
+11
-4
@@ -13,6 +13,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\Occupations;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Movie extends Model
|
||||
@@ -26,14 +27,20 @@ class Movie extends Model
|
||||
return $this->belongsToMany(Genre::class);
|
||||
}
|
||||
|
||||
public function cast(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
public function people(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Cast::class, 'cast_movie', 'cast_id', 'movie_id');
|
||||
return $this->belongsToMany(Person::class, 'credits');
|
||||
}
|
||||
|
||||
public function crew(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
public function credits(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->belongsToMany(Crew::class, 'crew_movie', 'person_id', 'movie_id');
|
||||
return $this->hasMany(Credit::class);
|
||||
}
|
||||
|
||||
public function directors(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Person::class, 'credits')
|
||||
->wherePivot('occupation_id', '=', Occupations::DIRECTOR->value);
|
||||
}
|
||||
|
||||
public function companies(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author Roardom <roardom@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Auditable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Occupation extends Model
|
||||
{
|
||||
use Auditable;
|
||||
|
||||
/**
|
||||
* Indicates If The Model Should Be Timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
public function people(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Person::class, 'credits');
|
||||
}
|
||||
|
||||
public function credits(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(Credit::class);
|
||||
}
|
||||
}
|
||||
+6
-12
@@ -25,21 +25,15 @@ class Person extends Model
|
||||
|
||||
public function tv(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Tv::class, 'person_tv', 'tv_id', 'person_id');
|
||||
}
|
||||
|
||||
public function season(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Season::class, 'person_season', 'season_id', 'person_id');
|
||||
}
|
||||
|
||||
public function episode(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Episode::class, 'episode_person', 'episode_id', 'person_id');
|
||||
return $this->belongsToMany(Tv::class, 'credits')
|
||||
->withPivot('character', 'occupation_id')
|
||||
->as('credit');
|
||||
}
|
||||
|
||||
public function movie(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Movie::class, 'person_movie', 'movie_id', 'person_id');
|
||||
return $this->belongsToMany(Movie::class, 'credits')
|
||||
->withPivot('character', 'occupation_id')
|
||||
->as('credit');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,12 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Helpers\Bbcode;
|
||||
use App\Helpers\Linkify;
|
||||
use App\Traits\Auditable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use voku\helper\AntiXSS;
|
||||
|
||||
class Playlist extends Model
|
||||
{
|
||||
@@ -45,4 +48,22 @@ class Playlist extends Model
|
||||
{
|
||||
return $this->morphMany(Comment::class, 'commentable');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set The Playlists Description After It's Been Purified.
|
||||
*/
|
||||
public function setDescriptionAttribute(?string $value): void
|
||||
{
|
||||
$this->attributes['description'] = htmlspecialchars((new AntiXSS())->xss_clean($value), ENT_NOQUOTES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse Description And Return Valid HTML.
|
||||
*/
|
||||
public function getDescriptionHtml(): string
|
||||
{
|
||||
$bbcode = new Bbcode();
|
||||
|
||||
return (new Linkify())->linky($bbcode->parse(htmlspecialchars_decode($this->description)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,19 +43,4 @@ class Season extends Model
|
||||
return $this->hasMany(Episode::class)
|
||||
->oldest('episode_number');
|
||||
}
|
||||
|
||||
public function person(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Person::class);
|
||||
}
|
||||
|
||||
public function cast(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Cast::class);
|
||||
}
|
||||
|
||||
public function crew(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Crew::class, 'crew_season', 'person_id', 'season_id');
|
||||
}
|
||||
}
|
||||
|
||||
+18
-10
@@ -35,6 +35,16 @@ class Torrent extends Model
|
||||
use Moderatable;
|
||||
use TorrentFilter;
|
||||
|
||||
/**
|
||||
* The Attributes That Should Be Mutated To Dates.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'fl_until' => 'datetime',
|
||||
'du_until' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* Belongs To A User.
|
||||
*/
|
||||
@@ -206,6 +216,14 @@ class Torrent extends Model
|
||||
return $this->hasMany(FreeleechToken::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bookmarks.
|
||||
*/
|
||||
public function bookmarks(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(Bookmark::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set The Torrents Description After Its Been Purified.
|
||||
*/
|
||||
@@ -250,16 +268,6 @@ class Torrent extends Model
|
||||
return StringHelper::formatBytes($bytes, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bookmarks.
|
||||
*/
|
||||
public function bookmarked(): bool
|
||||
{
|
||||
return (bool) Bookmark::where('user_id', '=', auth()->user()->id)
|
||||
->where('torrent_id', '=', $this->id)
|
||||
->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify Uploader When An Action Is Taken.
|
||||
*/
|
||||
|
||||
@@ -17,6 +17,7 @@ use App\Helpers\Bbcode;
|
||||
use App\Helpers\Linkify;
|
||||
use App\Notifications\NewComment;
|
||||
use App\Traits\Auditable;
|
||||
use App\Traits\TorrentFilter;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use voku\helper\AntiXSS;
|
||||
@@ -25,6 +26,7 @@ class TorrentRequest extends Model
|
||||
{
|
||||
use Auditable;
|
||||
use HasFactory;
|
||||
use TorrentFilter;
|
||||
|
||||
/**
|
||||
* The Attributes That Should Be Mutated To Dates.
|
||||
|
||||
+8
-11
@@ -13,6 +13,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\Occupations;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Tv extends Model
|
||||
@@ -39,19 +40,20 @@ class Tv extends Model
|
||||
->oldest('season_number');
|
||||
}
|
||||
|
||||
public function persons(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
public function people(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Person::class);
|
||||
return $this->belongsToMany(Person::class, 'credits');
|
||||
}
|
||||
|
||||
public function cast(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
public function credits(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->belongsToMany(Cast::class, 'cast_tv', 'cast_id', 'tv_id');
|
||||
return $this->hasMany(Credit::class);
|
||||
}
|
||||
|
||||
public function crew(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
public function creators(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Crew::class, 'crew_tv', 'person_id', 'tv_id');
|
||||
return $this->belongsToMany(Person::class, 'credits')
|
||||
->wherePivot('occupation_id', '=', Occupations::CREATOR->value);
|
||||
}
|
||||
|
||||
public function genres(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
@@ -59,11 +61,6 @@ class Tv extends Model
|
||||
return $this->belongsToMany(Genre::class);
|
||||
}
|
||||
|
||||
public function creators(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Person::class);
|
||||
}
|
||||
|
||||
public function networks(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Network::class);
|
||||
|
||||
+10
-5
@@ -119,11 +119,6 @@ class User extends Authenticatable
|
||||
return $this->belongsToMany(Torrent::class, 'bookmarks', 'user_id', 'torrent_id')->withTimestamps();
|
||||
}
|
||||
|
||||
public function isBookmarked(int $torrentId): bool
|
||||
{
|
||||
return $this->bookmarks()->where('torrent_id', '=', $torrentId)->first() !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Belongs To Many Seeding Torrents.
|
||||
*/
|
||||
@@ -154,6 +149,16 @@ class User extends Authenticatable
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* Belongs to many connectable seeding torrents.
|
||||
*/
|
||||
public function connectableSeedingTorrents(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Torrent::class, 'peers')
|
||||
->wherePivot('seeder', '=', 1)
|
||||
->wherePivot('connectable', '=', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Belongs to many followees.
|
||||
*/
|
||||
|
||||
@@ -91,4 +91,12 @@ class EventServiceProvider extends ServiceProvider
|
||||
public function boot(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if events and listeners should be automatically discovered.
|
||||
*/
|
||||
public function shouldDiscoverEvents(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class TV
|
||||
'query' => [
|
||||
'api_key' => config('api-keys.tmdb'),
|
||||
'language' => config('app.meta_locale'),
|
||||
'append_to_response' => 'videos,images,credits,external_ids,keywords,recommendations,alternative_titles',
|
||||
'append_to_response' => 'videos,images,aggregate_credits,external_ids,keywords,recommendations,alternative_titles',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
@@ -62,6 +62,7 @@ class TMDB
|
||||
public function person_array($person): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->ifExists('id', $person),
|
||||
'birthday' => $this->ifExists('birthday', $person),
|
||||
'known_for_department' => $this->ifExists('known_for_department', $person),
|
||||
'deathday' => $this->ifExists('deathday', $person),
|
||||
|
||||
@@ -24,8 +24,7 @@ trait GroupedLastScope
|
||||
* Each group is composed of one or more columns that make a unique combination to return the
|
||||
* last entry for.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param array|null $fields A list of fields that's considered as a unique entry by the query.
|
||||
* @param array|null $fields A list of fields that's considered as a unique entry by the query.
|
||||
*/
|
||||
public function scopeLastPerGroup(Builder $query, ?array $fields = null): Builder
|
||||
{
|
||||
|
||||
@@ -148,6 +148,31 @@ trait TorrentFilter
|
||||
->whereIn('tmdb', DB::table('collection_movie')->select('movie_id')->where('collection_id', '=', $collectionId));
|
||||
}
|
||||
|
||||
public function scopeOfCompany(Builder $query, int $companyId): Builder
|
||||
{
|
||||
return $query
|
||||
->where(
|
||||
fn ($query) => $query
|
||||
->where(
|
||||
fn ($query) => $query
|
||||
->whereIn('category_id', Category::select('id')->where('movie_meta', '=', 1))
|
||||
->whereIn('tmdb', DB::table('company_movie')->select('movie_id')->where('company_id', '=', $companyId))
|
||||
)
|
||||
->orWhere(
|
||||
fn ($query) => $query
|
||||
->whereIn('category_id', Category::select('id')->where('tv_meta', '=', 1))
|
||||
->whereIn('tmdb', DB::table('company_tv')->select('tv_id')->where('company_id', '=', $companyId))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function scopeOfNetwork(Builder $query, int $networkId): Builder
|
||||
{
|
||||
return $query
|
||||
->whereIn('category_id', Category::select('id')->where('tv_meta', '=', 1))
|
||||
->whereIn('tmdb', DB::table('network_tv')->select('tv_id')->where('network_id', '=', $networkId));
|
||||
}
|
||||
|
||||
public function scopeOfFreeleech(Builder $query, string|array $free): Builder
|
||||
{
|
||||
return $query->whereIntegerInRaw('free', (array) $free);
|
||||
|
||||
+22
-20
@@ -16,42 +16,41 @@
|
||||
"ext-zip": "*",
|
||||
"appstract/laravel-opcache": "^4.0.2",
|
||||
"assada/laravel-achievements": "^2.5",
|
||||
"doctrine/dbal": "^3.5.3",
|
||||
"fruitcake/laravel-cors": "^2.2",
|
||||
"doctrine/dbal": "^3.6.1",
|
||||
"gabrielelana/byte-units": "^0.5.0",
|
||||
"guzzlehttp/guzzle": "^7.5",
|
||||
"hdvinnie/laravel-html-purifier": "^1.0.2",
|
||||
"hdvinnie/laravel-joypixel-emojis": "^1.0.1",
|
||||
"hdvinnie/laravel-security-headers": "^1.0.1",
|
||||
"hdvinnie/laravel-html-purifier": "^2.0.0",
|
||||
"hdvinnie/laravel-joypixel-emojis": "^2.0.0",
|
||||
"hdvinnie/laravel-security-headers": "^2.0.0",
|
||||
"hootlex/laravel-moderation": "^1.1",
|
||||
"intervention/image": "^2.7.2",
|
||||
"joypixels/assets": "^6.6",
|
||||
"laravel/framework": "^v9.30.0",
|
||||
"laravel/tinker": "^2.8",
|
||||
"laravel/ui": "^3.4.6",
|
||||
"laravel/framework": "^10.4.1",
|
||||
"laravel/tinker": "^2.8.1",
|
||||
"laravel/ui": "^4.2.1",
|
||||
"league/flysystem-sftp-v3": "^3.10.3",
|
||||
"livewire/livewire": "^2.11.2",
|
||||
"marcreichel/igdb-laravel": "^3.6.1",
|
||||
"livewire/livewire": "^2.12.3",
|
||||
"marcreichel/igdb-laravel": "3.7.0",
|
||||
"paragonie/constant_time_encoding": "^2.6.3",
|
||||
"predis/predis": "^2.1.1",
|
||||
"spatie/laravel-backup": "^8.1.6",
|
||||
"predis/predis": "^2.1.2",
|
||||
"spatie/laravel-backup": "^8.1.7",
|
||||
"spatie/laravel-cookie-consent": "^3.2.4",
|
||||
"spatie/laravel-image-optimizer": "^1.7.1",
|
||||
"spatie/ssl-certificate": "^1.22.1",
|
||||
"symfony/dom-crawler": "^6.2.5",
|
||||
"theodorejb/polycast": "^1.0",
|
||||
"voku/anti-xss": "^4.1.39",
|
||||
"symfony/dom-crawler": "^6.2.7",
|
||||
"theodorejb/polycast": "dev-master",
|
||||
"voku/anti-xss": "^4.1.41",
|
||||
"vstelmakh/url-highlight": "^3.0.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"brianium/paratest": "^6.8.1",
|
||||
"brianium/paratest": "^6.9.1",
|
||||
"fakerphp/faker": "^1.21",
|
||||
"laravel/pint": "^1.4.1",
|
||||
"laravel/sail": "^1.19",
|
||||
"laravel/pint": "^1.6",
|
||||
"laravel/sail": "^1.21.2",
|
||||
"mockery/mockery": "^1.5.1",
|
||||
"nunomaduro/collision": "^6.4",
|
||||
"phpunit/phpunit": "^9.5.28",
|
||||
"spatie/laravel-ignition": "^1.6.4"
|
||||
"phpunit/phpunit": "^9.6.5",
|
||||
"spatie/laravel-ignition": "^2.0"
|
||||
},
|
||||
"config": {
|
||||
"preferred-install": "dist",
|
||||
@@ -59,6 +58,9 @@
|
||||
"optimize-autoloader": true,
|
||||
"platform": {
|
||||
"ext-mcrypt": "1.0"
|
||||
},
|
||||
"allow-plugins": {
|
||||
"pestphp/pest-plugin": true
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
|
||||
Generated
+672
-644
File diff suppressed because it is too large
Load Diff
+23
-37
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
@@ -144,6 +147,24 @@ return [
|
||||
|
||||
'cipher' => 'AES-256-CBC',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Maintenance Mode Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options determine the driver used to determine and
|
||||
| manage Laravel's "maintenance mode" status. The "cache" driver will
|
||||
| allow maintenance mode to be controlled across multiple machines.
|
||||
|
|
||||
| Supported drivers: "file", "cache"
|
||||
|
|
||||
*/
|
||||
|
||||
'maintenance' => [
|
||||
'driver' => 'file',
|
||||
// 'store' => 'redis',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Autoloaded Service Providers
|
||||
@@ -213,47 +234,12 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'aliases' => [
|
||||
|
||||
'App' => Illuminate\Support\Facades\App::class,
|
||||
'Arr' => Illuminate\Support\Arr::class,
|
||||
'Artisan' => Illuminate\Support\Facades\Artisan::class,
|
||||
'Auth' => Illuminate\Support\Facades\Auth::class,
|
||||
'Blade' => Illuminate\Support\Facades\Blade::class,
|
||||
'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
|
||||
'Bus' => Illuminate\Support\Facades\Bus::class,
|
||||
'Cache' => Illuminate\Support\Facades\Cache::class,
|
||||
'aliases' => Facade::defaultAliases()->merge([
|
||||
'CacheUser' => App\Helpers\CacheUser::class,
|
||||
'Config' => Illuminate\Support\Facades\Config::class,
|
||||
'Cookie' => Illuminate\Support\Facades\Cookie::class,
|
||||
'CookieConsent' => BrianFaust\CookieConsent\Facades\CookieConsent::class,
|
||||
'Crypt' => Illuminate\Support\Facades\Crypt::class,
|
||||
'DB' => Illuminate\Support\Facades\DB::class,
|
||||
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
|
||||
'Event' => Illuminate\Support\Facades\Event::class,
|
||||
'File' => Illuminate\Support\Facades\File::class,
|
||||
'Gate' => Illuminate\Support\Facades\Gate::class,
|
||||
'Hash' => Illuminate\Support\Facades\Hash::class,
|
||||
'Image' => Intervention\Image\Facades\Image::class,
|
||||
'Irc' => App\Bots\IRCAnnounceBot::class,
|
||||
'Lang' => Illuminate\Support\Facades\Lang::class,
|
||||
'Log' => Illuminate\Support\Facades\Log::class,
|
||||
'Mail' => Illuminate\Support\Facades\Mail::class,
|
||||
'Notification' => Illuminate\Support\Facades\Notification::class,
|
||||
'Password' => Illuminate\Support\Facades\Password::class,
|
||||
'Queue' => Illuminate\Support\Facades\Queue::class,
|
||||
'Redirect' => Illuminate\Support\Facades\Redirect::class,
|
||||
'Redis' => Illuminate\Support\Facades\Redis::class,
|
||||
'Request' => Illuminate\Support\Facades\Request::class,
|
||||
'Response' => Illuminate\Support\Facades\Response::class,
|
||||
'Route' => Illuminate\Support\Facades\Route::class,
|
||||
'Schema' => Illuminate\Support\Facades\Schema::class,
|
||||
'Session' => Illuminate\Support\Facades\Session::class,
|
||||
'Storage' => Illuminate\Support\Facades\Storage::class,
|
||||
'Str' => Illuminate\Support\Str::class,
|
||||
'URL' => Illuminate\Support\Facades\URL::class,
|
||||
'Validator' => Illuminate\Support\Facades\Validator::class,
|
||||
'View' => Illuminate\Support\Facades\View::class,
|
||||
],
|
||||
])->toArray(),
|
||||
|
||||
];
|
||||
|
||||
+5
-1
@@ -86,10 +86,14 @@ return [
|
||||
| than one user table or model in the application and you want to have
|
||||
| separate password reset settings based on the specific user types.
|
||||
|
|
||||
| The expire time is the number of minutes that the reset token should be
|
||||
| The expire time is the number of minutes that each reset token will be
|
||||
| considered valid. This security feature keeps tokens short-lived so
|
||||
| they have less time to be guessed. You may change this as needed.
|
||||
|
|
||||
| The throttle setting is the number of seconds a user must wait before
|
||||
| generating more password reset tokens. This prevents the user from
|
||||
| quickly generating a very large amount of password reset tokens.
|
||||
|
|
||||
*/
|
||||
|
||||
'passwords' => [
|
||||
|
||||
@@ -37,7 +37,12 @@ return [
|
||||
'app_id' => env('PUSHER_APP_ID'),
|
||||
'options' => [
|
||||
'cluster' => env('PUSHER_APP_CLUSTER'),
|
||||
'useTLS' => true,
|
||||
|
||||
'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
|
||||
'port' => env('PUSHER_PORT', 443),
|
||||
'scheme' => env('PUSHER_SCHEME', 'https'),
|
||||
'encrypted' => true,
|
||||
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
|
||||
],
|
||||
'client_options' => [
|
||||
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
|
||||
|
||||
+4
-4
@@ -99,12 +99,12 @@ return [
|
||||
| Cache Key Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing a RAM based store such as APC or Memcached, there might
|
||||
| be other applications utilizing the same cache. So, we'll specify a
|
||||
| value to get prefixed to all our keys so we can avoid collisions.
|
||||
| When utilizing the APC, database, memcached, Redis, or DynamoDB cache
|
||||
| stores there might be other applications using the same cache. For
|
||||
| that reason, you may prefix every cache key to avoid collisions.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug(config('app.name'), '_').'_cache'),
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
|
||||
|
||||
];
|
||||
|
||||
+16
-19
@@ -1,15 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author HDVinnie <hdinnovations@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
@@ -70,7 +61,6 @@ return [
|
||||
'options' => \extension_loaded('pdo_mysql') ? array_filter([
|
||||
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
|
||||
'dump' => [
|
||||
'dump_binary_path' => '/usr/bin', // only the path, so without `mysqldump` or `pg_dump`
|
||||
'use_single_transaction',
|
||||
@@ -105,6 +95,8 @@ return [
|
||||
'charset' => 'utf8',
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
|
||||
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
|
||||
],
|
||||
|
||||
],
|
||||
@@ -135,15 +127,20 @@ return [
|
||||
|
||||
'redis' => [
|
||||
|
||||
'client' => env('REDIS_CLIENT', 'predis'),
|
||||
'client' => env('REDIS_CLIENT', 'phpredis'),
|
||||
|
||||
'options' => [
|
||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
|
||||
],
|
||||
|
||||
'default' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD', null),
|
||||
'port' => env('REDIS_PORT', 6379),
|
||||
'database' => env('REDIS_DB', 0),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_DB', '0'),
|
||||
'read_write_timeout' => -1,
|
||||
],
|
||||
|
||||
@@ -151,9 +148,9 @@ return [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD', null),
|
||||
'port' => env('REDIS_PORT', 6379),
|
||||
'database' => env('REDIS_CACHE_DB', 1),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_CACHE_DB', '1'),
|
||||
'read_write_timeout' => -1,
|
||||
],
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ return [
|
||||
|
|
||||
| Here you may configure as many filesystem "disks" as you wish, and you
|
||||
| may even configure multiple disks of the same driver. Defaults have
|
||||
| been setup for each driver as an example of the required options.
|
||||
| been set up for each driver as an example of the required values.
|
||||
|
|
||||
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
||||
|
|
||||
@@ -33,6 +33,7 @@ return [
|
||||
'local' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app'),
|
||||
'throw' => false,
|
||||
],
|
||||
|
||||
'public' => [
|
||||
@@ -40,6 +41,7 @@ return [
|
||||
'root' => storage_path('app/public'),
|
||||
'url' => env('APP_URL').'/storage',
|
||||
'visibility' => 'public',
|
||||
'throw' => false,
|
||||
],
|
||||
|
||||
's3' => [
|
||||
@@ -51,6 +53,7 @@ return [
|
||||
'url' => env('AWS_URL'),
|
||||
'endpoint' => env('AWS_ENDPOINT'),
|
||||
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||
'throw' => false,
|
||||
],
|
||||
|
||||
'ftp' => [
|
||||
|
||||
+8
-4
@@ -30,7 +30,10 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
|
||||
'deprecations' => [
|
||||
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
|
||||
'trace' => false,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -78,10 +81,11 @@ return [
|
||||
'papertrail' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => SyslogUdpHandler::class,
|
||||
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
|
||||
'handler_with' => [
|
||||
'host' => env('PAPERTRAIL_URL'),
|
||||
'port' => env('PAPERTRAIL_PORT'),
|
||||
'host' => env('PAPERTRAIL_URL'),
|
||||
'port' => env('PAPERTRAIL_PORT'),
|
||||
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
|
||||
],
|
||||
],
|
||||
|
||||
|
||||
+15
-8
@@ -35,13 +35,14 @@ return [
|
||||
|
||||
'mailers' => [
|
||||
'smtp' => [
|
||||
'transport' => 'smtp',
|
||||
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
|
||||
'port' => env('MAIL_PORT', 587),
|
||||
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
|
||||
'username' => env('MAIL_USERNAME'),
|
||||
'password' => env('MAIL_PASSWORD'),
|
||||
'timeout' => null,
|
||||
'transport' => 'smtp',
|
||||
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
|
||||
'port' => env('MAIL_PORT', 587),
|
||||
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
|
||||
'username' => env('MAIL_USERNAME'),
|
||||
'password' => env('MAIL_PASSWORD'),
|
||||
'timeout' => null,
|
||||
'local_domain' => env('MAIL_EHLO_DOMAIN'),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
@@ -50,15 +51,21 @@ return [
|
||||
|
||||
'mailgun' => [
|
||||
'transport' => 'mailgun',
|
||||
// 'client' => [
|
||||
// 'timeout' => 5,
|
||||
// ],
|
||||
],
|
||||
|
||||
'postmark' => [
|
||||
'transport' => 'postmark',
|
||||
// 'client' => [
|
||||
// 'timeout' => 5,
|
||||
// ],
|
||||
],
|
||||
|
||||
'sendmail' => [
|
||||
'transport' => 'sendmail',
|
||||
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'),
|
||||
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
|
||||
],
|
||||
|
||||
'log' => [
|
||||
|
||||
+1
-11
@@ -1,15 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author HDVinnie <hdinnovations@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
@@ -29,6 +18,7 @@ return [
|
||||
'domain' => env('MAILGUN_DOMAIN'),
|
||||
'secret' => env('MAILGUN_SECRET'),
|
||||
'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
|
||||
'scheme' => 'https',
|
||||
],
|
||||
|
||||
'postmark' => [
|
||||
|
||||
@@ -22,37 +22,37 @@ return new class () extends Migration {
|
||||
foreach ($comments as $comment) {
|
||||
if ($comment->torrent_id !== null) {
|
||||
$comment->commentable_id = $comment->torrent_id;
|
||||
$comment->commentable_type = 'App\Models\Torrent';
|
||||
$comment->commentable_type = \App\Models\Torrent::class;
|
||||
$comment->save();
|
||||
}
|
||||
|
||||
if ($comment->article_id !== null) {
|
||||
$comment->commentable_id = $comment->article_id;
|
||||
$comment->commentable_type = 'App\Models\Article';
|
||||
$comment->commentable_type = \App\Models\Article::class;
|
||||
$comment->save();
|
||||
}
|
||||
|
||||
if ($comment->requests_id !== null) {
|
||||
$comment->commentable_id = $comment->requests_id;
|
||||
$comment->commentable_type = 'App\Models\TorrentRequest';
|
||||
$comment->commentable_type = \App\Models\TorrentRequest::class;
|
||||
$comment->save();
|
||||
}
|
||||
|
||||
if ($comment->collection_id !== null) {
|
||||
$comment->commentable_id = $comment->collection_id;
|
||||
$comment->commentable_type = 'App\Models\Collection';
|
||||
$comment->commentable_type = \App\Models\Collection::class;
|
||||
$comment->save();
|
||||
}
|
||||
|
||||
if ($comment->playlist_id !== null) {
|
||||
$comment->commentable_id = $comment->playlist_id;
|
||||
$comment->commentable_type = 'App\Models\Playlist';
|
||||
$comment->commentable_type = \App\Models\Playlist::class;
|
||||
$comment->save();
|
||||
}
|
||||
|
||||
if ($comment->ticket_id !== null) {
|
||||
$comment->commentable_id = $comment->ticket_id;
|
||||
$comment->commentable_type = 'App\Models\Ticket';
|
||||
$comment->commentable_type = \App\Models\Ticket::class;
|
||||
$comment->save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -7,8 +7,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -9,8 +9,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -7,8 +7,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -7,8 +7,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -7,8 +7,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
@@ -22,8 +20,6 @@ return new class () extends Migration {
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
|
||||
@@ -8,8 +8,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -8,8 +8,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -9,8 +9,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -7,8 +7,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -9,8 +9,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -9,8 +9,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -8,8 +8,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -8,8 +8,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -6,8 +6,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -58,8 +58,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -6,8 +6,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -24,8 +24,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -9,8 +9,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -9,8 +9,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -9,8 +9,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -8,8 +8,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -8,8 +8,6 @@ use Illuminate\Database\Migrations\Migration;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -8,8 +8,6 @@ use Illuminate\Database\Migrations\Migration;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -7,8 +7,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::drop('cast');
|
||||
Schema::drop('cast_episode');
|
||||
Schema::drop('cast_movie');
|
||||
Schema::drop('cast_season');
|
||||
Schema::drop('cast_tv');
|
||||
Schema::drop('crew_episode');
|
||||
Schema::drop('crew_movie');
|
||||
Schema::drop('crew_season');
|
||||
Schema::drop('crew_tv');
|
||||
Schema::drop('episode_guest_star');
|
||||
Schema::drop('episode_person');
|
||||
Schema::drop('person_movie');
|
||||
Schema::drop('person_season');
|
||||
Schema::drop('person_tv');
|
||||
|
||||
|
||||
Schema::create('occupations', function (Blueprint $table): void {
|
||||
$table->smallIncrements('id');
|
||||
$table->smallInteger('position');
|
||||
$table->string('name');
|
||||
});
|
||||
|
||||
DB::table('occupations')->insert([
|
||||
[
|
||||
'id' => 1,
|
||||
'position' => 1,
|
||||
'name' => 'Creator',
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'position' => 2,
|
||||
'name' => 'Director',
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'position' => 3,
|
||||
'name' => 'Writer',
|
||||
],
|
||||
[
|
||||
'id' => 4,
|
||||
'position' => 4,
|
||||
'name' => 'Producer',
|
||||
],
|
||||
[
|
||||
'id' => 5,
|
||||
'position' => 5,
|
||||
'name' => 'Composer',
|
||||
],
|
||||
[
|
||||
'id' => 6,
|
||||
'position' => 6,
|
||||
'name' => 'Cinematographer',
|
||||
],
|
||||
[
|
||||
'id' => 7,
|
||||
'position' => 7,
|
||||
'name' => 'Editor',
|
||||
],
|
||||
[
|
||||
'id' => 8,
|
||||
'position' => 8,
|
||||
'name' => 'Production Designer',
|
||||
],
|
||||
[
|
||||
'id' => 9,
|
||||
'position' => 9,
|
||||
'name' => 'Art Director',
|
||||
],
|
||||
[
|
||||
'id' => 10,
|
||||
'position' => 10,
|
||||
'name' => 'Actor',
|
||||
],
|
||||
]);
|
||||
|
||||
Schema::create('credits', function (Blueprint $table): void {
|
||||
$table->increments('id');
|
||||
$table->unsignedBigInteger('person_id');
|
||||
$table->unsignedBigInteger('movie_id')->nullable();
|
||||
$table->unsignedBigInteger('tv_id')->nullable();
|
||||
$table->unsignedSmallInteger('occupation_id');
|
||||
$table->unsignedInteger('order')->nullable();
|
||||
$table->string('character')->nullable();
|
||||
|
||||
$table->unique(['person_id', 'movie_id', 'tv_id', 'occupation_id', 'character']);
|
||||
|
||||
$table->foreign('person_id')->references('id')->on('person')->cascadeOnUpdate()->cascadeOnDelete();
|
||||
$table->foreign('movie_id')->references('id')->on('movie')->cascadeOnUpdate()->cascadeOnDelete();
|
||||
$table->foreign('tv_id')->references('id')->on('tv')->cascadeOnUpdate()->cascadeOnDelete();
|
||||
$table->foreign('occupation_id')->references('id')->on('occupations')->cascadeOnUpdate()->cascadeOnDelete();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author Roardom <roardom@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Occupation;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class OccupationSeeder extends Seeder
|
||||
{
|
||||
private $occupations;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->occupations = $this->getOccupations();
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto generated seed file.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
Occupation::upsert($this->occupations);
|
||||
}
|
||||
|
||||
private function getOccupations(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'id' => 1,
|
||||
'position' => 1,
|
||||
'name' => 'Creator',
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'position' => 2,
|
||||
'name' => 'Director',
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'position' => 3,
|
||||
'name' => 'Writer',
|
||||
],
|
||||
[
|
||||
'id' => 4,
|
||||
'position' => 4,
|
||||
'name' => 'Producer',
|
||||
],
|
||||
[
|
||||
'id' => 5,
|
||||
'position' => 5,
|
||||
'name' => 'Composer',
|
||||
],
|
||||
[
|
||||
'id' => 6,
|
||||
'position' => 6,
|
||||
'name' => 'Cinematographer',
|
||||
],
|
||||
[
|
||||
'id' => 7,
|
||||
'position' => 7,
|
||||
'name' => 'Editor',
|
||||
],
|
||||
[
|
||||
'id' => 8,
|
||||
'position' => 8,
|
||||
'name' => 'Production Designer',
|
||||
],
|
||||
[
|
||||
'id' => 9,
|
||||
'position' => 9,
|
||||
'name' => 'Art Director',
|
||||
],
|
||||
[
|
||||
'id' => 10,
|
||||
'position' => 10,
|
||||
'name' => 'Actor',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user