Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/ledger.corals.io/Corals/core/Settings/Http/Controllers/API/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/ledger.corals.io/Corals/core/Settings/Http/Controllers/API/SettingsController.php
<?php

namespace Corals\Settings\Http\Controllers\API;


use Corals\Foundation\Http\Controllers\APIBaseController;
use Corals\Settings\Facades\Settings;
use Corals\Settings\Http\Requests\SettingRequest;
use Corals\Settings\Models\Setting;
use Corals\Settings\Services\SettingService;
use Corals\Settings\Transformers\API\SettingPresenter;
use Illuminate\Http\Request;

class SettingsController extends APIBaseController
{
    protected $settingService;

    /**
     * SettingsController constructor.
     * @param SettingService $settingService
     * @throws \Exception
     */
    public function __construct(SettingService $settingService)
    {
        $this->settingService = $settingService;
        $this->settingService->setPresenter(new SettingPresenter());

        $this->corals_middleware_except = ['getActiveLanguages', 'getSettings'];

        parent::__construct();
    }

    public function update(SettingRequest $request, Setting $setting)
    {
        try {
            $setting = $this->settingService->update($request, $setting);

            return apiResponse($this->settingService->getModelDetails(), trans('Corals::messages.success.updated', ['item' => $setting->label]));
        } catch (\Exception $exception) {
            return apiExceptionResponse($exception);
        }
    }

    public function getSettingValue(Request $request, $code, $default = null)
    {
        try {
            if (!isSuperUser()) {
                abort(403, 'Forbidden!!');
            }

            $value = Settings::get($code, $default);

            if (is_array($value)) {
                $value = apiPluck($value);
            }

            return apiResponse($value);
        } catch (\Exception $exception) {
            return apiExceptionResponse($exception);
        }
    }

    public function getActiveLanguages()
    {
        try {
            return apiResponse(apiPluck(\Language::allowed(), 'code', 'label'));
        } catch (\Exception $exception) {
            return apiExceptionResponse($exception);
        }
    }

    /**
     * @return \Illuminate\Http\JsonResponse|void
     */
    public function getSettings()
    {
        try {
            $settings = Setting::query()
                ->where('is_public', true)
                ->select('value', 'type', 'code')
                ->get()
                ->toArray();

            return apiResponse($settings);
        } catch (\Exception $e) {
            return apiExceptionResponse($e);
        }

    }
}

Spamworldpro Mini