Current File : /home/itiffy/public_html/app/Http/Controllers/Admin/PaymentGatewayController.php |
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Redirect;
use Schema;
use App\Gatway;
use App\Http\Requests\CreateGatwayRequest;
use App\Http\Requests\UpdateGatwayRequest;
use Illuminate\Http\Request;
class PaymentGatewayController extends Controller {
/**
* Display a listing of gatway
*
* @param Request $request
*
* @return \Illuminate\View\View
*/
public function index(Request $request)
{
$gatway = Gatway::find(1);
return view('admin.gatway.edit', compact('gatway'));
}
/**
* Show the form for creating a new gatway
*
* @return \Illuminate\View\View
*/
public function create()
{
return view('admin.gatway.create');
}
/**
* Store a newly created gatway in storage.
*
* @param CreateGatwayRequest|Request $request
*/
public function store(CreateGatwayRequest $request)
{
Gatway::create($request->all());
return redirect()->route(config('quickadmin.route').'.gatway.index');
}
/**
* Show the form for editing the specified gatway.
*
* @param int $id
* @return \Illuminate\View\View
*/
public function edit($id)
{
$gatway = Gatway::find($id);
return view('admin.gatway.edit', compact('gatway'));
}
/**
* Update the specified gatway in storage.
* @param UpdateGatwayRequest|Request $request
*
* @param int $id
*/
public function update($id, UpdateGatwayRequest $request)
{
$gatway = Gatway::findOrFail($id);
$gatway->update($request->all());
return Redirect::back()->with('success', true)->with('message','Successfully updated.');
//return redirect()->route(config('quickadmin.route').'.gatway.index');
}
/**
* Remove the specified gatway from storage.
*
* @param int $id
*/
public function destroy($id)
{
Gatway::destroy($id);
return redirect()->route(config('quickadmin.route').'.gatway.index');
}
/**
* Mass delete function from index page
* @param Request $request
*
* @return mixed
*/
public function massDelete(Request $request)
{
if ($request->get('toDelete') != 'mass') {
$toDelete = json_decode($request->get('toDelete'));
Gatway::destroy($toDelete);
} else {
Gatway::whereNotNull('id')->delete();
}
return redirect()->route(config('quickadmin.route').'.gatway.index');
}
}