Replace insertGetId method with Model::create

This commit is contained in:
DariusIII
2018-02-02 13:42:41 +01:00
parent c992efe05c
commit 73b4ca4ed9
15 changed files with 27 additions and 32 deletions
+2 -4
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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);
+2 -2
View File
@@ -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(