photo/app/Providers/AppServiceProvider.php

51 lines
1.2 KiB
PHP
Raw Normal View History

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