photo/app/Providers/AppServiceProvider.php

54 lines
1.3 KiB
PHP
Raw Normal View History

2016-06-20 13:35:59 +00:00
<?php
namespace App\Providers;
2019-11-09 02:52:04 +00:00
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Route;
2016-06-20 13:35:59 +00:00
use Illuminate\Support\ServiceProvider;
2019-11-08 12:08:34 +00:00
use Illuminate\Foundation\Bus\DispatchesJobs;
2019-11-08 12:51:47 +00:00
use App\Models\{Photo,Video};
use App\Jobs\{PhotoMove,VideoMove};
2016-06-20 13:35:59 +00:00
class AppServiceProvider extends ServiceProvider
{
2024-08-25 08:26:29 +00:00
use DispatchesJobs;
/**
* Register any application services.
*
* @return void
*/
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot(): void
{
Route::model('po',Photo::class);
2019-11-09 02:52:04 +00:00
// Any photo saved, queue it to be moved.
Photo::saved(function($photo) {
if ($photo->scanned && (! $photo->duplicate) && (! $photo->remove) && ($x=$photo->moveable()) === TRUE) {
2019-11-09 02:52:04 +00:00
Log::info(sprintf('%s: Need to Move [%s]',__METHOD__,$photo->id.'|'.serialize($x)));
PhotoMove::dispatch($photo)->onQueue('move');
2019-11-09 02:52:04 +00:00
}
});
// 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'));
}
});
2024-08-25 08:26:29 +00:00
}
2019-11-09 02:52:04 +00:00
}