photo/app/Providers/AppServiceProvider.php
2016-06-29 14:04:02 +10:00

42 lines
810 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(__METHOD__.': Need to Move: '.$photo->id.'|'.serialize($x));
$this->dispatch((new PhotoMove($photo))->onQueue('move'));
}
});
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}