Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve loadExists for API Controller
Browse files Browse the repository at this point in the history
Obi-Wana committed Dec 20, 2024
1 parent e08afb5 commit 24632ec
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions app/Http/Controllers/API/TorrentController.php
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@ public function index(): TorrentsResource
*/
public function store(Request $request): \Illuminate\Http\JsonResponse
{
$user = $request->user()->loadExists();
$user = $request->user()->loadExists('internals');
abort_unless($user->can_upload ?? $user->group->can_upload, 403, __('torrent.cant-upload').' '.__('torrent.cant-upload-desc'));

$requestFile = $request->file('torrent');
@@ -166,22 +166,22 @@ public function store(Request $request): \Illuminate\Http\JsonResponse
$torrent->stream = $request->input('stream');
$torrent->sd = $request->input('sd');
$torrent->personal_release = $request->input('personal_release') ?? 0;
$torrent->internal = $user->group->is_modo || $user->internals()->exists() ? ($request->input('internal') ?? 0) : 0;
$torrent->featured = $user->group->is_modo || $user->internals()->exists() ? ($request->input('featured') ?? false) : false;
$torrent->doubleup = $user->group->is_modo || $user->internals()->exists() ? ($request->input('doubleup') ?? 0) : 0;
$torrent->refundable = $user->group->is_modo || $user->internals()->exists() ? ($request->input('refundable') ?? false) : false;
$torrent->internal = $user->group->is_modo || $user->internals_exists ? ($request->input('internal') ?? 0) : 0;

Check failure on line 169 in app/Http/Controllers/API/TorrentController.php

GitHub Actions / php 8.3 on ubuntu-22.04

Access to an undefined property App\Models\User::$internals_exists.
$torrent->featured = $user->group->is_modo || $user->internals_exists ? ($request->input('featured') ?? false) : false;

Check failure on line 170 in app/Http/Controllers/API/TorrentController.php

GitHub Actions / php 8.3 on ubuntu-22.04

Access to an undefined property App\Models\User::$internals_exists.
$torrent->doubleup = $user->group->is_modo || $user->internals_exists ? ($request->input('doubleup') ?? 0) : 0;

Check failure on line 171 in app/Http/Controllers/API/TorrentController.php

GitHub Actions / php 8.3 on ubuntu-22.04

Access to an undefined property App\Models\User::$internals_exists.
$torrent->refundable = $user->group->is_modo || $user->internals_exists ? ($request->input('refundable') ?? false) : false;

Check failure on line 172 in app/Http/Controllers/API/TorrentController.php

GitHub Actions / php 8.3 on ubuntu-22.04

Access to an undefined property App\Models\User::$internals_exists.
$du_until = $request->input('du_until');

if (($user->group->is_modo || $user->internals()->exists()) && isset($du_until)) {
if (($user->group->is_modo || $user->internals_exists) && isset($du_until)) {

Check failure on line 175 in app/Http/Controllers/API/TorrentController.php

GitHub Actions / php 8.3 on ubuntu-22.04

Access to an undefined property App\Models\User::$internals_exists.
$torrent->du_until = Carbon::now()->addDays($request->integer('du_until'));
}
$torrent->free = $user->group->is_modo || $user->internals()->exists() ? ($request->input('free') ?? 0) : 0;
$torrent->free = $user->group->is_modo || $user->internals_exists ? ($request->input('free') ?? 0) : 0;

Check failure on line 178 in app/Http/Controllers/API/TorrentController.php

GitHub Actions / php 8.3 on ubuntu-22.04

Access to an undefined property App\Models\User::$internals_exists.
$fl_until = $request->input('fl_until');

if (($user->group->is_modo || $user->internals()->exists()) && isset($fl_until)) {
if (($user->group->is_modo || $user->internals_exists) && isset($fl_until)) {

Check failure on line 181 in app/Http/Controllers/API/TorrentController.php

GitHub Actions / php 8.3 on ubuntu-22.04

Access to an undefined property App\Models\User::$internals_exists.
$torrent->fl_until = Carbon::now()->addDays($request->integer('fl_until'));
}
$torrent->sticky = $user->group->is_modo || $user->internals()->exists() ? ($request->input('sticky') ?? 0) : 0;
$torrent->sticky = $user->group->is_modo || $user->internals_exists ? ($request->input('sticky') ?? 0) : 0;

Check failure on line 184 in app/Http/Controllers/API/TorrentController.php

GitHub Actions / php 8.3 on ubuntu-22.04

Access to an undefined property App\Models\User::$internals_exists.
$torrent->moderated_at = Carbon::now();
$torrent->moderated_by = User::SYSTEM_USER_ID;

0 comments on commit 24632ec

Please sign in to comment.