Issues (374)

app/Models/MediaInfo.php (2 issues)

Labels
1
<?php
2
3
namespace App\Models;
4
5
use Illuminate\Database\Eloquent\Factories\HasFactory;
6
use Illuminate\Database\Eloquent\Model;
7
use Mhor\MediaInfo\Container\MediaInfoContainer;
8
9
class MediaInfo extends Model
10
{
11
    use HasFactory;
0 ignored issues
show
The trait Illuminate\Database\Eloquent\Factories\HasFactory requires the property $factoryClass which is not provided by App\Models\MediaInfo.
Loading history...
12
13
    protected $guarded = [];
14
15
    public static function addData($id, MediaInfoContainer $xmlArray): void
16
    {
17
        $mediainfoArray = $xmlArray->getGeneral();
18
        if (! $mediainfoArray) {
0 ignored issues
show
$mediainfoArray is of type Mhor\MediaInfo\Type\General, thus it always evaluated to true.
Loading history...
19
            return;
20
        }
21
22
        // Check if we have the same release in the database
23
        if (self::where('releases_id', $id)->exists()) {
24
            return;
25
        }
26
27
        self::insertOrIgnore([
28
            'releases_id' => $id,
29
            'movie_name' => $mediainfoArray->get('movie_name') ?? null,
30
            'file_name' => $mediainfoArray->get('file_name') ?? null,
31
            'unique_id' => $mediainfoArray->get('unique_id') ?? null,
32
            'created_at' => now(),
33
            'updated_at' => now(),
34
        ]);
35
    }
36
}
37