2016-06-20 13:35:59 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
2016-06-29 04:04:02 +00:00
|
|
|
use Log;
|
2016-06-20 13:35:59 +00:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
2016-06-29 04:04:02 +00:00
|
|
|
use App\Model\Photo;
|
|
|
|
use App\Jobs\PhotoMove;
|
2016-07-04 06:00:33 +00:00
|
|
|
use App\Model\Video;
|
|
|
|
use App\Jobs\VideoMove;
|
2016-06-29 04:04:02 +00:00
|
|
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
2016-06-20 13:35:59 +00:00
|
|
|
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
{
|
2016-06-29 04:04:02 +00:00
|
|
|
use DispatchesJobs;
|
|
|
|
|
2016-06-20 13:35:59 +00:00
|
|
|
/**
|
|
|
|
* Bootstrap any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function boot()
|
|
|
|
{
|
2016-06-29 04:04:02 +00:00
|
|
|
// Any photo saved, queue it to be moved.
|
|
|
|
Photo::saved(function($photo) {
|
|
|
|
if (! $photo->duplicate AND ($x=$photo->moveable()) === TRUE)
|
|
|
|
{
|
2016-06-30 11:34:18 +00:00
|
|
|
Log::info(sprintf('%s: Need to Move [%s]',__METHOD__,$photo->id.'|'.serialize($x)));
|
2016-06-29 04:04:02 +00:00
|
|
|
$this->dispatch((new PhotoMove($photo))->onQueue('move'));
|
|
|
|
}
|
|
|
|
});
|
2016-07-04 06:00:33 +00:00
|
|
|
|
|
|
|
// 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'));
|
|
|
|
}
|
|
|
|
});
|
2016-06-20 13:35:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register any application services.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|