HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/Neopoints/momsecurity.be/app/Komma/Development/PreviewController.php
<?php


namespace App\Komma\Development;


use App\Http\Controllers\Controller;
use App\Komma\Users\Models\User;
use App\Notifications\CustomerRegistered;
use App\Notifications\CustomerRegisteredSetPassword;
use App\Notifications\KmsResetPasswordNotification;
use App\Notifications\SiteResetPasswordNotification;
use Illuminate\Mail\Markdown;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\View\View;

class PreviewController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Mail previews
    |--------------------------------------------------------------------------
    |
    | These functions must returns views that represent mails.
    |
    */
    /**
     * @see SiteResetPasswordNotification
     * @return \Illuminate\Support\HtmlString
     */
    public function resetPasswordMail()
    {
        $token = str_random(32);
        return $this->notificationToView(new SiteResetPasswordNotification($token));
    }

    /**
     * @see KmsResetPasswordNotification
     * @return \Illuminate\Support\HtmlString|View
     */
    public function resetPasswordMailKms()
    {
        $token = str_random(32);
        return $this->notificationToView(new SiteResetPasswordNotification($token));
    }

    /**
     * @see CustomerRegisteredSetPassword
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function setPasswordMail()
    {
        $customer = User::inRandomOrder()->first();
        $token = str_random(32);

        return $this->notificationToView(new CustomerRegisteredSetPassword($customer, $token));
    }

    /**
     * @see CustomerRegistered
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function registeredMail()
    {
        $customer = User::inRandomOrder()->first();
        return $this->notificationToView(new CustomerRegistered($customer));
    }

    /*
     |--------------------------------------------------------------------------
     | Authentication view previews
     |--------------------------------------------------------------------------
     |
     | These functions must return blade views that are related to authentication
     |
     */
    public function registerView()
    {
        return view('site.auth.register');
    }

    public function registeredView()
    {
        return view('site.auth.registered');
    }

    public function loginView()
    {
        return view('site.auth.login');
    }

    public function forgotPassword()
    {
        return view('site.auth.password.email');
    }

    public function set()
    {
        return view('site.auth.password.set', ['token' => str_random(32)]);
    }

    public function reset()
    {
        return view('site.auth.password.reset', ['token' => str_random(32)]);
    }

    public function loginViewKms()
    {
        return view('kms.auth.login');
    }

    public function forgotPasswordKms()
    {
        return view('kms.auth.password.email');
    }

    public function resetKms()
    {
        return view('kms.auth.password.reset', ['token' => str_random(32)]);
    }

    public function resetedKms()
    {
        return view('kms.auth.password.reseted');
    }

    /*
     |--------------------------------------------------------------------------
     | Helper methods
     |--------------------------------------------------------------------------
     |
     | These functions provide useful help for the ones that return views.
     */
    /**
     * Converts a notification to view
     *
     * @param Notification $notification
     * @return \Illuminate\Support\HtmlString|View
     */
    private function notificationToView(Notification $notification)
    {
        /** @var MailMessage $mail */
        $mail = $notification->toMail(\Auth::user());
        if($mail->markdown) {
            $markdown = new Markdown(view());
            return $markdown->render($mail->markdown, $mail->data());
        }
        elseif($mail->view)
        {
            return view($mail->view, $mail->data());
        } else {
            throw new \RuntimeException('Preview controller: I don\'t know how to render a view for "'.get_class($notification).'"');
        }
    }
}