<?php

namespace App\Notifications;

use Illuminate\Auth\Notifications\VerifyEmail as CoreVerifyEmail;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\URL;

class VerifyEmail extends CoreVerifyEmail
{
    protected $data;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct($data)
    {
        $this->data = $data;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['mail'];
    }

    /**
     * Get the verification URL for the given notifiable.
     *
     * @param mixed $notifiable
     * @return string
     */
    protected function verificationUrl($notifiable)
    {
        if (static::$createUrlCallback) {
            return call_user_func(static::$createUrlCallback, $notifiable);
        }
        $parameter =  [
            'id' => $this->data->id,
            'hash' => sha1($this->data->external_id),
        ];
       
        $expireTime = config('auth.verification.expire', 60);

        $shortKey = generateRandomUrlKey($parameter,$expireTime);
         
        return route('member.verification.verify',['key' => $shortKey]);
      
       
    }
}
