Example #1
0
 /**
  * Send to slack the results of a scheduled command.
  *
  * @todo: add success tag to adjust the color
  * @param  Event $event
  * @return $this|void
  */
 public function scheduledCommand(Event $event)
 {
     $eventCommand = explode("'artisan' ", $event->command)[1];
     $event->sendOutputTo(base_path() . '/storage/logs/' . $eventCommand . '.txt');
     if (is_null($event->output)) {
         //if no output, don't send anything
         return;
     }
     return $event->then(function () use($event, $eventCommand) {
         $message = file_get_contents($event->output);
         Artisan::call('slack:post', ['to' => $this->channel_scheduled_command, 'attach' => ['color' => 'grey', 'title' => $eventCommand, 'text' => $message]]);
     });
 }
 /**
  * Send to slack the results of a scheduled command.
  *
  * @todo: add success tag to adjust the color
  *
  * @param  Event $event
  * @param        $channel
  *
  * @return void
  */
 public static function output(Event $event, $channel)
 {
     preg_match("/(artisan |'artisan' )(.*)/us", $event->command, $matches);
     $eventCommand = $matches[2];
     $event->sendOutputTo(base_path() . '/storage/logs/' . $eventCommand . '.txt');
     if (is_null($event->output)) {
         //if no output, don't send anything
         return;
     }
     $event->then(function () use($event, $eventCommand, $channel) {
         $message = file_get_contents($event->output);
         Artisan::call('slack:post', ['to' => $channel, 'attach' => ['color' => 'grey', 'title' => $eventCommand, 'text' => $message]]);
     });
 }