MMCT TEAM
Server IP : 103.191.208.50  /  Your IP : 216.73.216.53
Web Server : LiteSpeed
System : Linux orion.herosite.pro 4.18.0-553.53.1.lve.el8.x86_64 #1 SMP Wed May 28 17:01:02 UTC 2025 x86_64
User : celkcksm ( 1031)
PHP Version : 7.4.33
Disable Function : show_source, system, shell_exec, passthru, popen, exec
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/celkcksm/hrms.ncriptech.com/app/Http/Middleware/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/celkcksm/hrms.ncriptech.com/app/Http/Middleware/DemoModeMiddleware.php
<?php

namespace App\Http\Middleware;

use Brian2694\Toastr\Facades\Toastr;
use Closure;

class DemoModeMiddleware
{

    public function handle($request, Closure $next)
    {
        if (config('app.style') === 'demo') {
            // Check the current route action
            $routeAction = $request->route()->getAction('controller');

            // Check if the action is "destroy"
            $action = last(explode('@', $routeAction));

            if ($action === 'destroy' && !$this->isExempt($action)) {
                if ($request->ajax()) {
                    return response()->json([
                        'result' => false,
                        'message' => 'You are not allowed to perform the delete action in demo mode',
                        'error' => 'failed',
                    ], 401);
                } else {
                    Toastr::error(_trans('message.You are not allowed to perform the delete action in demo mode'), 'Error');
                    return redirect()->back();
                }
            }
        }

        return $next($request);
    }

    protected function isExempt($action)
    {
        // Add logic to check if the current model is exempt based on its name
        return in_array($action, $this->exemptModels);
    }
}

MMCT - 2023