diff --git a/app/Http/Controllers/Admin/TahesabController.php b/app/Http/Controllers/Admin/TahesabController.php index 00ed2e4..40a05a1 100644 --- a/app/Http/Controllers/Admin/TahesabController.php +++ b/app/Http/Controllers/Admin/TahesabController.php @@ -108,16 +108,16 @@ class TahesabController extends Controller // directon: 0 = daryaft az moshtari // directon: 1 = pardakht be moshtari - public function wallet($input = null) + public function wallet($data) { - if ($input instanceof \Illuminate\Http\Request) { - $data = $input->all(); - } elseif (is_array($input)) { - $data = $input; - } else { - $data = request()->all(); - } +// if ($input instanceof \Illuminate\Http\Request) { +// $data = $input->all(); +// } elseif (is_array($input)) { +// $data = $input; +// } else { +// $data = request()->all(); +// } if (!isset($data['customer_id']) || !isset($data['value'])) { return request()->expectsJson() @@ -169,28 +169,31 @@ class TahesabController extends Controller -1, //MultiRadif ] - ]); + ])->json(); } catch (\Exception $e) { return $e->getMessage(); } if ($response['OK']) { - $tahesab->sh_factor = $response['Sh_factor']; - $tahesab->tahesab_id = $response['OK']; - $tahesab->save(); + Tahesab::where('id', $tahesab->id)->update([ + "sh_factor" => $response['Sh_factor'], + "tahesab_id" => $response['OK'], + "res" => json_encode($response, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT), + ]); + return $data; } return false; } - public function walletGold($input = null) + public function walletGold($data) { - if ($input instanceof \Illuminate\Http\Request) { - $data = $input->all(); - } elseif (is_array($input)) { - $data = $input; - } else { - $data = request()->all(); - } +// if ($input instanceof \Illuminate\Http\Request) { +// $data = $input->all(); +// } elseif (is_array($input)) { +// $data = $input; +// } else { +// $data = request()->all(); +// } // return ($data); if (!isset($data['customer_id'])) { @@ -256,18 +259,20 @@ class TahesabController extends Controller 0, //Jens_Felez (string)$date, ] - ]); + ])->json(); } catch (Exception $e) { return $e->getMessage(); } if ($response['OK']) { - $tahesab->sh_factor = $response['Sh_factor']; - $tahesab->tahesab_id = $response['OK']; - $tahesab->factor_number = $response['Factor_Number']; - $tahesab->tah_id = $response['ID']; - $tahesab->res = $response; - $tahesab->data = $data; - $tahesab->save(); + Tahesab::where('id', $tahesab->id)->update([ + "sh_factor" => $response['Sh_factor'], + "tahesab_id" => $response['OK'], + "factor_number" => $response['Factor_Number'], + "tah_id" => $response['ID'], + "data" => json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT), + "res" => json_encode($response, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT), + ]); + return $data; } return false; diff --git a/app/Models/Tahesab.php b/app/Models/Tahesab.php index de5441b..2db8a36 100644 --- a/app/Models/Tahesab.php +++ b/app/Models/Tahesab.php @@ -24,6 +24,8 @@ class Tahesab extends Model 'res', 'factor_number', 'tah_id', + 'type', + 'data', ];