/home/kueuepay/public_html/app/Http/Controllers/Admin/SubscriberController.php
<?php

namespace App\Http\Controllers\Admin;

use Exception;
use Illuminate\Http\Request;
use App\Models\Frontend\Subscribe;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Notification;
use App\Notifications\websiteSubscribeNotification;

class SubscriberController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $page_title = "Website Subscribers";
        $subscribers = Subscribe::orderByDesc("id")->paginate(15);
        return view('admin.sections.subscriber.index',compact('page_title','subscribers'));
    }

    public function sendMail(Request $request) {
        $validator = Validator::make($request->all(),[
            'subject'       => "required|string|max:255",
            'message'       => "required|string|max:5000",
        ]);
        if($validator->fails()) return back()->withErrors($validator)->withInput()->with('modal','send-mail-subscribers');
        $validated = $validator->validate();

        try{
            $subscribers = Subscribe::get()->pluck("email")->toArray();
            Notification::route("mail",$subscribers)->notify(new websiteSubscribeNotification($validated));
        }catch(Exception $e) {
            return back()->with(['error' => ['Mail send failed! Please try again']]);
        }
        return back()->with(['success' => ['Mail successfully sended']]);
    }
}
Web Journal
top

Discover the Latest in Digital Payments and NFC Technology

Dive into our blog to explore the cutting-edge trends in digital payments and NFC technology. Stay updated on the innovations that are revolutionizing transactions, boosting security, and making payments quicker and more convenient. Learn how these advancements are shaping the future of financial interactions and driving the global transition towards a cashless world.

The Rise of Contactless Payments:...

In recent years, contactless payments have surged in popularity, driven...

Enhancing Payment Security: The Role...

As digital transactions proliferate, ensuring robust payment security is more critical than ever. Two foundational...

The Future of Digital Wallets:...

Digital wallets have fundamentally transformed how we manage money, offering a streamlined, secure, and highly...