53 lines
1.2 KiB
PHP
53 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Log;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use App\Model\Photo;
|
|
use App\Jobs\PhotoMove;
|
|
use App\Model\Video;
|
|
use App\Jobs\VideoMove;
|
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
use DispatchesJobs;
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot()
|
|
{
|
|
// Any photo saved, queue it to be moved.
|
|
Photo::saved(function($photo) {
|
|
if (! $photo->duplicate 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 video saved, queue it to be moved.
|
|
Video::saved(function($video) {
|
|
if (! $video->duplicate 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'));
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Register any application services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function register()
|
|
{
|
|
//
|
|
}
|
|
}
|