Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

theokafadaris/chatwire

158 stars
2 code files
View theokafadaris/chatwire on GitHub

app/Jobs/SendEmailJob.php

Open in GitHub
use App\Mail\SendChatToEmail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
 
class SendEmailJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
 
protected $details;
 
public function __construct($details)
{
$this->details = $details;
}
 
public function handle(): void
{
Log::info('Sending email to '.$this->details['email']);
$email = new SendChatToEmail($this->details);
Mail::to($this->details['email'])->send($email);
}
}

app/Http/Livewire/ChatBox.php

Open in GitHub
use Livewire\Component;
 
class ChatBox extends Component
{
// ...
public function sendChatToEmail()
{
if ($this->messages === []) {
$this->alert('error', 'You have not started a conversation yet!', [
'position' => 'top-end',
'timer' => 3000,
'toast' => true,
]);
} else {
$details = [
'email' => auth()->user()->email,
'messages' => $this->messages,
];
dispatch(new \App\Jobs\SendEmailJob($details));
$this->alert('success', 'Your email was sent successfully!', [
'position' => 'top-end',
'timer' => 3000,
'toast' => true,
]);
}
}
// ...
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.