Added handling of created_manual, revert some file_path()

This commit is contained in:
Deon George
2020-01-05 18:02:32 +11:00
parent 0b6b3021fd
commit 270f63144b
4 changed files with 30 additions and 7 deletions

View File

@@ -97,7 +97,21 @@ abstract class Catalog extends Model
->orWhere(function($q) {
// Or they have the same time taken with the same camera
if ($this->attributes['created'] AND $this->software_id) {
$q->where('created','=',$this->attributes['created'] ?: NULL);
$q->where(function ($q) {
$q->where('created','=',$this->attributes['created'])
->orWhere('created_manual','=',$this->attributes['created']);
});
if (static::$includeSubSecTime)
$q->where('subsectime','=',Arr::get($this->attributes,'subsectime'));
$q->where('software_id','=',$this->attributes['software_id']);
} elseif ($this->attributes['created_manual'] AND $this->software_id) {
$q->where(function ($q) {
$q->where('created','=',$this->attributes['created_manual'])
->orWhere('created_manual','=',$this->attributes['created_manual']);
});
if (static::$includeSubSecTime)
$q->where('subsectime','=',Arr::get($this->attributes,'subsectime'));
@@ -272,6 +286,11 @@ abstract class Catalog extends Model
return (! is_readable($this->file_path())) ? NULL : filesize($this->file_path());
}
public function getCreatedAttribute(): Carbon
{
return $this->created_manual ?: $this->asDateTime($this->attributes['created']);
}
/**
* Return item dimensions
*/
@@ -314,10 +333,6 @@ abstract class Catalog extends Model
return $this->HTMLCheckbox('ignore_duplicate',$this->id,$this->ignore_duplicate);
}
public function getDateCreatedAttribute() {
return $this->attributes['date_created'] ? Carbon::createFromTimestamp($this->attributes['date_created']) : NULL;
}
/**
* @deprecated
*/