HEX
Server: LiteSpeed
System: Linux sv4.hami.host 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64
User: armgroup (1008)
PHP: 8.2.32
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open, mail, socket_create, socket_create_listen, socket_create_pair, link, dl, openlog, syslog, stream_socket_server, curl_multi_init
Upload Files
File: /home/armgroup/libs/app/Http/Controllers/Frontend/IndexController.php
<?php

namespace App\Http\Controllers\Frontend;

use App\Http\Controllers\Controller;
use App\Models\Article;
use App\Models\Banner;
use App\Models\Brand;
use App\Models\Category;
use App\Models\Product;
use Artesaos\SEOTools\Facades\SEOTools;
use Illuminate\Support\Facades\Storage;

class IndexController extends Controller
{
    public function index()
    {
        SEOTools::setTitle(settings('title'));
        SEOTools::setDescription(settings('description'));

        $banners = Banner::getBanners([
            'main-slider',
            'top-of-latest-products',
            'why-us',
            'top-of-footer',
        ]);
        [
            $slider,
        ] = [
            $banners->firstWhere('position', 'main-slider'),
        ];

        $indexCategories = Category::query()
            ->where('type', Product::class)
            ->where('status', true)
            ->where('show_in_index', true)
            ->whereNotNull('image')
            ->limit(8)
            ->get(['name', 'slug', 'image']);

        $articles = Article::query()
            ->with('categories:id,name')
            ->where('status', true)
            ->whereNotNull('image')
            ->latest('id')
            ->limit(4)
            ->get(['title', 'slug', 'image', 'description', 'created_at']);

        $brands = Brand::query()
            ->whereNotNull('image')
            ->latest('id')
            // ->limit(12)
            ->get(['name', 'slug', 'image', 'created_at']);
        $specialProducts = Product::query()
            ->with(['options', 'activeOptionValues'])
            ->where('status', true)
            ->whereNotNull('special')
            ->where('special_started_at', '<=', now())
            ->where('special_ended_at', '>=', now())
            ->limit(12)
            ->get(['id', 'name', 'slug', 'image', 'code', 'price', 'stock', 'special', 'special_started_at', 'special_ended_at', 'country_code']);

        $latestProducts = Product::query()
            ->with(['options', 'activeOptionValues'])
            ->where('status', true)
            ->limit(12)
            ->get(['id', 'name', 'slug', 'image', 'code', 'price', 'stock', 'special', 'special_started_at', 'special_ended_at', 'country_code']);

        
        $sellerProducts = Product::query()
            ->where('status', true)
            ->where('best_seller', true)
            ->get(['id', 'name', 'slug', 'image', 'code', 'price', 'stock', 'special', 'special_started_at', 'special_ended_at', 'country_code']);

        return view('frontend.index',
            compact(
                'slider',
                'brands',
                'articles',
                'specialProducts',
                'latestProducts',
                'sellerProducts',
                'indexCategories'
            ));
    }

    public function getFileSrc($model, $name = null)
    {
        $model = 'App\\Models\\'.$model;

        return $this->checkAccess($name, $model) ? response()->file(Storage::path($name)) : abort(404);
    }

    private function checkAccess($name, string $model): bool
    {
        // for users check user_id with folder name and for admins check permission
        return $name && class_exists($model) && (auth()->id() == explode('/',
            $name)[$model::USER_ID_SEGMENT] || auth()->user()->can($model::PERMISSION_NAME));
    }
}