replace offline to oflinepayment payment gateways
This commit is contained in:
0
modules/OfflinePayment/Http/Controllers/.gitkeep
Normal file
0
modules/OfflinePayment/Http/Controllers/.gitkeep
Normal file
121
modules/OfflinePayment/Http/Controllers/Settings.php
Normal file
121
modules/OfflinePayment/Http/Controllers/Settings.php
Normal file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\OfflinePayment\Http\Controllers;
|
||||
|
||||
use Artisan;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
use Modules\OfflinePayment\Http\Requests\Setting as Request;
|
||||
use Modules\OfflinePayment\Http\Requests\SettingGet as GRequest;
|
||||
use Modules\OfflinePayment\Http\Requests\SettingDelete as DRequest;
|
||||
|
||||
class Settings extends Controller
|
||||
{
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @return Response
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$items = json_decode(setting('offlinepayment.methods'));
|
||||
|
||||
return view('offlinepayment::edit', compact('items'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
$offlinepayment = json_decode(setting('offlinepayment.methods'), true);
|
||||
|
||||
if (isset($request['method'])) {
|
||||
foreach ($offlinepayment as $key => $method) {
|
||||
if ($method['code'] == $request['method']) {
|
||||
$offlinepayment[$key]['code'] = 'offlinepayment.' . $request['code'] . '.' . (count($offlinepayment) + 1);
|
||||
$offlinepayment[$key]['name'] = $request['name'];
|
||||
$offlinepayment[$key]['order'] = $request['order'];
|
||||
$offlinepayment[$key]['description'] = $request['description'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$offlinepayment[] = array(
|
||||
'code' => 'offlinepayment.' . $request['code'] . '.' . (count($offlinepayment) + 1),
|
||||
'name' => $request['name'],
|
||||
'order' => $request['order'],
|
||||
'description' => $request['description']
|
||||
);
|
||||
}
|
||||
|
||||
// Set Api Token
|
||||
setting()->set('offlinepayment.methods', json_encode($offlinepayment));
|
||||
|
||||
setting()->save();
|
||||
|
||||
Artisan::call('cache:clear');
|
||||
|
||||
return redirect('modules/offlinepayment/settings');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @return Response
|
||||
*/
|
||||
public function get(GRequest $request)
|
||||
{
|
||||
$code = $request['code'];
|
||||
|
||||
$offlinepayment = json_decode(setting('offlinepayment.methods'), true);
|
||||
|
||||
foreach ($offlinepayment as $key => $method) {
|
||||
if ($method['code'] == $code) {
|
||||
$method['title'] = trans('offlinepayment::offlinepayment.edit', ['method' => $method['name']]);
|
||||
|
||||
$code = explode('.', $method['code']);
|
||||
|
||||
$method['code'] = $code[1];
|
||||
|
||||
$data = $method;
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'errors' => false,
|
||||
'success' => true,
|
||||
'data' => $data
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @return Response
|
||||
*/
|
||||
public function delete(DRequest $request)
|
||||
{
|
||||
$code = $request['code'];
|
||||
|
||||
$offlinepayment = json_decode(setting('offlinepayment.methods'), true);
|
||||
|
||||
foreach ($offlinepayment as $key => $method) {
|
||||
if ($method['code'] == $code) {
|
||||
unset($offlinepayment[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
// Set Api Token
|
||||
setting()->set('offlinepayment.methods', json_encode($offlinepayment));
|
||||
|
||||
setting()->save();
|
||||
|
||||
Artisan::call('cache:clear');
|
||||
|
||||
return response()->json([
|
||||
'errors' => false,
|
||||
'success' => true,
|
||||
]);
|
||||
}
|
||||
}
|
0
modules/OfflinePayment/Http/Middleware/.gitkeep
Normal file
0
modules/OfflinePayment/Http/Middleware/.gitkeep
Normal file
0
modules/OfflinePayment/Http/Requests/.gitkeep
Normal file
0
modules/OfflinePayment/Http/Requests/.gitkeep
Normal file
31
modules/OfflinePayment/Http/Requests/Setting.php
Normal file
31
modules/OfflinePayment/Http/Requests/Setting.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\OfflinePayment\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class Setting extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string',
|
||||
'code' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
30
modules/OfflinePayment/Http/Requests/SettingDelete.php
Normal file
30
modules/OfflinePayment/Http/Requests/SettingDelete.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\OfflinePayment\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class SettingDelete extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'code' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
30
modules/OfflinePayment/Http/Requests/SettingGet.php
Normal file
30
modules/OfflinePayment/Http/Requests/SettingGet.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\OfflinePayment\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class SettingGet extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'code' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
8
modules/OfflinePayment/Http/routes.php
Normal file
8
modules/OfflinePayment/Http/routes.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
Route::group(['middleware' => ['web', 'auth', 'language', 'adminmenu', 'permission:read-admin-panel'], 'prefix' => 'modules/offlinepayment', 'namespace' => 'Modules\OfflinePayment\Http\Controllers'], function () {
|
||||
Route::get('settings', 'settings@edit');
|
||||
Route::post('settings', 'settings@update');
|
||||
Route::post('settings/get', 'settings@get');
|
||||
Route::post('settings/delete', 'settings@delete');
|
||||
});
|
Reference in New Issue
Block a user