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/SBogers95/rentman.io/app/Komma/CustomerLogos/Kms/CustomerLogoController.php
<?php

namespace App\Komma\CustomerLogos\Kms;

/**
 * @author      Komma <info@komma.pro>
 * @copyright   (c) 2012-2016, Komma
 */

use App\Komma\CustomerLogos\Models\CustomerLogo;
use App\Komma\Kms\Core\SectionController;
use Illuminate\Database\Eloquent\Model;

class CustomerLogoController extends SectionController
{
    protected $slug = 'customerlogos';

    protected $forModelName = CustomerLogo::class;

    public function __construct(CustomerLogoSection $section)
    {
        parent::__construct($section);
    }

    public function getStructureAsJson()
    {
        $this->authorize('index', $this->forModelName);

//        // Try to get it out of the cache
        if (\Cache::has('customerLogos')) {
            $customerLogos = \Cache::get('customerLogos');
        } else {
            $customerLogos = $this->treeService->getStructure();
            \Log::info('Stored customer logos in cache');
            \Cache::forever('customerLogos', $customerLogos);
        }

        return \Response::json($customerLogos);
    }

    public function store($model = null, $updateExistingModel = false)
    {
        $this->clearCache();

        return parent::store($model, $updateExistingModel);
    }

    public function destroy(Model $model)
    {
        $this->clearCache();

        return parent::destroy($model);
    }

    private function clearCache()
    {
        \Cache::forget('customerLogos');
    }
}