Refactor Catalog Model
This commit is contained in:
parent
2caff58f73
commit
32e2dcf347
@ -101,7 +101,8 @@ abstract class Catalog extends Model
|
|||||||
$query->where('id','<>',$this->attributes['id']);
|
$query->where('id','<>',$this->attributes['id']);
|
||||||
|
|
||||||
// Skip ignore dups
|
// Skip ignore dups
|
||||||
$query->where(fn($q)=>$q->whereNull('ignore_duplicate')->orWhere('ignore_duplicate',FALSE));
|
$query->where(fn($q)=>$q->whereNull('ignore_duplicate')
|
||||||
|
->orWhere('ignore_duplicate',FALSE));
|
||||||
|
|
||||||
// Exclude those marked as remove
|
// Exclude those marked as remove
|
||||||
$query->where(fn($q)=>$q->where('remove','<>',TRUE));
|
$query->where(fn($q)=>$q->where('remove','<>',TRUE));
|
||||||
@ -113,16 +114,18 @@ abstract class Catalog extends Model
|
|||||||
// Where the signature is the same
|
// Where the signature is the same
|
||||||
->orWhere(function($q) {
|
->orWhere(function($q) {
|
||||||
// Or they have the same time taken with the same camera
|
// Or they have the same time taken with the same camera
|
||||||
if ($this->attributes['created'] AND $this->software_id) {
|
if ($this->attributes['created'] && $this->software_id) {
|
||||||
$q->where(fn($q)=>$q->where('created','=',$this->attributes['created'])->orWhere('created_manual','=',$this->attributes['created']));
|
$q->where(fn($q)=>$q->where('created','=',$this->attributes['created'])
|
||||||
|
->orWhere('created_manual','=',$this->attributes['created']));
|
||||||
|
|
||||||
if (static::$includeSubSecTime)
|
if (static::$includeSubSecTime)
|
||||||
$q->where('subsectime','=',Arr::get($this->attributes,'subsectime'));
|
$q->where('subsectime','=',Arr::get($this->attributes,'subsectime'));
|
||||||
|
|
||||||
$q->where('software_id','=',$this->attributes['software_id']);
|
$q->where('software_id','=',$this->attributes['software_id']);
|
||||||
|
|
||||||
} elseif ($this->attributes['created_manual'] AND $this->software_id) {
|
} elseif ($this->attributes['created_manual'] && $this->software_id) {
|
||||||
$q->where(fn($q)=>$q->where('created','=',$this->attributes['created_manual'])->orWhere('created_manual','=',$this->attributes['created_manual']));
|
$q->where(fn($q)=>$q->where('created','=',$this->attributes['created_manual'])
|
||||||
|
->orWhere('created_manual','=',$this->attributes['created_manual']));
|
||||||
|
|
||||||
if (static::$includeSubSecTime)
|
if (static::$includeSubSecTime)
|
||||||
$q->where('subsectime','=',Arr::get($this->attributes,'subsectime'));
|
$q->where('subsectime','=',Arr::get($this->attributes,'subsectime'));
|
||||||
@ -364,15 +367,6 @@ abstract class Catalog extends Model
|
|||||||
return sprintf('<input type="checkbox" name="%s[%s]" value="1"%s>',$name,$id,$value ? ' checked="checked"' : '');
|
return sprintf('<input type="checkbox" name="%s[%s]" value="1"%s>',$name,$id,$value ? ' checked="checked"' : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get ID Info link
|
|
||||||
* @deprecated use a component
|
|
||||||
*/
|
|
||||||
protected function HTMLLinkAttribute($id,$url)
|
|
||||||
{
|
|
||||||
return sprintf('<a href="%s" target="%s">%s</a>',url($url,$id),$id,$id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set values from the media object
|
* Set values from the media object
|
||||||
*
|
*
|
||||||
@ -424,6 +418,8 @@ abstract class Catalog extends Model
|
|||||||
|
|
||||||
$this->software_id = $so->id;
|
$this->software_id = $so->id;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case 'subsectime':
|
case 'subsectime':
|
||||||
$this->subsectime = $this->getObjectOriginal($item);
|
$this->subsectime = $this->getObjectOriginal($item);
|
||||||
break;
|
break;
|
||||||
@ -479,7 +475,7 @@ abstract class Catalog extends Model
|
|||||||
|
|
||||||
public function isMoveableReason(): ?string
|
public function isMoveableReason(): ?string
|
||||||
{
|
{
|
||||||
return isset($this->move_reason) ? $this->move_reason : NULL;
|
return $this->move_reason ?? NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -564,20 +560,8 @@ abstract class Catalog extends Model
|
|||||||
return $value ? 'TRUE' : 'FALSE';
|
return $value ? 'TRUE' : 'FALSE';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo Check if this is redundant
|
|
||||||
*
|
|
||||||
* @param bool $includeme
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
private function list_duplicate($includeme=FALSE)
|
|
||||||
{
|
|
||||||
return $this->list_duplicates($includeme)->pluck('id');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find duplicate images based on some attributes of the current image
|
* Find duplicate images based on some attributes of the current image
|
||||||
* @deprecate Use static::duplicates()
|
|
||||||
*/
|
*/
|
||||||
private function list_duplicates($includeme=FALSE)
|
private function list_duplicates($includeme=FALSE)
|
||||||
{
|
{
|
||||||
@ -606,7 +590,7 @@ abstract class Catalog extends Model
|
|||||||
{
|
{
|
||||||
$query->where('date_created','=',$this->date_created ? $this->date_created : NULL);
|
$query->where('date_created','=',$this->date_created ? $this->date_created : NULL);
|
||||||
if (Schema::hasColumn($this->getTable(),'subsectime'))
|
if (Schema::hasColumn($this->getTable(),'subsectime'))
|
||||||
$query->where('subsectime','=',$this->subsectime ? $this->subsectime : NULL);
|
$query->where('subsectime','=',$this->subsectime ?: NULL);
|
||||||
|
|
||||||
if (! is_null($this->model))
|
if (! is_null($this->model))
|
||||||
$query->where('model','=',$this->model);
|
$query->where('model','=',$this->model);
|
||||||
|
Loading…
Reference in New Issue
Block a user