PHP code example of sonnn / laravel-slack-bot

1. Go to this page and download the library: Download sonnn/laravel-slack-bot library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sonnn / laravel-slack-bot example snippets


'providers' => [
  ...
  Sonnn\SlackOutput\ServiceProvider::class,
],

'aliases' => [
  ...
  'SlackOutput' => Sonnn\SlackOutput\Facade\SlackOutput::class,
],

Artisan::queue('slack:post', [
  'to' => "#api-output",
  'attach' => $someAttachment,
  'message' => "Hello, I'm a bot"
]);

'classes' => [
	  \App\Models\User::class => [
		  'is_active' => true //optional constraint
	  ]
],

'dates' => [
	'yesterday' => \Carbon\Carbon::yesterday(),
	'last week' => \Carbon\Carbon::today()->subWeek(1)
]

protected function schedule(Schedule $schedule)
{
  $schedule->command('slack:stats')->daily()
}

use Sonnn\SlackOutput\Facade\SlackOutput;

...

public function report(Exception $e)
{
  if ($this->shouldReport($e)) {
    SlackOutput::exception($e);
  }

  parent::report($e);
}

use Sonnn\SlackOutput\Facade\SlackOutput;

...

public function boot()
{
  Queue::failing(function (JobFailed $job) {
    SlackOutput::jobFailed($job);
  });
}

use Sonnn\SlackOutput\Facade\SlackOutput;

...

protected function schedule(Schedule $schedule)
{
  SlackOutput::scheduledCommand(
    $schedule->command('db:backup-auto')->daily()
  );
}
sh
php artisan vendor:publish --provider="Sonnn\SlackOutput\ServiceProvider"