1. Go to this page and download the library: Download elfsundae/laravel-bearychat 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/ */
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use ElfSundae\BearyChat\Message;
class SendBearyChat implements ShouldQueue
{
use InteractsWithQueue, Queueable, SerializesModels;
/**
* The BearyChat client.
*
* @var \ElfSundae\BearyChat\Client
*/
protected $client;
/**
* The Message instance to be sent.
*
* @var \ElfSundae\BearyChat\Message
*/
protected $message;
/**
* Create a new job instance.
*
* @param mixed $message A Message instance, or parameters which can be handled
* by the `send` method of a Message instance.
*/
public function __construct($message = null)
{
if ($message instanceof Message) {
$this->message = $message;
} elseif (is_string($message)) {
$this->text($message);
if (func_num_args() > 1) {
if (is_bool($markdown = func_get_arg(1))) {
$this->markdown(func_get_arg(1));
if (func_num_args() > 2) {
$this->notification(func_get_arg(2));
}
} else {
call_user_func_array([$this, 'add'], array_slice(func_get_args(), 1));
}
}
}
}
/**
* Any unhandled methods will be sent to the Message instance.
*
* @param string $method
* @param array $parameters
* @return $this
*/
public function __call($method, $parameters)
{
$message = $this->message ?: new Message($this->client ?: bearychat());
$this->message = call_user_func_array([$message, $method], $parameters);
return $this;
}
/**
* Set the client with client name.
*
* @param string $name
* @return $this
*/
public function client($name)
{
$this->client = bearychat($name);
return $this;
}
/**
* Execute the job.
*/
public function handle()
{
if ($this->client) {
$this->client->sendMessage($this->message);
} else {
$this->message->send();
}
}
}
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void
*/
public function report(Exception $e)
{
parent::report($e);
if (app()->environment('production') && $this->shouldReport($e)) {
dispatch(
(new SendBearyChat)
->client('server')
->text('New Exception!')
->notification('New Exception: '.get_class($e))
->markdown(false)
->add(str_limit($e, 1300), get_class($e), null, '#a0a0a0')
);
}
}