Start of console commands enhancements
This commit is contained in:
@@ -180,8 +180,25 @@ abstract class Catalog extends Model
|
||||
return $format ? date('d-m-Y H:i:s',$t) : $t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return what the filename should be.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function file_name(bool $short=TRUE): string
|
||||
{
|
||||
// If the date created is not set, the file name will be based on the ID of the file.
|
||||
$file = sprintf('%s.%s',((is_null($this->date_created) OR ! $this->date_created)
|
||||
? sprintf('UNKNOWN/%07s',$this->file_path_id())
|
||||
: sprintf('%s_%03s',$this->date_created->format('Y/m/d-His'),$this->subsectime).
|
||||
((! static::$includeSubSecTime OR $this->subsectime) ? '' : sprintf('-%05s',$this->id))),$this->type());
|
||||
|
||||
return (($short OR preg_match('/^\//',$file)) ? '' : config('photo.dir').DIRECTORY_SEPARATOR).$file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the new name for the image
|
||||
* @deprecated
|
||||
*/
|
||||
public function file_path($short=FALSE,$new=FALSE)
|
||||
{
|
||||
@@ -304,6 +321,16 @@ abstract class Catalog extends Model
|
||||
return ($this->gps_lat AND $this->gps_lon) ? sprintf('%s/%s',$this->gps_lat,$this->gps_lon) : 'UNKNOWN';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return if this source file is readable.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isReadable(): bool
|
||||
{
|
||||
return is_readable($this->file_path());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an HTML checkbox
|
||||
*/
|
||||
@@ -371,6 +398,17 @@ abstract class Catalog extends Model
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flag to indicate if a file should be moved.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function mustMove(): bool
|
||||
{
|
||||
dump(['f'=>$this->filename,'fn'=>$this->file_name(),'test'=>($this->filename == $this->file_name())]);
|
||||
return $this->filename !== $this->file_name();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the id of the previous record
|
||||
*/
|
||||
|
Reference in New Issue
Block a user