mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-28 17:01:16 +00:00
Replace insertGetId method with Model::create
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
2018-02-02 DariusIII
|
||||
* Chg: Replace insertGetId method with Model::create
|
||||
* Chg: Replace all of getById functions with Model::find
|
||||
* Fix: Fix getByIdAndRssToken function
|
||||
* Chg: Use replace getById user lookup with User model find built in function(does the same thing as custom function)
|
||||
|
||||
@@ -281,7 +281,7 @@ class Group extends Model
|
||||
*/
|
||||
public static function addGroup($group): bool
|
||||
{
|
||||
return self::query()->insertGetId(
|
||||
return self::create(
|
||||
[
|
||||
'name' => trim($group['name']),
|
||||
'description' => isset($group['description']) ? trim($group['description']) : '',
|
||||
@@ -293,7 +293,7 @@ class Group extends Model
|
||||
'minsizetoformrelease' => $group['minsizetoformrelease'] === '' ? null : $group['minsizetoformrelease'],
|
||||
'minfilestoformrelease' => $group['minfilestoformrelease'] === '' ? null : $group['minfilestoformrelease'],
|
||||
]
|
||||
);
|
||||
)->id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,7 +36,7 @@ class Invitation extends Model
|
||||
*/
|
||||
public static function addInvite(int $uid, string $inviteToken)
|
||||
{
|
||||
self::query()->insertGetId(['guid' => $inviteToken, 'users_id' => $uid, 'created_at' => Carbon::now()]);
|
||||
self::create(['guid' => $inviteToken, 'users_id' => $uid]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -81,7 +81,7 @@ class Menu extends Model
|
||||
*/
|
||||
public static function addMenu($menu)
|
||||
{
|
||||
return self::query()->insertGetId(
|
||||
return self::create(
|
||||
[
|
||||
'href' => $menu['href'],
|
||||
'title' => $menu['title'],
|
||||
@@ -91,7 +91,7 @@ class Menu extends Model
|
||||
'menueval' => $menu['menueval'],
|
||||
'newwindow' => $menu['newwindow'],
|
||||
]
|
||||
);
|
||||
)->id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -88,16 +88,15 @@ class ReleaseFile extends Model
|
||||
$duplicateCheck = self::query()->where('releases_id', $id)->where('name', utf8_encode($name))->first();
|
||||
|
||||
if ($duplicateCheck === null) {
|
||||
$insert = self::query()->insertGetId(
|
||||
$insert = self::create(
|
||||
[
|
||||
'releases_id' => $id,
|
||||
'name' => utf8_encode($name),
|
||||
'size' => $size,
|
||||
'created_at' => $createdTime,
|
||||
'updated_at' => Carbon::now(),
|
||||
'passworded' => $hasPassword,
|
||||
]
|
||||
);
|
||||
)->id;
|
||||
|
||||
if (\strlen($hash) === 32) {
|
||||
ParHash::insertIgnore(['releases_id' => $id, 'hash' => $hash]);
|
||||
|
||||
@@ -46,7 +46,7 @@ class RoleExcludedCategory extends Model
|
||||
self::delRoleCategoryExclusions($role);
|
||||
if (\count($catids) > 0) {
|
||||
foreach ($catids as $catid) {
|
||||
self::query()->insertGetId(['user_roles_id' => $role, 'categories_id' => $catid, 'created_at' => Carbon::now()]);
|
||||
self::create(['user_roles_id' => $role, 'categories_id' => $catid]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ class UserExcludedCategory extends Model
|
||||
self::delUserCategoryExclusions($uid);
|
||||
if (\count($catids) > 0) {
|
||||
foreach ($catids as $catid) {
|
||||
self::query()->insertGetId(['users_id' => $uid, 'categories_id' => $catid, 'created_at' => Carbon::now()]);
|
||||
self::create(['users_id' => $uid, 'categories_id' => $catid]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class UserRole extends Model
|
||||
*/
|
||||
public static function addRole($name, $apirequests, $downloadrequests, $defaultinvites, $canpreview, $hideads, $donation, $addYear): int
|
||||
{
|
||||
return self::query()->insertGetId(
|
||||
return self::create(
|
||||
[
|
||||
'name' => $name,
|
||||
'apirequests' => $apirequests,
|
||||
@@ -84,7 +84,7 @@ class UserRole extends Model
|
||||
'donation' => $donation,
|
||||
'addyears' => $addYear,
|
||||
]
|
||||
);
|
||||
)->id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,13 +42,12 @@ class UsersRelease extends Model
|
||||
*/
|
||||
public static function addCart($uid, $releaseid): int
|
||||
{
|
||||
return self::query()->insertGetId(
|
||||
return self::create(
|
||||
[
|
||||
'users_id' => $uid,
|
||||
'releases_id' => $releaseid,
|
||||
'created_at' => Carbon::now(),
|
||||
]
|
||||
);
|
||||
)->id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-4
@@ -630,7 +630,7 @@ class Books
|
||||
|
||||
$check = BookInfo::query()->where('asin', $book['asin'])->first();
|
||||
if ($check === null) {
|
||||
$bookId = BookInfo::query()->insertGetId(
|
||||
$bookId = BookInfo::create(
|
||||
[
|
||||
'title' => $book['title'],
|
||||
'author' => $book['author'],
|
||||
@@ -645,10 +645,8 @@ class Books
|
||||
'overview' =>$book['overview'],
|
||||
'genre' => $book['genre'],
|
||||
'cover' => $book['cover'],
|
||||
'created_at' => Carbon::now(),
|
||||
'updated_at' => Carbon::now(),
|
||||
]
|
||||
);
|
||||
)->id;
|
||||
} else {
|
||||
if ($check !== null) {
|
||||
$bookId = $check['id'];
|
||||
|
||||
+1
-1
@@ -644,7 +644,7 @@ class Games
|
||||
if (\in_array(strtolower($genreName), $genreAssoc, false)) {
|
||||
$genreKey = array_search(strtolower($genreName), $genreAssoc, false);
|
||||
} else {
|
||||
$genreKey = Genre::query()->insertGetId(['title' => $genreName, 'type' => Genres::GAME_TYPE]);
|
||||
$genreKey = Genre::create(['title' => $genreName, 'type' => Genres::GAME_TYPE])->id;
|
||||
}
|
||||
|
||||
$game['gamesgenre'] = $genreName;
|
||||
|
||||
+3
-5
@@ -483,7 +483,7 @@ class Music
|
||||
if (\in_array(strtolower($genreName), $genreassoc, false)) {
|
||||
$genreKey = array_search(strtolower($genreName), $genreassoc, false);
|
||||
} else {
|
||||
$genreKey = Genre::query()->insertGetId(['title' => $genreName, 'type' => Genres::MUSIC_TYPE]);
|
||||
$genreKey = Genre::create(['title' => $genreName, 'type' => Genres::MUSIC_TYPE])->id;
|
||||
}
|
||||
}
|
||||
$mus['musicgenre'] = $genreName;
|
||||
@@ -491,7 +491,7 @@ class Music
|
||||
|
||||
$check = MusicInfo::query()->where('asin', $mus['asin'])->first(['id']);
|
||||
if ($check === null) {
|
||||
$musicId = MusicInfo::query()->insertGetId(
|
||||
$musicId = MusicInfo::create(
|
||||
[
|
||||
'title' => $mus['title'],
|
||||
'asin' =>$mus['asin'],
|
||||
@@ -505,10 +505,8 @@ class Music
|
||||
'genres_id' => (int) $mus['musicgenres_id'] === -1 ? 'null' : $mus['musicgenres_id'],
|
||||
'tracks' => $mus['tracks'],
|
||||
'cover' => $mus['cover'],
|
||||
'created_at' => Carbon::now(),
|
||||
'updated_at' => Carbon::now(),
|
||||
]
|
||||
);
|
||||
)->id;
|
||||
} else {
|
||||
$musicId = $check['id'];
|
||||
MusicInfo::query()->where('id', $musicId)->update(
|
||||
|
||||
+2
-2
@@ -200,7 +200,7 @@ class Nfo
|
||||
$check = ReleaseNfo::query()->where('releases_id', $release['id'])->first(['releases_id']);
|
||||
|
||||
if ($check === null) {
|
||||
ReleaseNfo::query()->insertGetId(['releases_id' => $release['id'], 'nfo' => "\x1f\x8b\x08\x00".gzcompress($nfo)]);
|
||||
ReleaseNfo::create(['releases_id' => $release['id'], 'nfo' => "\x1f\x8b\x08\x00".gzcompress($nfo)]);
|
||||
}
|
||||
|
||||
Release::query()->where('id', $release['id'])->update(['nfostatus' => self::NFO_FOUND]);
|
||||
@@ -337,7 +337,7 @@ class Nfo
|
||||
|
||||
$ckReleaseId = ReleaseNfo::query()->where('releases_id', $arr['id'])->first(['releases_id']);
|
||||
if ($ckReleaseId === null) {
|
||||
ReleaseNfo::query()->insertGetId(['releases_id' => $arr['id'], 'nfo' => "\x1f\x8b\x08\x00".gzcompress($fetchedBinary)]);
|
||||
ReleaseNfo::create(['releases_id' => $arr['id'], 'nfo' => "\x1f\x8b\x08\x00".gzcompress($fetchedBinary)]);
|
||||
}
|
||||
Release::query()->where('id', $arr['id'])->update(['nfostatus' => self::NFO_FOUND]);
|
||||
$ret++;
|
||||
|
||||
+3
-3
@@ -440,7 +440,7 @@ class XXX
|
||||
{
|
||||
$res = '';
|
||||
if ($genre !== null) {
|
||||
$res = Genre::query()->insertGetId(['title' => $genre, 'type' => Category::XXX_ROOT, 'disabled' => 0]);
|
||||
$res = Genre::create(['title' => $genre, 'type' => Category::XXX_ROOT, 'disabled' => 0]);
|
||||
}
|
||||
|
||||
return $res;
|
||||
@@ -598,7 +598,7 @@ class XXX
|
||||
|
||||
// Insert New XXX Information
|
||||
if ($check === null) {
|
||||
$xxxID = XxxInfo::query()->insertGetId(
|
||||
$xxxID = XxxInfo::create(
|
||||
[
|
||||
'title' => $mov['title'],
|
||||
'tagline' => $mov['tagline'],
|
||||
@@ -612,7 +612,7 @@ class XXX
|
||||
'directurl' => $mov['directurl'],
|
||||
'classused' => $mov['classused'],
|
||||
]
|
||||
);
|
||||
)->id;
|
||||
// Update BoxCover.
|
||||
if (! empty($mov['cover'])) {
|
||||
$cover = $this->releaseImage->saveImage($xxxID.'-cover', $mov['cover'], $this->imgSavePath);
|
||||
|
||||
@@ -227,7 +227,7 @@ abstract class TV extends Videos
|
||||
|
||||
if ($videoId === null) {
|
||||
// Insert the Show
|
||||
$videoId = Video::query()->insertGetId(
|
||||
$videoId = Video::create(
|
||||
[
|
||||
'type' => $show['type'],
|
||||
'title' => $show['title'],
|
||||
@@ -241,7 +241,7 @@ abstract class TV extends Videos
|
||||
'imdb' => $show['imdb'],
|
||||
'tmdb' => $show['tmdb'],
|
||||
]
|
||||
);
|
||||
)->id;
|
||||
// Insert the supplementary show info
|
||||
TvInfo::query()
|
||||
->insert(
|
||||
|
||||
Reference in New Issue
Block a user