65 lines
1.8 KiB
PHP
65 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Services\Api\TopUpSettingService;
|
|
use Illuminate\Http\Request;
|
|
|
|
class TopUpSettingController extends Controller
|
|
{
|
|
protected $topUpSettingService;
|
|
|
|
public function __construct(TopUpSettingService $topUpSettingService)
|
|
{
|
|
$this->topUpSettingService = $topUpSettingService;
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$response = $this->topUpSettingService->getAllSettings();
|
|
|
|
if (!$response['success']) {
|
|
return back()->with('error', $response['message']);
|
|
}
|
|
|
|
return view('pages.top-up-settings', [
|
|
'settings' => $response['data']
|
|
]);
|
|
}
|
|
|
|
public function store(Request $request)
|
|
{
|
|
$response = $this->topUpSettingService->createSetting($request->all());
|
|
|
|
if (!$response['success']) {
|
|
return back()->withInput()->with('error', $response['message']);
|
|
}
|
|
|
|
return redirect()->route('top-up-settings.index')
|
|
->with('success', 'Setting created successfully');
|
|
}
|
|
|
|
public function update(Request $request, $id)
|
|
{
|
|
$response = $this->topUpSettingService->updateSetting($id, $request->all());
|
|
|
|
if (!$response['success']) {
|
|
return back()->withInput()->with('error', $response['message']);
|
|
}
|
|
|
|
return redirect()->route('top-up-settings.index')
|
|
->with('success', 'Setting updated successfully');
|
|
}
|
|
|
|
public function destroy($id)
|
|
{
|
|
$response = $this->topUpSettingService->deleteSetting($id);
|
|
|
|
if (!$response['success']) {
|
|
return back()->with('error', $response['message']);
|
|
}
|
|
|
|
return redirect()->route('top-up-settings.index')
|
|
->with('success', 'Setting deleted successfully');
|
|
}
|
|
}
|