Files
upstream-krayin/packages/Webkul/Admin/src/Http/Controllers/Configuration/ConfigurationController.php
upstream-mirror 135ffdb085
Some checks failed
Admin | Playwright Tests / Admin | Playwright Tests | Shard 1 Of 6 (push) Failing after 37s
Admin | Playwright Tests / Admin | Playwright Tests | Shard 2 Of 6 (push) Failing after 7s
Admin | Playwright Tests / Admin | Playwright Tests | Shard 4 Of 6 (push) Failing after 7s
Admin | Playwright Tests / Admin | Playwright Tests | Shard 6 Of 6 (push) Failing after 6s
Linting Tests / PHP 8.3 test on ubuntu-latest (push) Failing after 5s
CI / PHP 8.3 test on ubuntu-latest (push) Failing after 6s
Skills Consistency / validate-skills (push) Successful in 10s
Admin | Playwright Tests / Admin | Playwright Tests | Shard 3 Of 6 (push) Failing after 7s
Admin | Playwright Tests / Admin | Playwright Tests | Shard 5 Of 6 (push) Failing after 6s
snapshot of https://github.com/krayin/laravel-crm.git (2.2, 2026-09-18; blobs > 131072B omitted)
2026-09-18 04:37:41 +05:00

86 lines
2.1 KiB
PHP

<?php
namespace Webkul\Admin\Http\Controllers\Configuration;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Storage;
use Illuminate\View\View;
use Webkul\Admin\Http\Controllers\Controller;
use Webkul\Admin\Http\Requests\ConfigurationForm;
use Webkul\Core\Repositories\CoreConfigRepository as ConfigurationRepository;
class ConfigurationController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct(protected ConfigurationRepository $configurationRepository) {}
/**
* Display a listing of the resource.
*/
public function index(): View
{
if (
request()->route('slug')
&& request()->route('slug2')
) {
return view('admin::configuration.edit');
}
return view('admin::configuration.index');
}
/**
* Store a newly created resource in storage.
*/
public function store(ConfigurationForm $request): RedirectResponse
{
Event::dispatch('core.configuration.save.before');
$this->configurationRepository->create($request->all());
Event::dispatch('core.configuration.save.after');
session()->flash('success', trans('admin::app.configuration.index.save-success'));
return redirect()->back();
}
/**
* download the file for the specified resource.
*
* @return Response
*/
public function download()
{
$path = request()->route()->parameters()['path'];
$fileName = 'configuration/'.$path;
$config = $this->configurationRepository->findOneByField('value', $fileName);
return Storage::download($config['value']);
}
/**
* Search for configurations.
*/
public function search(): JsonResponse
{
$results = $this->configurationRepository->search(
system_config()->getItems(),
request()->query('query')
);
return new JsonResponse([
'data' => $results,
]);
}
}