Move video over to software_id

This commit is contained in:
Deon George
2019-12-26 15:56:31 +11:00
parent 99ca07201e
commit 80a76559e5
8 changed files with 148 additions and 22 deletions

View File

@@ -5,9 +5,9 @@ namespace App\Models\Abstracted;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Schema;
use DB;
use Illuminate\Support\Facades\DB;
use App\Models\{Person,Tag};
use App\Models\{Person,Software,Tag};
abstract class Catalog extends Model
{
@@ -18,6 +18,11 @@ abstract class Catalog extends Model
return $this->belongsToMany(Person::class);
}
public function software()
{
return $this->belongsTo(Software::class);
}
public function tags()
{
return $this->belongsToMany(Tag::class);

View File

@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model as EloquentModel;
class Model extends EloquentModel
{
protected $fillable = ['name'];
protected $fillable = ['name','make_id'];
public function make()
{

View File

@@ -20,11 +20,6 @@ class Photo extends Abstracted\Catalog
8=>-90,
];
public function software()
{
return $this->belongsTo(Software::class);
}
public function getIDLinkAttribute()
{
return $this->HTMLLinkAttribute($this->id,url('p/info').'/');
@@ -184,12 +179,23 @@ class Photo extends Abstracted\Catalog
$this->gps_lon = static::latlon(preg_split('/,\s?/',$this->property('exif:GPSLongitude')),$this->property('exif:GPSLongitudeRef'));
}
// @todo Now set software_id
public function setMakeModel()
{
$this->make = $this->property('exif:Make') ? $this->property('exif:Make') : NULL;
$this->model = $this->property('exif:Model') ? $this->property('exif:Model') : NULL;
$this->software = $this->property('exif:Software') ? $this->property('exif:Software') : NULL;
$ma = Make::firstOrCreate([
'name'=>$this->property('exif:Make') ?: NULL,
]);
$mo = Model::firstOrCreate([
'name'=>$this->property('exif:Model') ?: NULL,
'make_id'=>$ma->id,
]);
$so = Software::firstOrCreate([
'name'=>$this->property('exif:Software') ?: NULL,
'model_id'=>$mo->id,
]);
$this->software_id = $so->id;
}
public function setSignature()

View File

@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
class Software extends Model
{
protected $fillable = ['name'];
protected $fillable = ['name','model_id'];
public function model()
{

View File

@@ -141,12 +141,24 @@ class Video extends Abstracted\Catalog
$this->gps_altitude = $this->property('gps_altitude');
}
// @todo Now set software_id
public function setMakeModel()
{
$this->make = $this->property('make');
$this->model = $this->property('model');
$this->software = $this->property('software');
$ma = Make::firstOrCreate([
'name'=>$this->property('make') ?: NULL,
]);
$mo = Model::firstOrCreate([
'name'=>$this->property('model') ?: NULL,
'make_id'=>$ma->id,
]);
$so = Software::firstOrCreate([
'name'=>$this->property('software') ?: NULL,
'model_id'=>$mo->id,
]);
$this->software_id = $so->id;
$this->type = $this->property('type');
$this->length = round($this->property('length'),2);
$this->codec = $this->property('codec');