osb/app/Http/Controllers/CheckoutController.php

83 lines
1.8 KiB
PHP
Raw Normal View History

2020-07-27 04:49:59 +00:00
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\View\View;
2020-07-27 04:49:59 +00:00
use App\Http\Requests\CheckoutAddEdit;
use App\Models\{Checkout,Invoice};
2020-07-27 04:49:59 +00:00
class CheckoutController extends Controller
{
/**
* Update a suppliers details
*
* @param CheckoutAddEdit $request
* @param Checkout $o
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse
*/
public function addedit(CheckoutAddEdit $request,Checkout $o)
{
$this->middleware(['auth','wholesaler']);
foreach ($request->except(['_token','active','submit']) as $key => $item)
$o->{$key} = $item;
$o->active = (bool)$request->active;
try {
$o->save();
} catch (\Exception $e) {
return redirect()->back()->withErrors($e->getMessage())->withInput();
}
return redirect()->back()
->with('success','Payment saved');
}
2020-07-27 04:49:59 +00:00
public function cart_invoice(Request $request,Invoice $o=NULL)
{
if ($o) {
$request->session()->put('invoice.cart.'.$o->id,$o->id);
}
if (! $request->session()->get('invoice.cart'))
return redirect()->to('u/home');
return View('u.invoice.cart')
->with('invoices',Invoice::find(array_values($request->session()->get('invoice.cart'))));
}
public function fee(Request $request,Checkout $o): float
{
return $o->fee($request->post('total',0));
}
/**
* Render a specific invoice for the user
*
* @return View
*/
public function home(): View
{
return View('payment.home');
}
2020-07-27 04:49:59 +00:00
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('payment.view',['o'=>$o]);
}
2020-07-27 04:49:59 +00:00
}