PHP 8.2.30
Preview: DebugController.php Size: 3.48 KB
/home/byroehnu/cnggold.com.ng/app/Http/Controllers/DebugController.php

<?php

namespace App\Http\Controllers;

use App\Models\CaseStudy;
use App\Models\Page;
use App\Models\Portfolio;
use App\Models\Service;
use App\Models\Setting;
use App\Models\Team;
use Illuminate\Support\Facades\File;
use Inertia\Inertia;

class DebugController extends Controller
{
    public function any()
    {
        $main_menu = Setting::pull('main_menu');
        $newDomain = request()->getHost();
        $this->replaceDomainPaths(json_decode($main_menu, true), "bione-laravel.laralink.com", $newDomain);

        // update page
        Page::with('contents')->each(function ($page) {
            $page->contents->each(function ($content) {
                $contentData = $content->toArray();
                $newDomain = request()->getHost();
                $contentData['sections_data'] = $this->replaceDomainPaths($contentData['sections_data'], "bione-laravel.laralink.com", $newDomain);
                $content->update($contentData);
            });
        });

        // update portfolio
        Portfolio::with('contents')->each(function ($portfolio) {
            $portfolio->contents->each(function ($content) {
                $contentData = $content->toArray();
                $newDomain = request()->getHost();
                $contentData['sections_data'] = $this->replaceDomainPaths($contentData['sections_data'], "bione-laravel.laralink.com", $newDomain);
                $content->update($contentData);
            });
        });

        // service update
        Service::with('contents')->each(function ($service) {
            $service->contents->each(function ($content) {
                $contentData = $content->toArray();
                $newDomain = request()->getHost();
                $contentData['sections_data'] = $this->replaceDomainPaths($contentData['sections_data'], "bione-laravel.laralink.com", $newDomain);
                $content->update($contentData);
            });
        });

        // case study update
        CaseStudy::with('contents')->each(function ($caseStudy) {
            $caseStudy->contents->each(function ($content) {
                $contentData = $content->toArray();
                $newDomain = request()->getHost();
                $contentData['sections_data'] = $this->replaceDomainPaths($contentData['sections_data'], "bione-laravel.laralink.com", $newDomain);
                $content->update($contentData);
            });
        });

        // Team update
        Team::with('contents')->each(function ($team) {
            $team->contents->each(function ($content) {
                $contentData = $content->toArray();
                $newDomain = request()->getHost();
                $contentData['sections_data'] = $this->replaceDomainPaths($contentData['sections_data'], "bione-laravel.laralink.com", $newDomain);
                $content->update($contentData);
            });
        });
    }

    /**
     * Recursively replace all URLs with a specific domain.
     *
     * @param mixed $data
     * @param string $oldDomain
     * @param string $newDomain
     * @return mixed
     */
    private function replaceDomainPaths($data, string $oldDomain, string $newDomain)
    {
        if (is_array($data)) {
            foreach ($data as $key => $value) {
                $data[$key] = $this->replaceDomainPaths($value, $oldDomain, $newDomain);
            }
        } elseif (is_string($data) && str_contains($data, $oldDomain)) {
            $data = str_replace("https://{$oldDomain}", "https://{$newDomain}", $data);
        }

        return $data;
    }
}

Directory Contents

Dirs: 4 × Files: 6

Name Size Perms Modified Actions
Admin DIR
- drwxr-xr-x 2025-07-19 07:29:54
Edit Download
Auth DIR
- drwxr-xr-x 2025-05-08 11:48:26
Edit Download
Debug DIR
- drwxr-xr-x 2025-04-08 04:12:56
Edit Download
Frontend DIR
- drwxr-xr-x 2025-07-19 07:29:54
Edit Download
336 B lrw-r--r-- 2025-04-19 04:22:18
Edit Download
3.48 KB lrw-r--r-- 2025-07-19 11:19:37
Edit Download
8.61 KB lrw-r--r-- 2025-07-19 11:26:12
Edit Download
3.66 KB lrw-r--r-- 2025-05-04 10:26:05
Edit Download
1.48 KB lrw-r--r-- 2025-04-08 04:12:56
Edit Download
3.97 KB lrw-r--r-- 2025-07-19 12:08:07
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).