chore: better firstOrCreate usage

This commit is contained in:
Phan An 2019-11-29 22:23:30 +01:00
parent 3e245ee13e
commit ef140d8819
5 changed files with 4 additions and 5 deletions

View file

@ -20,7 +20,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
* @property Collection $songs
* @property bool $is_unknown
*
* @method static self firstOrCreate(array $where, array $params)
* @method static self firstOrCreate(array $where, array $params = [])
*/
class Album extends Model
{

View file

@ -19,7 +19,7 @@ use Illuminate\Database\Eloquent\Relations\HasManyThrough;
* @property bool $has_image
*
* @method static self find(int $id)
* @method static self firstOrCreate(array $where, array $params)
* @method static self firstOrCreate(array $where, array $params = [])
*/
class Artist extends Model
{
@ -84,7 +84,7 @@ class Artist extends Model
$name = trim($name) ?: self::UNKNOWN_NAME;
return static::firstOrCreate(compact('name'), compact('name'));
return static::firstOrCreate(compact('name'));
}
/**

View file

@ -12,6 +12,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
* @property Song $song
* @property User $user
* @property int $id
* @method self firstOrCreate(array $where, array $params = [])
*/
class Interaction extends Model
{

View file

@ -11,7 +11,6 @@ class AlbumTableSeeder extends Seeder
Album::firstOrCreate([
'id' => Album::UNKNOWN_ID,
], [
'id' => Album::UNKNOWN_ID,
'artist_id' => Artist::UNKNOWN_ID,
'name' => Album::UNKNOWN_NAME,
'cover' => Album::UNKNOWN_COVER,

View file

@ -10,7 +10,6 @@ class ArtistTableSeeder extends Seeder
Artist::firstOrCreate([
'id' => Artist::UNKNOWN_ID,
], [
'id' => Artist::UNKNOWN_ID,
'name' => Artist::UNKNOWN_NAME,
]);
}