Created
March 4, 2018 19:51
-
-
Save ak4bento/319e836f195ddfa7198448ecbad50f62 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
use App\Http\Controllers\AppBaseController; | |
use Flash; | |
use Prettus\Repository\Criteria\RequestCriteria; | |
use Response; | |
use App\Http\Requests\Createoc_categoryRequest; | |
use App\Http\Requests\Updateoc_categoryRequest; | |
use App\Repositories\oc_categoryRepository; | |
use App\Http\Controllers\portalpulsa; | |
use App\Models\cs_saldo; | |
use Auth; | |
use App\Http\Requests\Createcs_saldoRequest; | |
use App\Http\Requests\Updatecs_saldoRequest; | |
use App\Repositories\cs_saldoRepository; | |
class cs_pulsaController extends Controller | |
{ | |
private $ocCategoryRepository; | |
private $csSaldoRepository; | |
public function __construct(oc_categoryRepository $ocCategoryRepo, cs_saldoRepository $csSaldoRepo) | |
{ | |
$this->csSaldoRepository = $csSaldoRepo; | |
$this->ocCategoryRepository = $ocCategoryRepo; | |
} | |
public function index(Request $request) | |
{ | |
$portalpulsa = new portalpulsa; | |
$this->ocCategoryRepository->pushCriteria(new RequestCriteria($request)); | |
$ocCategories = $this->ocCategoryRepository->all(); | |
return view('cs_pulsa.index',['ocCategories' => $ocCategories, 'portalpulsa' => $portalpulsa]); | |
} | |
public function mobile(Request $request) | |
{ | |
$portalpulsa = new portalpulsa; | |
$this->ocCategoryRepository->pushCriteria(new RequestCriteria($request)); | |
$ocCategories = $this->ocCategoryRepository->all(); | |
return view('mobile.cs_pulsa.index',['ocCategories' => $ocCategories, 'portalpulsa' => $portalpulsa]); | |
} | |
public function paketdata(Request $request) | |
{ | |
$portalpulsa = new portalpulsa; | |
$this->ocCategoryRepository->pushCriteria(new RequestCriteria($request)); | |
$ocCategories = $this->ocCategoryRepository->all(); | |
return view('cs_pulsa.paketdata',['ocCategories' => $ocCategories, 'portalpulsa' => $portalpulsa]); | |
} | |
public function gojekgrab(Request $request) | |
{ | |
$portalpulsa = new portalpulsa; | |
$this->ocCategoryRepository->pushCriteria(new RequestCriteria($request)); | |
$ocCategories = $this->ocCategoryRepository->all(); | |
return view('cs_pulsa.gojekgrab',['ocCategories' => $ocCategories, 'portalpulsa' => $portalpulsa]); | |
} | |
public function buy(Request $request) | |
{ | |
$portalpulsa = new portalpulsa; | |
$this->ocCategoryRepository->pushCriteria(new RequestCriteria($request)); | |
$ocCategories = $this->ocCategoryRepository->all(); | |
$cek = cs_saldo::where('user_id',Auth::user()->id)->first(); | |
// return $cek->id; | |
if (count($cek) > 0) { | |
foreach ($portalpulsa->cekHarga($request['kode'])->message as $harga) { | |
$ck = $harga->price; | |
} | |
if ($cek['saldo'] > $ck) { | |
$hasil = $portalpulsa->prosesPulsa($request['kode'],$request['nohp'],2); | |
Flash::success("Transaksi anda berhasil. ".$hasil->message); | |
$saldoUpdate = cs_saldo::find($cek->id); | |
$saldoUpdate->saldo = ($cek->saldo) - ($ck + 200); | |
$saldoUpdate->save(); | |
// Flash::success("Transaksi anda berhasil."); | |
return redirect(route('home')); | |
// return view('cs_pulsa.index',['ocCategories' => $ocCategories, 'portalpulsa' => $portalpulsa]); | |
} | |
else { | |
Flash::warning('Saldo anda kurang, silahkan ini saldo anda terlebih dahulu.'); | |
return back()->withInput(); | |
// return view('cs_pulsa.index',['ocCategories' => $ocCategories, 'portalpulsa' => $portalpulsa]); | |
} | |
} | |
else { | |
Flash::error('Saldo Anda kurang, silahkan ini saldo anda terlebih dahulu.'); | |
return back()->withInput(); | |
// return view('cs_pulsa.index',['ocCategories' => $ocCategories, 'portalpulsa' => $portalpulsa]); | |
} | |
} | |
public function buyMobile(Request $request) | |
{ | |
$portalpulsa = new portalpulsa; | |
$this->ocCategoryRepository->pushCriteria(new RequestCriteria($request)); | |
$ocCategories = $this->ocCategoryRepository->all(); | |
$cek = cs_saldo::where('user_id',Auth::user()->id)->first(); | |
// return $cek->id; | |
if (count($cek) > 0) { | |
foreach ($portalpulsa->cekHarga($request['kode'])->message as $harga) { | |
$ck = $harga->price; | |
} | |
if ($cek['saldo'] > $ck) { | |
$hasil = $portalpulsa->prosesPulsa($request['kode'],$request['nohp'],2); | |
Flash::success("Transaksi anda berhasil. ".$hasil->message); | |
$saldoUpdate = cs_saldo::find($cek->id); | |
$saldoUpdate->saldo = ($cek->saldo) - ($ck + 200); | |
$saldoUpdate->save(); | |
// Flash::success("Transaksi anda berhasil."); | |
return redirect(route('mobile.home')); | |
// return view('cs_pulsa.index',['ocCategories' => $ocCategories, 'portalpulsa' => $portalpulsa]); | |
} | |
else { | |
Flash::warning('Saldo anda kurang, silahkan ini saldo anda terlebih dahulu.'); | |
return back()->withInput(); | |
// return view('cs_pulsa.index',['ocCategories' => $ocCategories, 'portalpulsa' => $portalpulsa]); | |
} | |
} | |
else { | |
Flash::error('Saldo Anda kurang, silahkan ini saldo anda terlebih dahulu.'); | |
return back()->withInput(); | |
// return view('cs_pulsa.index',['ocCategories' => $ocCategories, 'portalpulsa' => $portalpulsa]); | |
} | |
} | |
public function buypln(Request $request) | |
{ | |
$portalpulsa = new portalpulsa; | |
$this->ocCategoryRepository->pushCriteria(new RequestCriteria($request)); | |
$ocCategories = $this->ocCategoryRepository->all(); | |
$cek = cs_saldo::where('user_id',Auth::user()->id)->first(); | |
// return $cek->id; | |
if (count($cek) > 0) { | |
foreach ($portalpulsa->cekHarga($request['kode'])->message as $harga) { | |
$ck = $harga->price; | |
} | |
if ($cek['saldo'] > $ck) { | |
$hasil = $portalpulsa->prosesPLN($request['kode'],$request['nohp'],$request['idpel'],1); | |
Flash::success("Transaksi anda berhasil. ".$hasil->message); | |
$saldoUpdate = cs_saldo::find($cek->id); | |
$saldoUpdate->saldo = ($cek->saldo) - ($ck + 200); | |
$saldoUpdate->save(); | |
// Flash::success("Transaksi anda berhasil."); | |
return redirect(route('home')); | |
// return view('cs_pulsa.index',['ocCategories' => $ocCategories, 'portalpulsa' => $portalpulsa]); | |
} | |
else { | |
Flash::warning('Saldo anda kurang, silahkan ini saldo anda terlebih dahulu.'); | |
return back()->withInput(); | |
// return view('cs_pulsa.index',['ocCategories' => $ocCategories, 'portalpulsa' => $portalpulsa]); | |
} | |
} | |
else { | |
Flash::error('Anda belum memiliki saldo, silahkan ini saldo anda terlebih dahulu.'); | |
return back()->withInput(); | |
// return view('cs_pulsa.index',['ocCategories' => $ocCategories, 'portalpulsa' => $portalpulsa]); | |
} | |
} | |
public function buyplnMobile(Request $request) | |
{ | |
$portalpulsa = new portalpulsa; | |
$this->ocCategoryRepository->pushCriteria(new RequestCriteria($request)); | |
$ocCategories = $this->ocCategoryRepository->all(); | |
$cek = cs_saldo::where('user_id',Auth::user()->id)->first(); | |
// return $cek->id; | |
if (count($cek) > 0) { | |
foreach ($portalpulsa->cekHarga($request['kode'])->message as $harga) { | |
$ck = $harga->price; | |
} | |
if ($cek['saldo'] > $ck) { | |
$hasil = $portalpulsa->prosesPLN($request['kode'],$request['nohp'],$request['idpel'],1); | |
Flash::success("Transaksi anda berhasil. ".$hasil->message); | |
$saldoUpdate = cs_saldo::find($cek->id); | |
$saldoUpdate->saldo = ($cek->saldo) - ($ck + 200); | |
$saldoUpdate->save(); | |
// Flash::success("Transaksi anda berhasil."); | |
return redirect(route('mobile.home')); | |
// return view('cs_pulsa.index',['ocCategories' => $ocCategories, 'portalpulsa' => $portalpulsa]); | |
} | |
else { | |
Flash::warning('Saldo anda kurang, silahkan ini saldo anda terlebih dahulu.'); | |
return back()->withInput(); | |
// return view('cs_pulsa.index',['ocCategories' => $ocCategories, 'portalpulsa' => $portalpulsa]); | |
} | |
} | |
else { | |
Flash::error('Anda belum memiliki saldo, silahkan ini saldo anda terlebih dahulu.'); | |
return back()->withInput(); | |
// return view('cs_pulsa.index',['ocCategories' => $ocCategories, 'portalpulsa' => $portalpulsa]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment