Back | Home
الـ Path الحالي: /home/picotech/domains/instantly.picotech.app/public_html/public/uploads/../../app/Http/Controllers
الملفات الموجودة في هذا الـ Path:
.
..
Admin
AssetController.php
Auth
Controller.php
Customer
FrontController.php
InboundController.php
RouteController.php
ScheduleController.php
UpgradeController.php

مشاهدة ملف: AssetController.php

<?php

namespace App\Http\Controllers;

use App\Events\MailEvent;
use App\Events\MailOpen;
use App\Models\Campaign;
use App\Models\EmailQueue;
use App\Models\MessageLog;
use App\Models\Unsubscribe;
use Illuminate\Http\Request;

class AssetController extends Controller
{
    public function mailOpen(Request $request)
    {
        $campaignId = $request->campaign_id;
        $messageLogId = $request->message_log;
        MailEvent::dispatch('opened',$campaignId,$messageLogId);

        // Return a 1x1 transparent GIF image to the client
        $image = base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
        return response($image, 200)->header('Content-Type', 'image/gif');
    }

    public function unsubscribe(Request $request)
    {
        $campaign = Campaign::where('id', $request->campaign)->first();
        if ($campaign && $request->email) {
//            $messageLog = MessageLog::where('campaign_id', $campaign->id)->where('id', $request->message)->first();
//            if($messageLog) {
                $subscribed = Unsubscribe::where('email', $request->email)->first();
                if (!$subscribed) {
                    $unsub = new Unsubscribe();
                    $unsub->campaign_id = $campaign->id;
//                    $unsub->queue_id = $messageLog->queue_id;
                    $unsub->email = $request->email;
                    $unsub->save();
//                }
            }
        } else {
            $subscribed = Unsubscribe::where('email', $request->email)->first();
            if (!$subscribed) {
                $unsub = new Unsubscribe();
                $unsub->email = $request->email;
                $unsub->save();
            }
        }
        echo "<div style='text-align: center; margin-top: 30px; color: black; padding: 40px; background: lightblue;'><h3> Successfully Unsubscribed </h3></div>";
    }

    public function mailClicked(Request $request)
    {
        if (!$request->redirect) {
            abort(404);
        }
        $campaignId = $request->campaign;
        $messageLogId = $request->message;
        if(!$request->track_no){
            MailEvent::dispatch('clicked',$campaignId,$messageLogId);
        }

        return redirect()->to(urldecode($request->redirect));
    }
}