photo/app/Providers/AppServiceProvider.php
2016-06-30 21:34:18 +10:00

42 lines
824 B
PHP

<?php
namespace App\Providers;
use Log;
use Illuminate\Support\ServiceProvider;
use App\Model\Photo;
use App\Jobs\PhotoMove;
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'));
}
});
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}