Skip to content

Instantly share code, notes, and snippets.

@whitneyburton
Created January 17, 2020 23:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whitneyburton/41782a084fef145d630834592b674da8 to your computer and use it in GitHub Desktop.
Save whitneyburton/41782a084fef145d630834592b674da8 to your computer and use it in GitHub Desktop.
// app/Http/Controllers/HooksController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
use App\Mail\SendMailable;
class HooksController extends Controller
{
public function sendmails(Request $request)
{
$payload = $request->all();
if($payload['type'] == "message.new"){
foreach ($payload["members"] as $member) {
if($member\["user"\]["online"] == false){
$email = $member\["user"\]["id"]."@gmail.com";
Mail::to($email)->send(new SendMailable($member\["user"\]["name"]));
return 'Email was sent';
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment