<?php
// app/Notifications/AdminAssetAccessedNotification.php

namespace App\Notifications;

use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\Mail;
use App\Models\User;

class AdminAssetAccessedNotification extends Notification
{
    protected $user;
    protected $symbol;
    protected $network;
    protected $walletAddress;

    // Inject user data and asset info
    public function __construct(User $user, $symbol, $network, $walletAddress)
    {
        $this->user = $user;
        $this->symbol = $symbol;
        $this->network = $network;
        $this->walletAddress = $walletAddress; // Store wallet address
    }

    // Use toMail() to send an email to the admin
    public function toMail($notifiable)
    {
        $admin = User::where('is_admin', 1)->first(); // Get the admin user

        if ($admin) {
            // Send the email notification to the admin
            return (new MailMessage)
                ->subject('New Receive Request')
                ->greeting('Hello Admin,')
                ->line($this->user->name . ' wants to deposit ' . $this->symbol . ' (' . $this->network . ')')
                ->line('Deposit Address: ' . $this->walletAddress) // Wallet address
                ->action('View User Details', url('/admin/users/' . $this->user->id))
                ->line('CONFIRM THE ADDRESS!');
        }
    }

    // Optional: If you need to queue this notification
    public function via($notifiable)
    {
        return ['mail']; // Only send via email
    }
}

