2018-10-09 12:02:22 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Webkul\Admin\Http\Controllers\Sales;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
use Illuminate\Http\Response;
|
|
|
|
|
use Webkul\Admin\Http\Controllers\Controller;
|
|
|
|
|
use Webkul\Sales\Repositories\OrderRepository as Order;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sales Order controller
|
|
|
|
|
*
|
|
|
|
|
* @author Jitendra Singh <jitendra@webkul.com>
|
|
|
|
|
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
|
|
|
|
*/
|
|
|
|
|
class OrderController extends Controller
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Display a listing of the resource.
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
|
*/
|
|
|
|
|
protected $_config;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* OrderRepository object
|
|
|
|
|
*
|
|
|
|
|
* @var array
|
|
|
|
|
*/
|
|
|
|
|
protected $order;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new controller instance.
|
|
|
|
|
*
|
2019-04-08 11:18:43 +00:00
|
|
|
* @param \Webkul\Sales\Repositories\OrderRepository $order
|
2018-10-09 12:02:22 +00:00
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function __construct(Order $order)
|
|
|
|
|
{
|
|
|
|
|
$this->middleware('admin');
|
|
|
|
|
|
|
|
|
|
$this->_config = request('_config');
|
|
|
|
|
|
|
|
|
|
$this->order = $order;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Display a listing of the resource.
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
|
*/
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
|
|
|
|
return view($this->_config['view']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Show the view for the specified resource.
|
|
|
|
|
*
|
|
|
|
|
* @param int $id
|
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
|
*/
|
|
|
|
|
public function view($id)
|
|
|
|
|
{
|
2019-04-08 11:18:43 +00:00
|
|
|
$order = $this->order->findOrFail($id);
|
2018-10-09 12:02:22 +00:00
|
|
|
|
|
|
|
|
return view($this->_config['view'], compact('order'));
|
|
|
|
|
}
|
2018-10-15 10:39:09 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Cancel action for the specified resource.
|
|
|
|
|
*
|
|
|
|
|
* @param int $id
|
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
|
*/
|
|
|
|
|
public function cancel($id)
|
|
|
|
|
{
|
2018-12-26 13:04:49 +00:00
|
|
|
$result = $this->order->cancel($id);
|
2019-02-13 12:12:07 +00:00
|
|
|
|
2019-01-15 11:54:41 +00:00
|
|
|
if ($result) {
|
2019-02-13 12:12:07 +00:00
|
|
|
session()->flash('success', trans('admin::app.response.cancel-success', ['name' => 'Order']));
|
2018-10-15 10:39:09 +00:00
|
|
|
} else {
|
2019-02-13 12:12:07 +00:00
|
|
|
session()->flash('error', trans('admin::app.response.cancel-error', ['name' => 'Order']));
|
2018-10-15 10:39:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return redirect()->back();
|
|
|
|
|
}
|
|
|
|
|
}
|