
    // app/Http/Controllers/EmailController.php

<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
use App\Models\User;

class Store1 extends Admin_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->library('form_validation');
    }
    public function sendEmails()
    {
        // Retrieve users' email addresses from the database
        $users = User::pluck('email')->toArray();

        // Send emails to each user
        $subject = "Your Subject Here";
        $message = "Your email message goes here...";

        foreach ($users as $email) {
            Mail::raw($message, function($mail) use ($email, $subject) {
                $mail->to($email)
                    ->from('your_email@example.com') // Change this to your email address
                    ->subject($subject);
            });
        }

        return "Emails sent successfully";
    }

    public function showEmailForm()
    {
        return view('send_email_form');
    }
}
