64 lines
1.3 KiB
PHP
64 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Shop;
|
|
|
|
use App\Datatables\Shop\OrdersDataTable;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Repositories\Shop\Orders;
|
|
use App\Repositories\Shop\OrderMails;
|
|
use Illuminate\Http\Request;
|
|
|
|
class OrderController extends Controller
|
|
{
|
|
public function index(OrdersDataTable $dataTable)
|
|
{
|
|
return $dataTable->render('Admin.Shop.Orders.list');
|
|
}
|
|
|
|
public function create()
|
|
{
|
|
return view('Admin.Shop.Orders.create');
|
|
}
|
|
|
|
public function show($id)
|
|
{
|
|
$data = Orders::get($id);
|
|
|
|
return view('Admin.Shop.Orders.view', $data);
|
|
}
|
|
|
|
public function edit($id)
|
|
{
|
|
$data = Orders::edit($id);
|
|
// dump($data);
|
|
// exit;
|
|
|
|
return view('Admin.Shop.Orders.edit', $data);
|
|
}
|
|
|
|
public function store(Request $request)
|
|
{
|
|
$order = Orders::store($request->all());
|
|
switch ($order->status) {
|
|
case 1:
|
|
OrderMails::sendPreparation($order->id);
|
|
break;
|
|
case 2:
|
|
OrderMails::sendShipping($order->id);
|
|
break;
|
|
}
|
|
|
|
return redirect()->route('Admin.Shop.Orders.index');
|
|
}
|
|
|
|
public function delete($id)
|
|
{
|
|
return Orders::destroy($id);
|
|
}
|
|
|
|
public function download($id)
|
|
{
|
|
return Orders::download($id);
|
|
}
|
|
}
|