107 lines
2.5 KiB
PHP
107 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Order;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class PesananController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index()
|
|
{
|
|
$payload = [
|
|
'title' => 'Pesanan Pending'
|
|
];
|
|
return view('dashboard.pesanan.pending.index', $payload);
|
|
}
|
|
|
|
|
|
public function getDataPending(){
|
|
$data = Order::where('statusenabled', true)->get();
|
|
return $data;
|
|
}
|
|
|
|
public function actionOrder(Request $request, string $order_id){
|
|
DB::connection('dbOrderGizi')->beginTransaction();
|
|
try {
|
|
$order = Order::where('order_id', $order_id)->first();
|
|
$action = $request->query('action');
|
|
$payload = [
|
|
'pegawai_id_confirm_order' => auth()->user()->id,
|
|
'pegawai_name_confirm_order' => auth()->user()->full_name,
|
|
'pegawai_at_confirm_order' => Carbon::now(),
|
|
'status_order' => $action ?? 'Dibatalkan',
|
|
];
|
|
if(!$action){
|
|
$payload['note_dibatalkan'] = request('note_dibatalkan');
|
|
}
|
|
$order->update($payload);
|
|
DB::connection('dbOrderGizi')->commit();
|
|
return response()->json([
|
|
'status' => true,
|
|
'message' => $action ? 'Konfirmasi Order Gizi telah disetujui!' : 'Konfirmasi Order Gizi telah dibatalkan'
|
|
]);
|
|
} catch (\Throwable $th) {
|
|
DB::connection('dbOrderGizi')->rollBack();
|
|
return response()->json([
|
|
'status' => false,
|
|
'message' => 'Gagal melakukan Konfirmasi Order Gizi'
|
|
]);
|
|
//throw $th;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*/
|
|
public function create()
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*/
|
|
public function store(Request $request)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*/
|
|
public function show(string $id)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*/
|
|
public function edit(string $id)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*/
|
|
public function update(Request $request, string $id)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*/
|
|
public function destroy(string $id)
|
|
{
|
|
//
|
|
}
|
|
}
|