Update photo import to laravel 6.4
This commit is contained in:
parent
f6b456aa3d
commit
83d6d1e055
@ -3,7 +3,6 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
|
||||
class CatalogScan extends Command
|
||||
{
|
||||
@ -31,56 +30,51 @@ class CatalogScan extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$class = 'App\Model\\'.$this->argument('type');
|
||||
$class = 'App\Models\\'.$this->argument('type');
|
||||
|
||||
if (! class_exists($class))
|
||||
abort(500,sprintf('No class [%s]',$this->argument('type')));
|
||||
if (! class_exists($class))
|
||||
abort(500,sprintf('No class [%s]',$this->argument('type')));
|
||||
|
||||
$o = $class::findOrFail($this->argument('id'));
|
||||
$o = $class::findOrFail($this->argument('id'));
|
||||
|
||||
if (! is_readable($o->file_path()))
|
||||
{
|
||||
$this->warn(sprintf('Ignoring [%s], it is not readable',$o->file_path()));
|
||||
exit;
|
||||
}
|
||||
if (! is_readable($o->file_path())) {
|
||||
$this->warn(sprintf('Ignoring [%s], it is not readable',$o->file_path()));
|
||||
exit;
|
||||
}
|
||||
|
||||
$o->setDateCreated();
|
||||
$o->setSubSecTime();
|
||||
$o->setSignature();
|
||||
$o->setMakeModel();
|
||||
$o->setLocation();
|
||||
$o->setHeightWidth();
|
||||
$o->setThumbnail();
|
||||
$o->setDateCreated();
|
||||
$o->setSubSecTime();
|
||||
$o->setSignature();
|
||||
$o->setMakeModel();
|
||||
$o->setLocation();
|
||||
$o->setHeightWidth();
|
||||
$o->setThumbnail();
|
||||
|
||||
// If this is a duplicate
|
||||
$x = $class::whereIN('id',$o->list_duplicate())->get();
|
||||
if (count($x)) {
|
||||
$break = FALSE;
|
||||
// If this is a duplicate
|
||||
$x = $class::whereIN('id',$o->list_duplicate())->get();
|
||||
if (count($x)) {
|
||||
foreach ($x as $oo) {
|
||||
// And that photo is not marked as a duplicate
|
||||
if (! $oo->duplicate) {
|
||||
$o->duplicate = '1';
|
||||
$this->warn(sprintf('Image [%s] marked as a duplicate',$o->file_path()));
|
||||
|
||||
foreach ($x as $oo) {
|
||||
// And that photo is not marked as a duplicate
|
||||
if (! $oo->duplicate)
|
||||
{
|
||||
$o->duplicate = '1';
|
||||
$this->warn(sprintf('Image [%s] marked as a duplicate',$o->file_path()));
|
||||
// If the file signature also matches, we'll mark it for deletion
|
||||
if ($oo->file_signature AND $o->file_signature == $oo->file_signature) {
|
||||
$this->warn(sprintf('Image [%s] marked for deletion',$o->file_path()));
|
||||
$o->remove = '1';
|
||||
}
|
||||
|
||||
// If the file signature also matches, we'll mark it for deletion
|
||||
if ($oo->file_signature AND $o->file_signature == $oo->file_signature)
|
||||
{
|
||||
$this->warn(sprintf('Image [%s] marked for deletion',$o->file_path()));
|
||||
$o->remove = '1';
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$o->scanned = '1';
|
||||
$o->scanned = '1';
|
||||
|
||||
if ($o->getDirty())
|
||||
$this->warn(sprintf('Image [%s] metadata changed',$o->file_path()));
|
||||
if ($o->getDirty())
|
||||
$this->warn(sprintf('Image [%s] metadata changed',$o->file_path()));
|
||||
|
||||
$o->save();
|
||||
$o->save();
|
||||
}
|
||||
}
|
||||
|
@ -2,19 +2,17 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Log;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use App\Model\Person;
|
||||
use App\Model\PhotoPerson;
|
||||
use App\Model\Photo;
|
||||
use App\Model\PhotoTag;
|
||||
use App\Model\Tag;
|
||||
|
||||
use App\Models\{Person,Photo,Tag};
|
||||
use App\Traits\Files;
|
||||
|
||||
class PhotoImport extends Command
|
||||
{
|
||||
use DispatchesJobs;
|
||||
use \App\Traits\Files;
|
||||
use Files;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
@ -53,7 +51,11 @@ class PhotoImport extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$files = $this->getFiles(['dir'=>$this->option('dir'),'file'=>$this->option('file')],'photo');
|
||||
$files = $this->getFiles([
|
||||
'dir'=>$this->option('dir'),
|
||||
'file'=>$this->option('file')
|
||||
],'photo');
|
||||
|
||||
if (! count($files))
|
||||
exit;
|
||||
|
||||
@ -65,22 +67,21 @@ class PhotoImport extends Command
|
||||
$t = $p = array();
|
||||
|
||||
// Tags
|
||||
if ($this->option('tags'))
|
||||
{
|
||||
if ($this->option('tags')) {
|
||||
$tags = explode(',',$this->option('tags'));
|
||||
$t = Tag::whereIn('tag',$tags)->pluck('id')->toArray();
|
||||
if (! $t OR count($t) != count($tags))
|
||||
{
|
||||
|
||||
if (! $t OR count($t) != count($tags)) {
|
||||
$this->error(sprintf('Tag [%s] dont exist',join('|',$tags)));
|
||||
abort(501);
|
||||
}
|
||||
}
|
||||
|
||||
// People
|
||||
if ($this->option('people'))
|
||||
{
|
||||
if ($this->option('people')) {
|
||||
$tags = explode(',',$this->option('people'));
|
||||
$p = Person::whereIn('tag',$tags)->pluck('id')->toArray();
|
||||
|
||||
if (! $p OR count($p) != count($tags))
|
||||
{
|
||||
$this->error(sprintf('People [%s] dont exist',join('|',$tags)));
|
||||
@ -89,18 +90,15 @@ class PhotoImport extends Command
|
||||
}
|
||||
|
||||
$c = 0;
|
||||
foreach ($files as $file)
|
||||
{
|
||||
foreach ($files as $file) {
|
||||
$bar->advance();
|
||||
|
||||
if (preg_match('/@__thumb/',$file) OR preg_match('/\/._/',$file))
|
||||
{
|
||||
if (preg_match('/@__thumb/',$file) OR preg_match('/\/._/',$file)) {
|
||||
$this->warn(sprintf('Ignoring file [%s]',$file));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! in_array(strtolower(pathinfo($file,PATHINFO_EXTENSION)),config('photo.import.accepted')))
|
||||
{
|
||||
if (! in_array(strtolower(pathinfo($file,PATHINFO_EXTENSION)),config('photo.import.accepted'))) {
|
||||
$this->warn(sprintf('Ignoring [%s]',$file));
|
||||
continue;
|
||||
}
|
||||
@ -112,21 +110,21 @@ class PhotoImport extends Command
|
||||
|
||||
$o = Photo::where('filename',$file)->first();
|
||||
|
||||
if (is_null($o))
|
||||
{
|
||||
// The photo doesnt exist
|
||||
if (is_null($o)) {
|
||||
$o = new Photo;
|
||||
$o->filename = $file;
|
||||
}
|
||||
|
||||
if (! is_readable($o->file_path()))
|
||||
{
|
||||
if ($o->exists)
|
||||
$this->warn(sprintf('%s [%s] already in DB: %s',$o->objectType(),$file,$o->id));
|
||||
|
||||
// Make sure we can read the photo.
|
||||
if (! is_readable($o->file_path())) {
|
||||
$this->warn(sprintf('Ignoring [%s], it is not readable',$o->file_path()));
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($o->exists)
|
||||
$this->warn(sprintf('%s [%s] already in DB: %s',$o->objectType(),$file,$o->id));
|
||||
|
||||
$o->save();
|
||||
|
||||
if ($o->wasRecentlyCreated)
|
||||
|
@ -2,14 +2,15 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use DB;
|
||||
use Log;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Model\Photo;
|
||||
|
||||
use App\Traits\Files;
|
||||
use App\Models\Photo;
|
||||
|
||||
class PhotoMove extends Command
|
||||
{
|
||||
use \App\Traits\Files;
|
||||
use Files;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
@ -44,61 +45,54 @@ class PhotoMove extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if ($this->option('file'))
|
||||
{
|
||||
$po = Photo::notRemove()->notDuplicate()->where('filename',Photo::path($this->option('file')));
|
||||
}
|
||||
elseif ($this->option('id'))
|
||||
{
|
||||
$po = Photo::notRemove()->notDuplicate()->where('id',$this->option('id'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$po = Photo::notRemove()->notDuplicate();
|
||||
}
|
||||
if ($this->option('file')) {
|
||||
$po = Photo::notRemove()->notDuplicate()->where('filename',Photo::path($this->option('file')));
|
||||
|
||||
if (! $po)
|
||||
exit;
|
||||
} elseif ($this->option('id')) {
|
||||
$po = Photo::notRemove()->notDuplicate()->where('id',$this->option('id'));
|
||||
|
||||
// Show a progress bar
|
||||
$bar = $this->output->createProgressBar($po->count());
|
||||
$bar->setFormat("%current%/%max% [%bar%] %percent:3s%% (%memory%) (%remaining%) ");
|
||||
$bar->setRedrawFrequency(100);
|
||||
|
||||
$po->chunk(1,function($photo) use ($bar) {
|
||||
while ($o = $photo->shift())
|
||||
{
|
||||
if (($x = $o->moveable()) === TRUE) {
|
||||
Log::info(sprintf('%s: Moving (%s)[%s]',__METHOD__,$o->id,$o->filename));
|
||||
|
||||
if ($this->makeParentDir(dirname($o->file_path(FALSE,TRUE))) AND rename($o->file_path(),$o->file_path(FALSE,TRUE)))
|
||||
{
|
||||
// Convert the path to a relative one.
|
||||
$o->filename = $o->file_path(TRUE,TRUE);
|
||||
|
||||
// @todo If the DB update failed, move it back.
|
||||
if (! $o->save()) # AND ! rename($path,$o->file_path()))
|
||||
{
|
||||
$this->error(sprintf('Save after rename failed for (%s)',$o->id));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error(sprintf('Rename failed for (%s)',$o->id));
|
||||
continue;
|
||||
}
|
||||
|
||||
chmod($o->file_path(),0444);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($x > 0)
|
||||
$this->warn(sprintf('Unable to move (%s) [%s] to [%s], moveable returned (%s)',$o->id,$o->file_path(),$o->file_path(FALSE,TRUE),$x));
|
||||
}
|
||||
} else {
|
||||
$po = Photo::notRemove()->notDuplicate();
|
||||
}
|
||||
|
||||
$bar->advance();
|
||||
});
|
||||
if (! $po)
|
||||
exit;
|
||||
|
||||
// Show a progress bar
|
||||
$bar = $this->output->createProgressBar($po->count());
|
||||
$bar->setFormat("%current%/%max% [%bar%] %percent:3s%% (%memory%) (%remaining%) ");
|
||||
$bar->setRedrawFrequency(100);
|
||||
|
||||
$po->chunk(1,function($photo) use ($bar) {
|
||||
while ($o = $photo->shift()) {
|
||||
if (($x = $o->moveable()) === TRUE) {
|
||||
Log::info(sprintf('%s: Moving (%s)[%s]',__METHOD__,$o->id,$o->filename));
|
||||
|
||||
if ($this->makeParentDir(dirname($o->file_path(FALSE,TRUE))) AND rename($o->file_path(),$o->file_path(FALSE,TRUE))) {
|
||||
// Convert the path to a relative one.
|
||||
$o->filename = $o->file_path(TRUE,TRUE);
|
||||
|
||||
// @todo If the DB update failed, move it back.
|
||||
if (! $o->save()) # AND ! rename($path,$o->file_path()))
|
||||
{
|
||||
$this->error(sprintf('Save after rename failed for (%s)',$o->id));
|
||||
continue;
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->error(sprintf('Rename failed for (%s)',$o->id));
|
||||
continue;
|
||||
}
|
||||
|
||||
chmod($o->file_path(),0444);
|
||||
|
||||
} else {
|
||||
if ($x > 0)
|
||||
$this->warn(sprintf('Unable to move (%s) [%s] to [%s], moveable returned (%s)',$o->id,$o->file_path(),$o->file_path(FALSE,TRUE),$x));
|
||||
}
|
||||
}
|
||||
|
||||
$bar->advance();
|
||||
});
|
||||
}
|
||||
}
|
@ -2,11 +2,9 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Model\Photo;
|
||||
use App\Models\Photo;
|
||||
use App\Jobs\PhotoDelete;
|
||||
|
||||
class PhotoController extends Controller
|
||||
@ -23,86 +21,89 @@ class PhotoController extends Controller
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
$po = Photo::notRemove()->findOrFail($id);
|
||||
$po = Photo::notRemove()->findOrFail($id);
|
||||
|
||||
if ($po)
|
||||
{
|
||||
$po->remove = TRUE;
|
||||
$po->save();
|
||||
}
|
||||
if ($po)
|
||||
{
|
||||
$po->remove = TRUE;
|
||||
$po->save();
|
||||
}
|
||||
|
||||
return redirect()->action('PhotoController@info',[$id]);
|
||||
return redirect()->action('PhotoController@info',[$id]);
|
||||
}
|
||||
|
||||
public function deletes($id=NULL)
|
||||
{
|
||||
return view('catalog.deletereview',['return'=>url('/p/deletes'),'catalog'=>is_null($id) ? Photo::where('remove',1)->paginate(50) : Photo::where('id',$id)->paginate(1)]);
|
||||
return view('catalog.deletereview',['return'=>url('/p/deletes'),'catalog'=>is_null($id) ? Photo::where('remove',1)->paginate(50) : Photo::where('id',$id)->paginate(1)]);
|
||||
}
|
||||
|
||||
public function deletesUpdate(Request $request)
|
||||
{
|
||||
foreach ($request->input('remove') as $id=>$k)
|
||||
{
|
||||
$o = Photo::findOrFail($id);
|
||||
foreach ($request->input('remove') as $id=>$k)
|
||||
{
|
||||
$o = Photo::findOrFail($id);
|
||||
|
||||
if ($o->remove AND $request->input('remove.'.$id))
|
||||
$this->dispatch((new PhotoDelete($o))->onQueue('delete'));
|
||||
}
|
||||
if ($o->remove AND $request->input('remove.'.$id))
|
||||
$this->dispatch((new PhotoDelete($o))->onQueue('delete'));
|
||||
}
|
||||
|
||||
return redirect()->action('PhotoController@deletes',$request->input('pagenext') ? '?page='.$request->input('pagenext') : NULL);
|
||||
return redirect()->action('PhotoController@deletes',$request->input('pagenext') ? '?page='.$request->input('pagenext') : NULL);
|
||||
}
|
||||
|
||||
public function duplicates($id=NULL)
|
||||
{
|
||||
return view('catalog.duplicatereview',['return'=>url('/p/duplicates'),'catalog'=>is_null($id) ? Photo::notRemove()->where('duplicate',1)->paginate(50) : Photo::where('id',$id)->paginate(1)]);
|
||||
return view('catalog.duplicatereview',[
|
||||
'return'=>url('/p/duplicates'),
|
||||
'catalog'=>is_null($id) ? Photo::notRemove()->where('duplicate',1)->paginate(50) : Photo::where('id',$id)->paginate(1)
|
||||
]);
|
||||
}
|
||||
|
||||
public function duplicatesUpdate(Request $request)
|
||||
{
|
||||
foreach ($request->input('items') as $id)
|
||||
{
|
||||
$po = Photo::findOrFail($id);
|
||||
foreach ($request->input('items') as $id)
|
||||
{
|
||||
$po = Photo::findOrFail($id);
|
||||
|
||||
// Set if duplicate
|
||||
$po->duplicate = $request->input('duplicate.'.$id) ? 1 : NULL;
|
||||
// Set if duplicate
|
||||
$po->duplicate = $request->input('duplicate.'.$id) ? 1 : NULL;
|
||||
|
||||
// Set if flag
|
||||
$po->flag = $request->input('flag.'.$id) ? 1 : NULL;
|
||||
// Set if flag
|
||||
$po->flag = $request->input('flag.'.$id) ? 1 : NULL;
|
||||
|
||||
// Set if delete
|
||||
$po->remove = $request->input('remove.'.$id) ? 1 : NULL;
|
||||
// Set if delete
|
||||
$po->remove = $request->input('remove.'.$id) ? 1 : NULL;
|
||||
|
||||
$po->isDirty() AND $po->save();
|
||||
}
|
||||
$po->isDirty() AND $po->save();
|
||||
}
|
||||
|
||||
return redirect()->action('PhotoController@duplicates','?page='.$request->input('page'));
|
||||
return redirect()->action('PhotoController@duplicates','?page='.$request->input('page'));
|
||||
}
|
||||
|
||||
public function info($id)
|
||||
{
|
||||
return view('photo.view', ['photo'=> Photo::findOrFail($id)]);
|
||||
return view('photo.view', ['photo'=> Photo::findOrFail($id)]);
|
||||
}
|
||||
|
||||
public function thumbnail($id)
|
||||
{
|
||||
return response(Photo::findOrFail($id)->thumbnail(TRUE))->header('Content-Type','image/jpeg');
|
||||
return response(Photo::findOrFail($id)->thumbnail(TRUE))->header('Content-Type','image/jpeg');
|
||||
}
|
||||
|
||||
public function undelete($id)
|
||||
{
|
||||
$po = Photo::findOrFail($id);
|
||||
$po = Photo::findOrFail($id);
|
||||
|
||||
if ($po)
|
||||
{
|
||||
$po->remove = NULL;
|
||||
$po->save();
|
||||
}
|
||||
if ($po)
|
||||
{
|
||||
$po->remove = NULL;
|
||||
$po->save();
|
||||
}
|
||||
|
||||
return redirect()->action('PhotoController@info',[$id]);
|
||||
return redirect()->action('PhotoController@info',[$id]);
|
||||
}
|
||||
|
||||
public function view($id)
|
||||
{
|
||||
return response(Photo::findOrFail($id)->image())->header('Content-Type','image/jpeg');
|
||||
return response(Photo::findOrFail($id)->image())->header('Content-Type','image/jpeg');
|
||||
}
|
||||
}
|
@ -2,12 +2,13 @@
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Log;
|
||||
use App\Jobs\Job;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Artisan;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
use App\Models\Abstracted\Catalog;
|
||||
|
||||
class CatalogScan extends Job implements ShouldQueue
|
||||
{
|
||||
@ -21,8 +22,7 @@ class CatalogScan extends Job implements ShouldQueue
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(\App\Model\Abstracted\Catalog $o)
|
||||
{
|
||||
public function __construct(Catalog $o) {
|
||||
$this->o = $o;
|
||||
}
|
||||
|
||||
@ -34,6 +34,7 @@ class CatalogScan extends Job implements ShouldQueue
|
||||
public function handle()
|
||||
{
|
||||
Log::info(sprintf('%s: Scanning [%s|%s]',__METHOD__,$this->o->objecttype(),$this->o->id));
|
||||
|
||||
Artisan::call('catalog:scan',['type'=>$this->o->objecttype(),'id'=>$this->o->id]);
|
||||
}
|
||||
}
|
@ -2,16 +2,16 @@
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Log;
|
||||
use App\Jobs\Job;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use App\Model\Photo;
|
||||
|
||||
use App\Models\Photo;
|
||||
|
||||
class PhotoDelete extends Job implements ShouldQueue
|
||||
{
|
||||
use InteractsWithQueue, SerializesModels;
|
||||
use InteractsWithQueue,SerializesModels;
|
||||
|
||||
private $photo;
|
||||
|
||||
|
@ -2,17 +2,17 @@
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Log;
|
||||
use App\Jobs\Job;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use App\Model\Photo;
|
||||
use Artisan;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
use App\Models\Photo;
|
||||
|
||||
class PhotoMove extends Job implements ShouldQueue
|
||||
{
|
||||
use InteractsWithQueue, SerializesModels;
|
||||
use InteractsWithQueue,SerializesModels;
|
||||
|
||||
private $photo;
|
||||
|
||||
|
@ -2,16 +2,16 @@
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Log;
|
||||
use App\Jobs\Job;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use App\Model\Video;
|
||||
|
||||
use App\Models\Video;
|
||||
|
||||
class VideoDelete extends Job implements ShouldQueue
|
||||
{
|
||||
use InteractsWithQueue, SerializesModels;
|
||||
use InteractsWithQueue,SerializesModels;
|
||||
|
||||
private $video;
|
||||
|
||||
|
@ -2,17 +2,17 @@
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Log;
|
||||
use App\Jobs\Job;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use App\Model\Video;
|
||||
use Artisan;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
use App\Models\Video;
|
||||
|
||||
class VideoMove extends Job implements ShouldQueue
|
||||
{
|
||||
use InteractsWithQueue, SerializesModels;
|
||||
use InteractsWithQueue,SerializesModels;
|
||||
|
||||
private $video;
|
||||
|
||||
|
@ -62,13 +62,13 @@ abstract class Catalog extends Model
|
||||
});
|
||||
}
|
||||
|
||||
abstract public function setDateCreated();
|
||||
abstract public function setLocation();
|
||||
abstract public function setMakeModel();
|
||||
abstract public function setSignature();
|
||||
abstract public function setSubSecTime();
|
||||
abstract public function setThumbnail();
|
||||
abstract public function view();
|
||||
abstract public function setDateCreated();
|
||||
abstract public function setLocation();
|
||||
abstract public function setMakeModel();
|
||||
abstract public function setSignature();
|
||||
abstract public function setSubSecTime();
|
||||
abstract public function setThumbnail();
|
||||
abstract public function view();
|
||||
|
||||
/**
|
||||
* Date the multimedia was created
|
||||
@ -282,7 +282,7 @@ abstract class Catalog extends Model
|
||||
{
|
||||
return DB::table($this->getTable())
|
||||
->where('id','<',$this->id)
|
||||
->orderby('id','DEC')
|
||||
->orderby('id','DESC')
|
||||
->first();
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
|
||||
@ -29,22 +30,22 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
// Any photo saved, queue it to be moved.
|
||||
Photo::saved(function($photo) {
|
||||
if ($photo->scanned AND ! $photo->duplicate AND ! $photo->remove AND ($x=$photo->moveable()) === TRUE)
|
||||
{
|
||||
Log::info(sprintf('%s: Need to Move [%s]',__METHOD__,$photo->id.'|'.serialize($x)));
|
||||
$this->dispatch((new PhotoMove($photo))->onQueue('move'));
|
||||
}
|
||||
});
|
||||
// Any photo saved, queue it to be moved.
|
||||
Photo::saved(function($photo) {
|
||||
if ($photo->scanned AND ! $photo->duplicate AND ! $photo->remove AND ($x=$photo->moveable()) === TRUE) {
|
||||
Log::info(sprintf('%s: Need to Move [%s]',__METHOD__,$photo->id.'|'.serialize($x)));
|
||||
|
||||
// Any video saved, queue it to be moved.
|
||||
Video::saved(function($video) {
|
||||
if ($video->scanned AND ! $video->duplicate AND ! $video->remove AND ($x=$video->moveable()) === TRUE)
|
||||
{
|
||||
Log::info(sprintf('%s: Need to Move [%s]',__METHOD__,$video->id.'|'.serialize($x)));
|
||||
$this->dispatch((new VideoMove($video))->onQueue('move'));
|
||||
}
|
||||
});
|
||||
$this->dispatch((new PhotoMove($photo))->onQueue('move'));
|
||||
}
|
||||
});
|
||||
|
||||
// Any video saved, queue it to be moved.
|
||||
Video::saved(function($video) {
|
||||
if ($video->scanned AND ! $video->duplicate AND ! $video->remove AND ($x=$video->moveable()) === TRUE) {
|
||||
Log::info(sprintf('%s: Need to Move [%s]',__METHOD__,$video->id.'|'.serialize($x)));
|
||||
|
||||
$this->dispatch((new VideoMove($video))->onQueue('move'));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -2,15 +2,15 @@
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use Log;
|
||||
use App\Model\Photo;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
trait Files
|
||||
{
|
||||
/**
|
||||
* Get a list of files
|
||||
*/
|
||||
public function getFiles(array $option,$type)
|
||||
public function getFiles(array $option,string $type): Collection
|
||||
{
|
||||
// Make sure we got a directory or a file to import
|
||||
if (is_null($option['file']) AND is_null($option['dir']))
|
||||
@ -18,38 +18,42 @@ trait Files
|
||||
|
||||
Log::info(sprintf('%s: Processing: %s',__METHOD__,($option['file'] ? $option['file'] : $option['dir'])));
|
||||
|
||||
$files = [];
|
||||
$files = collect();
|
||||
$dir = '';
|
||||
|
||||
if ($option['dir'])
|
||||
{
|
||||
if ($option['dir'] AND is_dir($option['dir'])) {
|
||||
// Remove our trailing slash from the directory.
|
||||
$dir = preg_replace('/\/$/','',$option['dir']);
|
||||
|
||||
// Exclude . & .. from the path.
|
||||
$files = array_diff(scandir($dir),array('.','..'));
|
||||
$files = $files->merge(array_diff(scandir($dir),array('.','..')));
|
||||
|
||||
}
|
||||
elseif ($option['file'] AND file_exists($option['file']))
|
||||
{
|
||||
} elseif ($option['file'] AND ! is_dir($option['file']) AND file_exists($option['file'])) {
|
||||
$dir = dirname($option['file']);
|
||||
$files = array(basename($option['file']));
|
||||
|
||||
$files->push(basename($option['file']));
|
||||
}
|
||||
|
||||
// Determine if our dir is releative to where we store data
|
||||
// Determine if our dir is relative to where we store data
|
||||
$dir = static::path($dir,$type);
|
||||
|
||||
// Add our path
|
||||
if ($dir)
|
||||
array_walk($files,function(&$value,$key,$path='') {
|
||||
if ($path) {
|
||||
$value = sprintf('%s/%s',$path,$value);
|
||||
}
|
||||
},$dir);
|
||||
$files->transform(function($value) use ($dir) {
|
||||
return sprintf('%s/%s',$dir,$value);
|
||||
});
|
||||
|
||||
Log::info(sprintf('%s: Processing: %s (%s)',__METHOD__,($option['file'] ? $option['file'] : $option['dir']),count($files)));
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively make a parent dir to hold files.
|
||||
*
|
||||
* @param $dir
|
||||
* @return bool
|
||||
*/
|
||||
public function makeParentDir($dir)
|
||||
{
|
||||
if (is_dir($dir))
|
||||
@ -61,7 +65,14 @@ trait Files
|
||||
return is_writable(dirname($dir)) AND mkdir($dir);
|
||||
}
|
||||
|
||||
public static function path($path,$type)
|
||||
/**
|
||||
* Return if the dir is a sub dir of our config.
|
||||
*
|
||||
* @param $path
|
||||
* @param $type
|
||||
* @return string
|
||||
*/
|
||||
public static function path($path,$type): string
|
||||
{
|
||||
return (strpos($path,config($type.'.dir').'/') === 0) ? str_replace(config($type.'.dir').'/','',$path) : $path;
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateUsersTable extends Migration
|
||||
{
|
||||
@ -13,9 +14,10 @@ class CreateUsersTable extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->bigIncrements('id');
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
@ -29,6 +31,6 @@ class CreateUsersTable extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('users');
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreatePasswordResetsTable extends Migration
|
||||
{
|
||||
@ -14,8 +15,8 @@ class CreatePasswordResetsTable extends Migration
|
||||
{
|
||||
Schema::create('password_resets', function (Blueprint $table) {
|
||||
$table->string('email')->index();
|
||||
$table->string('token')->index();
|
||||
$table->timestamp('created_at');
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
@ -26,6 +27,6 @@ class CreatePasswordResetsTable extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('password_resets');
|
||||
Schema::dropIfExists('password_resets');
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
@extends('layouts.app')
|
||||
@extends('adminlte::layouts.app')
|
||||
|
||||
<?php $data = [
|
||||
'ID'=>['id','idlink'],
|
||||
@ -13,7 +13,7 @@
|
||||
'Delete'=>['remove','removecheckbox'],
|
||||
];?>
|
||||
|
||||
@section('content')
|
||||
@section('main-content')
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-11 col-md-offset-1">
|
||||
|
@ -1,6 +1,6 @@
|
||||
@extends('layouts.app')
|
||||
@extends('adminlte::layouts.app')
|
||||
|
||||
@section('content')
|
||||
@section('main-content')
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-10 col-md-offset-1">
|
||||
|
1
resources/views/vendor/.gitkeep
vendored
1
resources/views/vendor/.gitkeep
vendored
@ -1 +0,0 @@
|
||||
|
@ -11,6 +11,25 @@
|
||||
|
|
||||
*/
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('welcome');
|
||||
});
|
||||
#Route::get('/', function () {
|
||||
# return view('welcome');
|
||||
#});
|
||||
|
||||
Route::get('/p/deletes/{id?}','PhotoController@deletes')->where('id','[0-9]+');
|
||||
Route::get('/v/deletes/{id?}','VideoController@deletes')->where('id','[0-9]+');
|
||||
Route::get('/p/duplicates/{id?}','PhotoController@duplicates')->where('id','[0-9]+');
|
||||
Route::get('/v/duplicates/{id?}','VideoController@duplicates')->where('id','[0-9]+');
|
||||
Route::get('/p/info/{id}','PhotoController@info')->where('id','[0-9]+');
|
||||
Route::get('/v/info/{id}','VideoController@info')->where('id','[0-9]+');
|
||||
Route::get('/p/thumbnail/{id}','PhotoController@thumbnail')->where('id','[0-9]+');
|
||||
Route::get('/p/view/{id}','PhotoController@view')->where('id','[0-9]+');
|
||||
Route::get('/v/view/{id}','VideoController@view')->where('id','[0-9]+');
|
||||
|
||||
Route::post('/p/delete/{id}','PhotoController@delete')->where('id','[0-9]+');
|
||||
Route::post('/v/delete/{id}','VideoController@delete')->where('id','[0-9]+');
|
||||
Route::post('/p/duplicates','PhotoController@duplicatesUpdate');
|
||||
Route::post('/v/duplicates','VideoController@duplicatesUpdate');
|
||||
Route::post('/p/deletes','PhotoController@deletesUpdate');
|
||||
Route::post('/v/deletes','VideoController@deletesUpdate');
|
||||
Route::post('/p/undelete/{id}','PhotoController@undelete')->where('id','[0-9]+');
|
||||
Route::post('/v/undelete/{id}','VideoController@undelete')->where('id','[0-9]+');
|
Loading…
Reference in New Issue
Block a user