-
app/Notifications/ContactForm.php
Open in GitHubuse Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; class ContactForm extends Notification implements ShouldQueue { use Queueable; protected $sender; public function __construct($sender) { $this->sender = $sender; } public function via($notifiable) { return ['mail']; } public function toMail($notifiable) { return (new MailMessage)->subject('New message received from contact form')->view('emails.notif', [ 'subject' => 'New Message Received', 'body_message' => 'You received a new message from the contact form of your PteroBilling store.', 'body_action' => 'Please click the button below to read the message in the admin area.', 'button_text' => 'View Message', 'button_url' => url()->route('admin.page.contact', ['id' => 'contact', 'msg_id' => $this->sender->id]), 'notice' => 'You may change the email address that receives this kind of emails in the admin area.', ]); } // }
-
app/Http/Controllers/Store/ContactController.php
Open in GitHubuse App\Http\Controllers\Controller; class ContactController extends Controller { // public function store(Request $request) { // $sender = Contact::create([ 'email' => $request->input('email'), 'name' => $request->input('name'), 'subject' => $request->input('subject'), 'message' => $request->input('message'), ]); Notification::route('mail', $receiver)->notify(new ContactForm($sender)); return back()->with('success_msg', 'Your message has been sent!'); } }