Add PHP type hints

This commit is contained in:
Shift
2023-03-30 14:15:39 +00:00
parent 5e7a2d9254
commit afb0f41611
220 changed files with 523 additions and 469 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ class InstallNntmux extends Command
parent::__construct();
}
public function handle()
public function handle(): void
{
$error = false;
@@ -36,7 +36,7 @@ class NntmuxDeleteUnVerifiedUsers extends Command
*
* @return mixed
*/
public function handle()
public function handle(): void
{
$this->info('Deleting unverified users.');
User::deleteUnVerified();
@@ -36,7 +36,7 @@ class NntmuxPopulateSearchIndexes extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): int
{
if ($this->option('releases') && $this->option('manticore')) {
$this->manticoreReleases();
@@ -146,7 +146,7 @@ class NntmuxPopulateSearchIndexes extends Command
/**
* @return void
*/
private function elasticReleases()
private function elasticReleases(): void
{
$elastic = new ElasticSearchSiteSearch();
$total = Release::count();
@@ -192,7 +192,7 @@ class NntmuxPopulateSearchIndexes extends Command
/**
* @return void
*/
private function elasticPreDB()
private function elasticPreDB(): void
{
$elastic = new ElasticSearchSiteSearch();
$total = Predb::count();
@@ -39,7 +39,7 @@ class NntmuxRemoveBadReleases extends Command
*
* @throws \Exception
*/
public function handle()
public function handle(): void
{
Release::query()->where('passwordstatus', '=', -2)->delete();
+1 -1
View File
@@ -38,7 +38,7 @@ class NntmuxResetDb extends Command
/**
* @throws \Exception
*/
public function handle()
public function handle(): void
{
if ($this->confirm('This script removes all releases, nzb files, samples, previews , nfos, truncates all article tables and resets all groups. Are you sure you want reset the DB?')) {
$timestart = now();
@@ -51,7 +51,7 @@ class NntmuxResetPostProcessing extends Command
*
* @return mixed
*/
public function handle()
public function handle(): void
{
if (empty($this->option('category'))) {
$qry = Release::query()->select(['id'])->get();
+1 -1
View File
@@ -36,7 +36,7 @@ class NntmuxResetTruncate extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): void
{
UsenetGroup::query()->update(['first_record' => 0, 'first_record_postdate' => null, 'last_record' => 0, 'last_record_postdate' => null, 'last_updated' => null]);
$this->info('Reseting all groups completed.');
@@ -36,7 +36,7 @@ class NntmuxUpdateExpiredRoles extends Command
*
* @return mixed
*/
public function handle()
public function handle(): void
{
$this->info('Updating expired roles.');
$this->info('Updating users that will have their roles expire or are already expired');
+1 -1
View File
@@ -33,7 +33,7 @@ class TmuxUIRestart extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): void
{
$this->call('tmux-ui:stop', ['--kill' => true]);
$this->call('tmux-ui:start');
+1 -1
View File
@@ -26,7 +26,7 @@ class TmuxUIStart extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): void
{
$tmux = new Tmux();
$tmux_session = Settings::settingValue('site.tmux.tmux_session') ?? 0;
+1 -1
View File
@@ -26,7 +26,7 @@ class TmuxUIStop extends Command
/**
* @throws \Exception
*/
public function handle()
public function handle(): void
{
$tmux = new Tmux();
$tmux->stopIfRunning();
+1 -1
View File
@@ -28,7 +28,7 @@ class UpdateNNTmuxDB extends Command
parent::__construct();
}
public function handle()
public function handle(): void
{
// also prevent web access.
$this->output->writeln('<info>Updating database</info>');
+2 -2
View File
@@ -22,7 +22,7 @@ class Kernel extends ConsoleKernel
*
* @return void
*/
protected function schedule(Schedule $schedule)
protected function schedule(Schedule $schedule): void
{
$schedule->command('disposable:update')->weekly();
$schedule->command('clean:directories')->hourly()->withoutOverlapping();
@@ -43,7 +43,7 @@ class Kernel extends ConsoleKernel
*
* @return void
*/
protected function commands()
protected function commands(): void
{
$this->load(__DIR__.'/Commands');
+1 -1
View File
@@ -31,7 +31,7 @@ class Handler extends ExceptionHandler
*
* @return void
*/
public function register()
public function register(): void
{
$this->reportable(function (Throwable $e) {
if (app()->bound('sentry')) {
+1 -1
View File
@@ -28,7 +28,7 @@ class PhpYenc
/**
* @param bool $ignore
*/
public static function decode(&$text, $ignore = false): bool|string
public static function decode(&$text, bool $ignore = false): bool|string
{
$crc = '';
// Extract the yEnc string itself.
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Admin;
use Illuminate\Http\RedirectResponse;
use App\Http\Controllers\BasePageController;
use App\Models\Category;
use Blacklight\Regexes;
@@ -41,7 +42,7 @@ class AdminCategoryRegexesController extends BasePageController
*
* @throws \Exception
*/
public function edit(Request $request)
public function edit(Request $request): RedirectResponse
{
$this->setAdminPrefs();
$regexes = new Regexes(['Settings' => null, 'Table_Name' => 'category_regexes']);
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Admin;
use Illuminate\Http\RedirectResponse;
use App\Http\Controllers\BasePageController;
use App\Models\User;
use Blacklight\Contents;
@@ -32,7 +33,7 @@ class AdminContentController extends BasePageController
*
* @throws \Exception
*/
public function create(Request $request)
public function create(Request $request): RedirectResponse
{
$this->setAdminPrefs();
$contents = new Contents();
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Admin;
use Illuminate\Http\RedirectResponse;
use App\Http\Controllers\BasePageController;
use App\Models\UsenetGroup;
use Illuminate\Http\Request;
@@ -67,7 +68,7 @@ class AdminGroupController extends BasePageController
*
* @throws \Exception
*/
public function edit(Request $request)
public function edit(Request $request): RedirectResponse
{
$this->setAdminPrefs();
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Admin;
use Illuminate\Http\RedirectResponse;
use App\Http\Controllers\BasePageController;
use App\Models\MovieInfo;
use App\Models\Release;
@@ -35,7 +36,7 @@ class AdminMovieController extends BasePageController
*
* @throws \Exception
*/
public function create(Request $request)
public function create(Request $request): RedirectResponse
{
if (! \defined('STDOUT')) {
\define('STDOUT', fopen('php://stdout', 'wb'));
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Admin;
use Illuminate\Http\RedirectResponse;
use App\Http\Controllers\BasePageController;
use App\Models\Category;
use App\Models\Release;
@@ -34,7 +35,7 @@ class AdminReleasesController extends BasePageController
*
* @throws \Exception
*/
public function edit(Request $request)
public function edit(Request $request): RedirectResponse
{
$this->setAdminPrefs();
$meta_title = $title = 'Release Edit';
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Admin;
use Illuminate\Http\RedirectResponse;
use App\Http\Controllers\BasePageController;
use App\Jobs\SendAccountChangedEmail;
use App\Models\Invitation;
@@ -79,7 +80,7 @@ class AdminUserController extends BasePageController
*
* @throws \Exception
*/
public function edit(Request $request)
public function edit(Request $request): RedirectResponse
{
$this->setAdminPrefs();
+2 -1
View File
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Api;
use Illuminate\Http\RedirectResponse;
use App\Events\UserAccessedApi;
use App\Http\Controllers\BasePageController;
use App\Models\Category;
@@ -245,7 +246,7 @@ class ApiV2Controller extends BasePageController
/**
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|void
*/
public function getNzb(Request $request)
public function getNzb(Request $request): RedirectResponse
{
$user = User::query()->where('api_token', $request->input('api_token'))->first();
event(new UserAccessedApi($user));
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Auth;
use Illuminate\Http\RedirectResponse;
use App\Http\Requests\Auth\LoginLoginRequest;
use App\Events\UserLoggedIn;
use App\Http\Controllers\Controller;
@@ -54,7 +55,7 @@ class LoginController extends Controller
* @throws \Illuminate\Auth\AuthenticationException
* @throws \Illuminate\Validation\ValidationException
*/
public function login(LoginLoginRequest $request)
public function login(LoginLoginRequest $request): RedirectResponse
{
$validator = Validator::make($request->all(), [
'username' => ['required'],
+8 -7
View File
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use Illuminate\View\View;
use Illuminate\Http\Request;
use App\Events\UserLoggedIn;
use App\Models\Category;
@@ -118,7 +119,7 @@ class BasePageController extends Controller
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function show404($message = null)
public function show404($message = null): View
{
if ($message !== null) {
return view('errors.404')->with('Message', $message);
@@ -130,7 +131,7 @@ class BasePageController extends Controller
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function show403()
public function show403(): View
{
return view('errors.403');
}
@@ -138,7 +139,7 @@ class BasePageController extends Controller
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function show503()
public function show503(): View
{
return view('errors.503')->with('Error', 'Service temporarily unavailable');
}
@@ -146,7 +147,7 @@ class BasePageController extends Controller
/**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function showBadBoy()
public function showBadBoy(): View
{
return view('errors.badboy')->with('Message', 'This is not you account.');
}
@@ -154,7 +155,7 @@ class BasePageController extends Controller
/**
* Show maintenance page.
*/
public function showMaintenance()
public function showMaintenance(): View
{
return view('errors.maintenance')->with('Message', 'We are performing an site maintenance.');
}
@@ -162,7 +163,7 @@ class BasePageController extends Controller
/**
* Show Security token mismatch page.
*/
public function showTokenError()
public function showTokenError(): View
{
return view('errors.tokenError')->with('Error', 'Token mismatch');
}
@@ -170,7 +171,7 @@ class BasePageController extends Controller
/**
* @param string $retry
*/
public function show429($retry = '')
public function show429(string $retry = '')
{
abort(429, $retry);
}
+2 -1
View File
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use Illuminate\Http\JsonResponse;
use Blacklight\Contents;
use Illuminate\Http\Request;
@@ -12,7 +13,7 @@ class ContentController extends BasePageController
*
* @throws \Exception
*/
public function show(Request $request)
public function show(Request $request): JsonResponse
{
$this->setPreferences();
$contents = new Contents();
+2 -1
View File
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use App\Models\DnzbFailure;
use App\Models\Predb;
@@ -30,7 +31,7 @@ class DetailsController extends BasePageController
*
* @throws \Exception
*/
public function show(Request $request, string $guid)
public function show(Request $request, string $guid): RedirectResponse
{
$this->setPreferences();
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use Illuminate\Http\RedirectResponse;
use App\Models\Forumpost;
use App\Models\Settings;
use Illuminate\Http\Request;
@@ -14,7 +15,7 @@ class ForumController extends BasePageController
*
* @throws \Exception
*/
public function forum(Request $request)
public function forum(Request $request): RedirectResponse
{
$this->setPreferences();
if ($this->isPostBack() && $request->has('addMessage') && $request->has('addSubject')) {
@@ -68,7 +69,7 @@ class ForumController extends BasePageController
*
* @throws \Exception
*/
public function getPosts($id, Request $request)
public function getPosts($id, Request $request): RedirectResponse
{
$this->setPreferences();
+2 -1
View File
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use Illuminate\Http\RedirectResponse;
use App\Jobs\SendAccountDeletedEmail;
use App\Models\ReleaseComment;
use App\Models\Settings;
@@ -103,7 +104,7 @@ class ProfileController extends BasePageController
*
* @throws \Exception
*/
public function edit(Request $request)
public function edit(Request $request): RedirectResponse
{
$this->setPreferences();
+2 -1
View File
@@ -2,6 +2,7 @@
namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
@@ -12,7 +13,7 @@ class Authenticate extends Middleware
* @param \Illuminate\Http\Request $request
* @return string
*/
protected function redirectTo($request)
protected function redirectTo(Request $request): string
{
if (! $request->expectsJson()) {
return route('login');
+3 -1
View File
@@ -2,6 +2,8 @@
namespace App\Http\Middleware;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Http\Request;
use Closure;
use Illuminate\Support\Facades\Auth;
@@ -15,7 +17,7 @@ class ClearanceMiddleware
*
* @throws \Exception
*/
public function handle($request, Closure $next)
public function handle(Request $request, Closure $next): Response
{
$user = $request->user();
+3 -1
View File
@@ -2,6 +2,8 @@
namespace App\Http\Middleware;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Http\Request;
use App\Support\Google2FAAuthenticator;
use Closure;
@@ -13,7 +15,7 @@ class Google2FAMiddleware
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public function handle($request, Closure $next)
public function handle(Request $request, Closure $next): Response
{
$authenticator = app(Google2FAAuthenticator::class)->boot($request);
@@ -2,6 +2,8 @@
namespace App\Http\Middleware;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Http\Request;
use Closure;
use Illuminate\Support\Facades\Auth;
@@ -14,7 +16,7 @@ class RedirectIfAuthenticated
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
public function handle(Request $request, Closure $next, ?string $guard = null): Response
{
if (Auth::guard($guard)->check()) {
return redirect()->to('/');
+1 -1
View File
@@ -11,7 +11,7 @@ class LoginLoginRequest extends FormRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
return [
'g-recaptcha-response' => [
@@ -11,7 +11,7 @@ class RegisterRegisterRequest extends FormRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
return [
'g-recaptcha-response' => [
@@ -11,7 +11,7 @@ class ShowLinkRequestFormForgotPasswordRequest extends FormRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
return ['g-recaptcha-response' => [
'required',
+1 -1
View File
@@ -11,7 +11,7 @@ class ContactContactURequest extends FormRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
return ['g-recaptcha-response' => [
'required',
@@ -11,7 +11,7 @@ class Disable2faPasswordSecurityRequest extends FormRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
return ['current-password' => [
'required',
+1 -1
View File
@@ -28,7 +28,7 @@ class RemoveInactiveAccounts implements ShouldQueue
*
* @return void
*/
public function handle()
public function handle(): void
{
User::query()->where('lastlogin', '<', now()->subMonths(6))->where('apiaccess', '<', now()->subMonths(6))->where('roles_id', '=', 1)->delete();
User::query()->where('lastlogin', '<', now()->subMonths(6))->whereNull('apiaccess')->where('roles_id', '=', 1)->delete();
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Jobs;
use App\Models\User;
use App\Mail\AccountChange;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -24,7 +25,7 @@ class SendAccountChangedEmail implements ShouldQueue
*
* @param \App\Models\User $user
*/
public function __construct($user)
public function __construct(User $user)
{
$this->user = $user;
}
@@ -34,7 +35,7 @@ class SendAccountChangedEmail implements ShouldQueue
*
* @return void
*/
public function handle()
public function handle(): void
{
Mail::to($this->user->email)->send(new AccountChange($this->user));
}
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Jobs;
use App\Models\User;
use App\Mail\AccountDeleted;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -24,7 +25,7 @@ class SendAccountDeletedEmail implements ShouldQueue
*
* @param \App\Models\User $user
*/
public function __construct($user)
public function __construct(User $user)
{
$this->user = $user;
}
@@ -34,7 +35,7 @@ class SendAccountDeletedEmail implements ShouldQueue
*
* @return void
*/
public function handle()
public function handle(): void
{
Mail::to(config('mail.from.address'))->send(new AccountDeleted($this->user));
}
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Jobs;
use App\Models\User;
use App\Mail\AccountExpired;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -24,7 +25,7 @@ class SendAccountExpiredEmail implements ShouldQueue
*
* @param \App\Models\User $user
*/
public function __construct($user)
public function __construct(User $user)
{
$this->user = $user;
}
@@ -34,7 +35,7 @@ class SendAccountExpiredEmail implements ShouldQueue
*
* @return void
*/
public function handle()
public function handle(): void
{
Mail::to($this->user->email)->send(new AccountExpired($this->user));
}
+1 -1
View File
@@ -34,7 +34,7 @@ class SendAccountWillExpireEmail implements ShouldQueue
*
* @return void
*/
public function handle()
public function handle(): void
{
Mail::to($this->user->email)->send(new AccountWillExpire($this->user, $this->days));
}
+1 -1
View File
@@ -30,7 +30,7 @@ class SendContactUsEmail implements ShouldQueue
$this->mailBody = $mailBody;
}
public function handle()
public function handle(): void
{
Mail::to($this->mailTo)->send(new ContactUs($this->email, $this->mailBody));
}
+1 -1
View File
@@ -40,7 +40,7 @@ class SendInviteEmail implements ShouldQueue
*
* @return void
*/
public function handle()
public function handle(): void
{
Mail::to($this->email)->send(new SendInvite($this->user, $this->url));
}
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Jobs;
use App\Models\User;
use App\Mail\NewAccountCreatedEmail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -24,7 +25,7 @@ class SendNewRegisteredAccountMail implements ShouldQueue
*
* @param \App\Models\User $user
*/
public function __construct($user)
public function __construct(User $user)
{
$this->user = $user;
}
@@ -34,7 +35,7 @@ class SendNewRegisteredAccountMail implements ShouldQueue
*
* @return void
*/
public function handle()
public function handle(): void
{
Mail::to(config('mail.from.address'))->send(new NewAccountCreatedEmail($this->user));
}
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Jobs;
use App\Models\User;
use App\Mail\ForgottenPassword;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -26,7 +27,7 @@ class SendPasswordForgottenEmail implements ShouldQueue
*
* @param \App\Models\User $user
*/
public function __construct($user, $resetLink)
public function __construct(User $user, $resetLink)
{
$this->user = $user;
$this->resetLink = $resetLink;
@@ -37,7 +38,7 @@ class SendPasswordForgottenEmail implements ShouldQueue
*
* @return void
*/
public function handle()
public function handle(): void
{
Mail::to($this->user->email)->send(new ForgottenPassword($this->resetLink));
}
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Jobs;
use App\Models\User;
use App\Mail\PasswordReset;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -30,7 +31,7 @@ class SendPasswordResetEmail implements ShouldQueue
* @param \App\Models\User $user
* @param string $newPass
*/
public function __construct($user, $newPass)
public function __construct(User $user, string $newPass)
{
$this->user = $user;
$this->newPass = $newPass;
@@ -41,7 +42,7 @@ class SendPasswordResetEmail implements ShouldQueue
*
* @return void
*/
public function handle()
public function handle(): void
{
Mail::to($this->user->email)->send(new PasswordReset($this->user, $this->newPass));
}
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Jobs;
use App\Models\User;
use App\Mail\WelcomeEmail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -24,7 +25,7 @@ class SendWelcomeEmail implements ShouldQueue
*
* @param \App\Models\User $user
*/
public function __construct($user)
public function __construct(User $user)
{
$this->user = $user;
}
@@ -34,7 +35,7 @@ class SendWelcomeEmail implements ShouldQueue
*
* @return void
*/
public function handle()
public function handle(): void
{
Mail::to($this->user->email)->send(new WelcomeEmail($this->user));
}
+1 -1
View File
@@ -22,7 +22,7 @@ class UpdateUserAccessedApi
*
* @return void
*/
public function handle(UserAccessedApi $event)
public function handle(UserAccessedApi $event): void
{
User::find($event->user->id)->update(['apiaccess' => now()]);
}
+1 -1
View File
@@ -22,7 +22,7 @@ class UpdateUserLoggedIn
*
* @return void
*/
public function handle(UserLoggedIn $event)
public function handle(UserLoggedIn $event): void
{
User::find($event->user->id)->update(
[
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Mail;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
@@ -30,7 +31,7 @@ class AccountChange extends Mailable
*
* @param \App\Models\User $user
*/
public function __construct($user)
public function __construct(User $user)
{
$this->user = $user;
$this->siteEmail = config('mail.from.address');
@@ -44,7 +45,7 @@ class AccountChange extends Mailable
*
* @throws \Exception
*/
public function build()
public function build(): static
{
return $this->from($this->siteEmail)->subject('Account Changed')->view('emails.accountChange')->with(['account' => $this->user->role->name, 'username' => $this->user->username, 'site' => $this->siteTitle]);
}
+1 -1
View File
@@ -40,7 +40,7 @@ class AccountDeleted extends Mailable
*
* @throws \Exception
*/
public function build()
public function build(): static
{
return $this->from($this->siteEmail)->subject('User Account Deleted')->view('emails.accountDelete')->with(['username' => $this->user->username, 'site' => $this->siteTitle]);
}
+1 -1
View File
@@ -33,7 +33,7 @@ class AccountExpired extends Mailable
*
* @throws \Exception
*/
public function build()
public function build(): static
{
return $this->from($this->siteEmail)->subject('Account expired')->view('emails.accountExpired')->with(['account' => $this->user->role->name, 'username' => $this->user->username, 'site' => $this->siteTitle]);
}
+1 -1
View File
@@ -42,7 +42,7 @@ class AccountWillExpire extends Mailable
*
* @return $this
*/
public function build()
public function build(): static
{
return $this->from($this->siteEmail)->subject('Account about to expire')->view('emails.accountAboutToExpire')->with(['account' => $this->user->role->name, 'username' => $this->user->username, 'site' => $this->siteTitle, 'days' => $this->days]);
}
+1 -1
View File
@@ -30,7 +30,7 @@ class ContactUs extends Mailable
*
* @throws \Exception
*/
public function build()
public function build(): static
{
return $this->from($this->mailFrom)->subject('Contact form submitted')->replyTo($this->mailFrom)->view('emails.contactUs')->with(['mailBody' => $this->mailBody]);
}
+1 -1
View File
@@ -41,7 +41,7 @@ class ForgottenPassword extends Mailable
*
* @throws \Exception
*/
public function build()
public function build(): static
{
return $this->from($this->siteEmail)->subject('Forgotten password reset')->view('emails.forgottenPassword')->with(['resetLink' => $this->resetLink, 'site' => $this->siteTitle]);
}
+1 -1
View File
@@ -42,7 +42,7 @@ class NewAccountCreatedEmail extends Mailable
*
* @return $this
*/
public function build()
public function build(): static
{
return $this->from($this->siteEmail)->subject('New account registered')->view('emails.newAccountCreated')->with(['username' => $this->user->username, 'site' => $this->siteTitle]);
}
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Mail;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
@@ -35,7 +36,7 @@ class PasswordReset extends Mailable
*
* @param \App\Models\User $user
*/
public function __construct($user, $newPass)
public function __construct(User $user, $newPass)
{
$this->user = $user;
$this->newPass = $newPass;
@@ -50,7 +51,7 @@ class PasswordReset extends Mailable
*
* @throws \Exception
*/
public function build()
public function build(): static
{
return $this->from($this->siteEmail)->subject('Password reset')->view('emails.passwordReset')->with(['newPass' => $this->newPass, 'userName' => $this->user->username, 'site' => $this->siteTitle]);
}
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Mail;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
@@ -35,7 +36,7 @@ class SendInvite extends Mailable
*
* @param \App\Models\User $user
*/
public function __construct($user, $invite)
public function __construct(User $user, $invite)
{
$this->user = $user;
$this->invite = $invite;
@@ -50,7 +51,7 @@ class SendInvite extends Mailable
*
* @throws \Exception
*/
public function build()
public function build(): static
{
return $this->from($this->siteEmail)->subject('Invite received')->view('emails.sendinvite')->with(['invite' => $this->invite, 'username' => $this->user['username'], 'site' => $this->siteTitle, 'email' => $this->user['email']]);
}
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Mail;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
@@ -30,7 +31,7 @@ class WelcomeEmail extends Mailable
*
* @param \App\Models\User $user
*/
public function __construct($user)
public function __construct(User $user)
{
$this->user = $user;
$this->siteEmail = config('mail.from.address');
@@ -42,7 +43,7 @@ class WelcomeEmail extends Mailable
*
* @return $this
*/
public function build()
public function build(): static
{
return $this->from($this->siteEmail)->subject('Welcome to '.$this->siteTitle)->view('emails.welcome')->with(['username' => $this->user->username, 'site' => $this->siteTitle]);
}
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Model;
/**
@@ -78,7 +79,7 @@ class AnidbInfo extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function title()
public function title(): BelongsTo
{
return $this->belongsTo(AnidbTitle::class, 'anidbid');
}
@@ -86,7 +87,7 @@ class AnidbInfo extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function episode()
public function episode(): BelongsTo
{
return $this->belongsTo(AnidbEpisode::class, 'anidbid');
}
+2 -2
View File
@@ -70,7 +70,7 @@ class BookInfo extends Model
/**
* @return string
*/
public function searchableAs()
public function searchableAs(): string
{
return 'ix_bookinfo_author_title_ft';
}
@@ -78,7 +78,7 @@ class BookInfo extends Model
/**
* @return array
*/
public function toSearchableArray()
public function toSearchableArray(): array
{
return [
'author' => $this->author,
+3 -3
View File
@@ -270,7 +270,7 @@ class Category extends Model
/**
* @return HasMany
*/
public function releases()
public function releases(): HasMany
{
return $this->hasMany(Release::class, 'categories_id');
}
@@ -278,7 +278,7 @@ class Category extends Model
/**
* @return BelongsTo
*/
public function parent()
public function parent(): BelongsTo
{
return $this->belongsTo(RootCategory::class, 'root_categories_id');
}
@@ -311,7 +311,7 @@ class Category extends Model
/**
* @return string
*/
public static function getCategorySearch(array $cat = [])
public static function getCategorySearch(array $cat = []): string
{
$categories = [];
// If multiple categories were sent in a single array position, slice and add them
+3 -2
View File
@@ -2,6 +2,7 @@
namespace App\Models;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Database\Eloquent\Model;
/**
@@ -59,7 +60,7 @@ class Forumpost extends Model
* @param int $sticky
* @param int $replies
*/
public static function add($parentId, $userid, $subject, $message, $locked = 0, $sticky = 0, $replies = 0): int
public static function add($parentId, $userid, $subject, $message, int $locked = 0, int $sticky = 0, int $replies = 0): int
{
if ($message === '') {
return -1;
@@ -140,7 +141,7 @@ class Forumpost extends Model
* @param $start
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public static function getBrowseRange()
public static function getBrowseRange(): LengthAwarePaginator
{
return self::query()
->where('forumpost.parentid', '=', 0)
+2 -2
View File
@@ -68,7 +68,7 @@ class GamesInfo extends Model
/**
* @return string
*/
public function searchableAs()
public function searchableAs(): string
{
return 'ix_title_ft';
}
@@ -76,7 +76,7 @@ class GamesInfo extends Model
/**
* @return array
*/
public function toSearchableArray()
public function toSearchableArray(): array
{
return [
'title' => $this->title,
+2 -2
View File
@@ -79,7 +79,7 @@ class MusicInfo extends Model
/**
* @return string
*/
public function searchableAs()
public function searchableAs(): string
{
return 'ix_musicinfo_artist_title_ft';
}
@@ -87,7 +87,7 @@ class MusicInfo extends Model
/**
* @return array
*/
public function toSearchableArray()
public function toSearchableArray(): array
{
return [
'artist' => $this->artist,
+4 -4
View File
@@ -155,7 +155,7 @@ class Predb extends Model
* @param string $cleanerName
* @return array|false Array with title/id from PreDB if found, false if not found.
*/
public static function matchPre($cleanerName)
public static function matchPre(string $cleanerName)
{
if (empty($cleanerName)) {
return false;
@@ -189,7 +189,7 @@ class Predb extends Model
*
* @throws \Exception
*/
public static function getAll($search = '')
public static function getAll(string $search = '')
{
$expiresAt = now()->addMinutes(config('nntmux.cache_expiry_medium'));
$predb = Cache::get(md5($search));
@@ -238,7 +238,7 @@ class Predb extends Model
/**
* @return string
*/
public function searchableAs()
public function searchableAs(): string
{
return 'ft_predb_filename';
}
@@ -246,7 +246,7 @@ class Predb extends Model
/**
* @return array
*/
public function toSearchableArray()
public function toSearchableArray(): array
{
return [
'filename' => $this->filename,
+2 -1
View File
@@ -2,6 +2,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Model;
/**
@@ -50,7 +51,7 @@ class PredbHash extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function predb()
public function predb(): BelongsTo
{
return $this->belongsTo(Predb::class, 'predb_id');
}
+18 -14
View File
@@ -2,6 +2,10 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Blacklight\ElasticSearchSiteSearch;
use Blacklight\ManticoreSearch;
use Blacklight\NZB;
@@ -163,7 +167,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function group()
public function group(): BelongsTo
{
return $this->belongsTo(UsenetGroup::class, 'groups_id');
}
@@ -171,7 +175,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function download()
public function download(): HasMany
{
return $this->hasMany(UserDownload::class, 'releases_id');
}
@@ -179,7 +183,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function userRelease()
public function userRelease(): HasMany
{
return $this->hasMany(UsersRelease::class, 'releases_id');
}
@@ -192,7 +196,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function category()
public function category(): BelongsTo
{
return $this->belongsTo(Category::class, 'categories_id');
}
@@ -200,7 +204,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function predb()
public function predb(): BelongsTo
{
return $this->belongsTo(Predb::class, 'predb_id');
}
@@ -208,7 +212,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function failed()
public function failed(): HasMany
{
return $this->hasMany(DnzbFailure::class, 'release_id');
}
@@ -216,7 +220,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function releaseExtra()
public function releaseExtra(): HasMany
{
return $this->hasMany(ReleaseExtraFull::class, 'releases_id');
}
@@ -224,7 +228,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function nfo()
public function nfo(): HasOne
{
return $this->hasOne(ReleaseNfo::class, 'releases_id');
}
@@ -232,7 +236,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function comment()
public function comment(): HasMany
{
return $this->hasMany(ReleaseComment::class, 'releases_id');
}
@@ -240,7 +244,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function releaseGroup()
public function releaseGroup(): HasMany
{
return $this->hasMany(ReleasesGroups::class, 'releases_id');
}
@@ -248,7 +252,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function video()
public function video(): BelongsTo
{
return $this->belongsTo(Video::class, 'videos_id');
}
@@ -256,7 +260,7 @@ class Release extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function episode()
public function episode(): BelongsTo
{
return $this->belongsTo(TvEpisode::class, 'tv_episodes_id');
}
@@ -345,7 +349,7 @@ class Release extends Model
*
* @throws \Exception
*/
public static function updateGrab($guid): void
public static function updateGrab(string $guid): void
{
$updateGrabs = ((int) Settings::settingValue('..grabstatus') !== 0);
if ($updateGrabs) {
@@ -541,7 +545,7 @@ class Release extends Model
*
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public static function getFailedRange()
public static function getFailedRange(): LengthAwarePaginator
{
$failedList = self::query()
->select(['name', 'searchname', 'size', 'guid', 'totalpart', 'postdate', 'adddate', 'grabs', 'cp.title as parent_category', 'c.title as sub_category', DB::raw("CONCAT(cp.title, ' > ', c.title) AS category_name")])
+7 -5
View File
@@ -2,6 +2,8 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Database\Eloquent\Model;
/**
@@ -68,7 +70,7 @@ class ReleaseComment extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function release()
public function release(): BelongsTo
{
return $this->belongsTo(Release::class, 'releases_id');
}
@@ -76,7 +78,7 @@ class ReleaseComment extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
public function user(): BelongsTo
{
return $this->belongsTo(User::class, 'users_id');
}
@@ -95,7 +97,7 @@ class ReleaseComment extends Model
/**
* @return array
*/
public static function getComments($id)
public static function getComments($id): array
{
return self::query()->where('releases_id', $id)->orderByDesc('created_at')->get()->toArray();
}
@@ -157,7 +159,7 @@ class ReleaseComment extends Model
*
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public static function getCommentsRange()
public static function getCommentsRange(): LengthAwarePaginator
{
$range = self::query()
->select(['release_comments.*', 'releases.guid'])
@@ -189,7 +191,7 @@ class ReleaseComment extends Model
/**
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public static function getCommentsForUserRange($uid)
public static function getCommentsForUserRange($uid): LengthAwarePaginator
{
return self::query()
->select(['release_comments.*', 'r.guid', 'r.searchname', 'u.username'])
+1 -1
View File
@@ -90,7 +90,7 @@ class ReleaseFile extends Model
*
* @throws \Exception
*/
public static function addReleaseFiles($id, $name, $size, $createdTime, $hasPassword, $hash = '', $crc = ''): int
public static function addReleaseFiles($id, $name, $size, $createdTime, $hasPassword, string $hash = '', string $crc = ''): int
{
// Check if we already have this data in table
$duplicateCheck = self::query()->where('releases_id', $id)->where('name', $name)->first();
+1 -1
View File
@@ -48,7 +48,7 @@ class ReleaseNfo extends Model
* @param bool $getNfoString
* @return \Illuminate\Database\Eloquent\Model|null|static
*/
public static function getReleaseNfo($id, $getNfoString = true)
public static function getReleaseNfo($id, bool $getNfoString = true)
{
$nfo = self::query()->where('releases_id', $id)->whereNotNull('nfo')->select(['releases_id']);
if ($getNfoString === true) {
+3 -3
View File
@@ -122,7 +122,7 @@ class Settings extends Model
* @param string $key
* @return mixed
*/
public function __get($key)
public function __get(string $key)
{
$override = self::query()->where('name', $key)->first();
@@ -144,7 +144,7 @@ class Settings extends Model
*
* @throws \RuntimeException
*/
public static function toTree($excludeUnsectioned = true): array
public static function toTree(bool $excludeUnsectioned = true): array
{
$results = self::cursor()->remember();
@@ -195,7 +195,7 @@ class Settings extends Model
* @return bool|null TRUE if Db version is greater than or eaqual to $requiredVersion,
* false if not, and null if the version isn't available to check against.
*/
public function isDbVersionAtLeast($requiredVersion): ?bool
public function isDbVersionAtLeast(string $requiredVersion): ?bool
{
$this->fetchDbVersion();
if (empty($this->dbVersion)) {
+2 -2
View File
@@ -47,7 +47,7 @@ class SteamApp extends Model
/**
* @return string
*/
public function searchableAs()
public function searchableAs(): string
{
return 'ix_name_ft';
}
@@ -55,7 +55,7 @@ class SteamApp extends Model
/**
* @return array
*/
public function toSearchableArray()
public function toSearchableArray(): array
{
return [
'name' => $this->name,
+2 -1
View File
@@ -2,6 +2,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Model;
/**
@@ -58,7 +59,7 @@ class TvEpisode extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function release()
public function release(): HasMany
{
return $this->hasMany(Release::class, 'tv_episodes_id');
}
+11 -9
View File
@@ -2,6 +2,8 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Blacklight\ColorCLI;
use Blacklight\NNTP;
use Blacklight\NZB;
@@ -94,7 +96,7 @@ class UsenetGroup extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function release()
public function release(): HasMany
{
return $this->hasMany(Release::class, 'groups_id');
}
@@ -197,7 +199,7 @@ class UsenetGroup extends Model
* @param string $name The group name.
* @return false|int false on failure, groups_id on success.
*/
public static function getIDByName($name)
public static function getIDByName(string $name)
{
$res = self::query()->where('name', $name)->first(['id']);
@@ -211,7 +213,7 @@ class UsenetGroup extends Model
* @param int $active Constrain query to active status
* @return mixed
*/
public static function getGroupsCount($groupname = '', $active = -1)
public static function getGroupsCount(string $groupname = '', int $active = -1)
{
$res = self::query();
@@ -231,7 +233,7 @@ class UsenetGroup extends Model
* @param null $active
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public static function getGroupsRange($groupname = '', $active = null)
public static function getGroupsRange(string $groupname = '', $active = null): LengthAwarePaginator
{
$groups = self::query()->groupBy('id')->orderBy('name');
@@ -254,7 +256,7 @@ class UsenetGroup extends Model
*
* @return int
*/
public static function updateGroup($group)
public static function updateGroup($group): int
{
return self::query()->where('id', $group['id'])->update(
[
@@ -278,7 +280,7 @@ class UsenetGroup extends Model
* @param string $groupName The full name of the usenet group being evaluated
* @return string|bool The name of the group replacing shorthand prefix or false if groupname was malformed
*/
public static function isValidGroup($groupName)
public static function isValidGroup(string $groupName)
{
if (preg_match('/^([\w\-]+\.)+[\w\-]+$/i', $groupName)) {
return preg_replace('/^a\.b\./i', 'alt.binaries.', $groupName, 1);
@@ -425,7 +427,7 @@ class UsenetGroup extends Model
*
* @throws \Exception
*/
public static function addBulk($groupList, $active = 1, $backfill = 1)
public static function addBulk(string $groupList, int $active = 1, int $backfill = 1)
{
if (preg_match('/^\s*$/m', $groupList)) {
$ret = 'No group list provided.';
@@ -477,7 +479,7 @@ class UsenetGroup extends Model
* @param string $column Which column active/backfill
* @param int $status Which status we are setting
*/
public static function updateGroupStatus($id, $column, $status = 0): string
public static function updateGroupStatus(int $id, string $column, int $status = 0): string
{
self::query()->where('id', $id)->update(
[
@@ -493,7 +495,7 @@ class UsenetGroup extends Model
*
* @param int $id The Group ID to disable
*/
public static function disableIfNotExist($id): void
public static function disableIfNotExist(int $id): void
{
self::updateGroupStatus($id, 'active');
(new ColorCLI())->error('Group does not exist on server, disabling');
+13 -10
View File
@@ -2,6 +2,9 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Collection;
use App\Jobs\SendAccountExpiredEmail;
use App\Jobs\SendAccountWillExpireEmail;
use App\Jobs\SendInviteEmail;
@@ -198,7 +201,7 @@ class User extends Authenticatable
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function role()
public function role(): BelongsTo
{
return $this->belongsTo(Role::class, 'roles_id');
}
@@ -206,7 +209,7 @@ class User extends Authenticatable
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function request()
public function request(): HasMany
{
return $this->hasMany(UserRequest::class, 'users_id');
}
@@ -214,7 +217,7 @@ class User extends Authenticatable
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function download()
public function download(): HasMany
{
return $this->hasMany(UserDownload::class, 'users_id');
}
@@ -222,7 +225,7 @@ class User extends Authenticatable
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function release()
public function release(): HasMany
{
return $this->hasMany(UsersRelease::class, 'users_id');
}
@@ -230,7 +233,7 @@ class User extends Authenticatable
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function series()
public function series(): HasMany
{
return $this->hasMany(UserSerie::class, 'users_id');
}
@@ -238,7 +241,7 @@ class User extends Authenticatable
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function invitation()
public function invitation(): HasMany
{
return $this->hasMany(Invitation::class, 'users_id');
}
@@ -246,7 +249,7 @@ class User extends Authenticatable
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function failedRelease()
public function failedRelease(): HasMany
{
return $this->hasMany(DnzbFailure::class, 'users_id');
}
@@ -254,7 +257,7 @@ class User extends Authenticatable
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function comment()
public function comment(): HasMany
{
return $this->hasMany(ReleaseComment::class, 'users_id');
}
@@ -273,7 +276,7 @@ class User extends Authenticatable
* @param string $host
* @param string $email
*/
public static function getCount($role = '', $username = '', $host = '', $email = ''): int
public static function getCount(string $role = '', string $username = '', string $host = '', string $email = ''): int
{
$res = self::query()->where('email', '<>', 'sharing@nZEDb.com');
@@ -399,7 +402,7 @@ class User extends Authenticatable
*
* @throws \Throwable
*/
public static function getRange($start, $offset, $orderBy, string $userName = '', ?string $email = '', ?string $host = '', ?string $role = '', bool $apiRequests = false)
public static function getRange($start, $offset, $orderBy, string $userName = '', ?string $email = '', ?string $host = '', ?string $role = '', bool $apiRequests = false): Collection
{
if ($apiRequests) {
UserRequest::clearApiRequests(false);
+4 -3
View File
@@ -2,6 +2,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Model;
/**
@@ -47,7 +48,7 @@ class UserDownload extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
public function user(): BelongsTo
{
return $this->belongsTo(User::class, 'users_id');
}
@@ -55,7 +56,7 @@ class UserDownload extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function release()
public function release(): BelongsTo
{
return $this->belongsTo(Release::class, 'releases_id');
}
@@ -67,7 +68,7 @@ class UserDownload extends Model
*
* @throws \Exception
*/
public static function getDownloadRequests($userID): int
public static function getDownloadRequests(int $userID): int
{
// Clear old requests.
self::whereUsersId($userID)->where('timestamp', '<', now()->subDay())->delete();
+4 -3
View File
@@ -2,6 +2,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
@@ -51,7 +52,7 @@ class UserRequest extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
public function user(): BelongsTo
{
return $this->belongsTo(User::class, 'users_id');
}
@@ -74,7 +75,7 @@ class UserRequest extends Model
* @throws \Exception
* @throws \Throwable
*/
public static function getApiRequests($userID): int
public static function getApiRequests(int $userID): int
{
// Clear old requests.
self::clearApiRequests($userID);
@@ -89,7 +90,7 @@ class UserRequest extends Model
* @param string $token API token of the user
* @param string $request The API request.
*/
public static function addApiRequest($token, $request): void
public static function addApiRequest(string $token, string $request): void
{
$userID = User::query()->select(['id'])->where('api_token', $token)->value('id');
self::query()->insert(['users_id' => $userID, 'request' => $request, 'timestamp' => now()]);
+2 -1
View File
@@ -2,6 +2,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Model;
/**
@@ -43,7 +44,7 @@ class UserSerie extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
public function user(): BelongsTo
{
return $this->belongsTo(User::class, 'users_id');
}
+8 -6
View File
@@ -2,6 +2,8 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Database\Eloquent\Model;
/**
@@ -64,7 +66,7 @@ class Video extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function alias()
public function alias(): HasMany
{
return $this->hasMany(VideoAlias::class, 'videos_id');
}
@@ -72,7 +74,7 @@ class Video extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function release()
public function release(): HasMany
{
return $this->hasMany(Release::class, 'videos_id');
}
@@ -80,7 +82,7 @@ class Video extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function episode()
public function episode(): HasMany
{
return $this->hasMany(TvEpisode::class, 'videos_id');
}
@@ -107,7 +109,7 @@ class Video extends Model
* @param string $showname
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public static function getRange($showname = '')
public static function getRange(string $showname = ''): LengthAwarePaginator
{
$sql = self::query()
->select(['videos.*', 'tv_info.summary', 'tv_info.publisher', 'tv_info.image'])
@@ -126,7 +128,7 @@ class Video extends Model
*
* @param string $showname
*/
public static function getCount($showname = ''): int
public static function getCount(string $showname = ''): int
{
$res = self::query()->join('tv_info', 'videos.id', '=', 'tv_info.videos_id');
@@ -143,7 +145,7 @@ class Video extends Model
* @param string $letter
* @param string $showname
*/
public static function getSeriesList($uid, $letter = '', $showname = ''): array
public static function getSeriesList($uid, string $letter = '', string $showname = ''): array
{
if (($letter !== '') && $letter === '0-9') {
$letter = '[0-9]';
+2 -1
View File
@@ -2,6 +2,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Model;
/**
@@ -37,7 +38,7 @@ class VideoAlias extends Model
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function video()
public function video(): BelongsTo
{
return $this->belongsTo(Video::class, 'videos_id');
}
+1 -1
View File
@@ -20,7 +20,7 @@ class UserServiceObserver
*
* @throws \Jrean\UserVerification\Exceptions\ModelNotCompliantException
*/
public function created(User $user)
public function created(User $user): void
{
$roleData = Role::query()->where('id', $user->roles_id);
$rateLimit = $roleData->value('rate_limit');
+2 -2
View File
@@ -12,7 +12,7 @@ class AppServiceProvider extends ServiceProvider
*
* @return void
*/
public function boot()
public function boot(): void
{
Paginator::useBootstrap();
$smarty = app('smarty.view');
@@ -24,7 +24,7 @@ class AppServiceProvider extends ServiceProvider
*
* @return void
*/
public function register()
public function register(): void
{
//
}
+1 -1
View File
@@ -20,7 +20,7 @@ class AuthServiceProvider extends ServiceProvider
*
* @return void
*/
public function boot()
public function boot(): void
{
}
}
+1 -1
View File
@@ -12,7 +12,7 @@ class BroadcastServiceProvider extends ServiceProvider
*
* @return void
*/
public function boot()
public function boot(): void
{
Broadcast::routes();
+1 -1
View File
@@ -37,7 +37,7 @@ class EventServiceProvider extends ServiceProvider
*
* @return void
*/
public function boot()
public function boot(): void
{
parent::boot();
+3 -3
View File
@@ -13,7 +13,7 @@ class HorizonServiceProvider extends HorizonApplicationServiceProvider
*
* @return void
*/
public function boot()
public function boot(): void
{
parent::boot();
@@ -29,7 +29,7 @@ class HorizonServiceProvider extends HorizonApplicationServiceProvider
*
* @return void
*/
protected function gate()
protected function gate(): void
{
Gate::define('viewHorizon', function ($user) {
return in_array($user->email, [
@@ -43,7 +43,7 @@ class HorizonServiceProvider extends HorizonApplicationServiceProvider
*
* @return void
*/
public function register()
public function register(): void
{
//
}
+5 -5
View File
@@ -14,7 +14,7 @@ class RouteServiceProvider extends ServiceProvider
*
* @return void
*/
public function boot()
public function boot(): void
{
//
@@ -26,7 +26,7 @@ class RouteServiceProvider extends ServiceProvider
*
* @return void
*/
public function map()
public function map(): void
{
$this->mapApiRoutes();
@@ -42,7 +42,7 @@ class RouteServiceProvider extends ServiceProvider
*
* @return void
*/
protected function mapWebRoutes()
protected function mapWebRoutes(): void
{
Route::middleware('web')
->group(base_path('routes/web.php'));
@@ -55,7 +55,7 @@ class RouteServiceProvider extends ServiceProvider
*
* @return void
*/
protected function mapApiRoutes()
protected function mapApiRoutes(): void
{
Route::prefix('api')
->middleware('api')
@@ -69,7 +69,7 @@ class RouteServiceProvider extends ServiceProvider
*
* @return void
*/
protected function mapRssRoutes()
protected function mapRssRoutes(): void
{
Route::prefix('rss')
->middleware('api')
+3 -3
View File
@@ -14,7 +14,7 @@ class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
*
* @return void
*/
public function register()
public function register(): void
{
// Telescope::night();
@@ -37,7 +37,7 @@ class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
*
* @return void
*/
protected function hideSensitiveRequestDetails()
protected function hideSensitiveRequestDetails(): void
{
if ($this->app->isLocal()) {
return;
@@ -59,7 +59,7 @@ class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
*
* @return void
*/
protected function gate()
protected function gate(): void
{
Gate::define('viewTelescope', function ($user) {
return in_array($user->email, [
+2 -2
View File
@@ -13,7 +13,7 @@ class UserServiceProvider extends ServiceProvider
*
* @return void
*/
public function register()
public function register(): void
{
//
}
@@ -23,7 +23,7 @@ class UserServiceProvider extends ServiceProvider
*
* @return void
*/
public function boot()
public function boot(): void
{
User::observe(UserServiceObserver::class);
}