This repository has been archived on 2024-05-20. You can view files and clone it, but cannot push or open issues or pull requests.

41 lines
816 B
PHP

<?php
namespace App\Helpers;
use App\Models\Quote;
use Illuminate\Http\Client\Response;
use Illuminate\Support\Facades\Http;
class Slack
{
private string $url;
public function __construct()
{
$this->url = config('bot.webhook');
}
private function send(string $text): Response
{
return Http::post($this->url, ['text' => $text]);
}
public function sendText(string $text): Response
{
activity()
->event('send')
->log("Manually sent quote: $text");
return $this->send($text);
}
public function sendQuote(Quote $quote): Response
{
activity()
->performedOn($quote)
->event('send')
->log("Requested quote: $quote");
return $this->send($quote->quote);
}
}