public function handle(BaseCommand $command, $next)
 {
     if (!$command->shouldLog()) {
         return $next($command);
     }
     $this->commandLogger->storeCommand($command, Carbon::now()->timestamp, '0.0.1');
     return $next($command);
 }
 public function notRemember(BaseCommand $command)
 {
     if ($command->getAuthState()->rememberMe == true) {
         $bag = new MessageBag();
         $bag->add('authorisation', 'This action cannot be performed using a `remembered` session');
         throw new AuthorisationException($bag);
     }
 }
 public function handle(BaseCommand $command, $next)
 {
     if (!$command->shouldTransact()) {
         return $next($command);
     }
     Log::debug('Starting command transaction');
     return DB::transaction(function () use($command, $next) {
         return $next($command);
     });
 }
 public function handle(BaseCommand $command, $next)
 {
     if (!$command->shouldCache()) {
         return $next($command);
     }
     $parameters = serialize(get_object_vars($command));
     $parametersHash = md5($parameters);
     $cacheName = get_class($command) . '|' . $parametersHash;
     $cacheHash = md5($cacheName);
     //Return existing cache or create a new one
     return \Cache::tags($command->getCacheTags())->remember($cacheHash, $command->getCacheTime(), function () use($next, $command) {
         \Log::info('Caching result for query ' . get_class($command));
         return $next($command);
     });
 }
 public function dispatchCommand(BaseCommand $command)
 {
     $command->attachAuthState($this->getAuthState());
     return $this->dispatch($command);
 }