cms-frontend/app/Http/Controllers/SystemParameterController.php

65 lines
1.8 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Services\Api\SystemParameterService;
use Illuminate\Http\Request;
class SystemParameterController extends Controller
{
protected $systemParamService;
public function __construct(SystemParameterService $systemParamService)
{
$this->systemParamService = $systemParamService;
}
public function index()
{
$response = $this->systemParamService->getAllParameters();
if (!$response['success']) {
return back()->with('error', $response['message']);
}
return view('pages.system-parameters', [
'parameters' => $response['data']
]);
}
public function store(Request $request)
{
$response = $this->systemParamService->createParameter($request->all());
if (!$response['success']) {
return back()->withInput()->with('error', $response['message']);
}
return redirect()->route('system-parameters.index')
->with('success', 'Parameter created successfully');
}
public function update(Request $request, $id)
{
$response = $this->systemParamService->updateParameter($id, $request->all());
if (!$response['success']) {
return back()->withInput()->with('error', $response['message']);
}
return redirect()->route('system-parameters.index')
->with('success', 'Parameter updated successfully');
}
public function destroy($id)
{
$response = $this->systemParamService->deleteParameter($id);
if (!$response['success']) {
return back()->with('error', $response['message']);
}
return redirect()->route('system-parameters.index')
->with('success', 'Parameter deleted successfully');
}
}