Separated Checkout and Payment controllers, updates to checkout and payments
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
use App\Http\Requests\CheckoutAddEdit;
|
||||
use App\Models\{Checkout,Invoice};
|
||||
@@ -11,31 +11,35 @@ use App\Models\{Checkout,Invoice};
|
||||
class CheckoutController extends Controller
|
||||
{
|
||||
/**
|
||||
* Update a suppliers details
|
||||
* Update a checkout details
|
||||
*
|
||||
* @param CheckoutAddEdit $request
|
||||
* @param Checkout $o
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function addedit(CheckoutAddEdit $request,Checkout $o)
|
||||
public function addedit(CheckoutAddEdit $request,Checkout $o): RedirectResponse
|
||||
{
|
||||
$this->middleware(['auth','wholesaler']);
|
||||
|
||||
foreach ($request->except(['_token','active','submit']) as $key => $item)
|
||||
foreach ($request->validated() as $key => $item)
|
||||
$o->{$key} = $item;
|
||||
|
||||
$o->active = (bool)$request->active;
|
||||
$o->active = (bool)$request->validated('active',FALSE);
|
||||
|
||||
try {
|
||||
$o->save();
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->withErrors($e->getMessage())->withInput();
|
||||
return redirect()
|
||||
->back()
|
||||
->withErrors($e->getMessage())->withInput();
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->back()
|
||||
->with('success','Payment saved');
|
||||
return $o->wasRecentlyCreated
|
||||
? redirect()
|
||||
->to('a/checkout/'.$o->id)
|
||||
->with('success','Checkout added')
|
||||
: redirect()
|
||||
->back()
|
||||
->with('success','Checkout saved');
|
||||
}
|
||||
|
||||
public function cart_invoice(Request $request,Invoice $o=NULL)
|
||||
@@ -57,29 +61,8 @@ class CheckoutController extends Controller
|
||||
return $o->fee($request->post('total',0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a specific invoice for the user
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function home(): View
|
||||
{
|
||||
return view('theme.backend.adminlte.payment.home');
|
||||
}
|
||||
|
||||
public function pay(Request $request,Checkout $o)
|
||||
{
|
||||
return redirect('pay/paypal/authorise');
|
||||
}
|
||||
|
||||
/**
|
||||
* View details on a specific payment method
|
||||
*
|
||||
* @param Checkout $o
|
||||
* @return View
|
||||
*/
|
||||
public function view(Checkout $o): View
|
||||
{
|
||||
return view('theme.backend.adminlte.payment.view',['o'=>$o]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user