Current File : /home/tradevaly/www/app/Http/Controllers/Admin/OrderController.php |
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\VendorOrder;
use App\Models\Order;
use App\Models\OrderItem;
use App\Models\AdminNotification;
use Brian2694\Toastr\Facades\Toastr;
use Carbon\Carbon;
use Illuminate\Http\Request;
class OrderController extends Controller
{
public function index(){
$orders = VendorOrder::orderby('created_at','desc')->paginate('20');
return view('backend.pages.order.index',compact('orders'));
}
public function paymentStatus(Request $request,$id)
{
$order = Order::where('id',$id)->firstOrFail();
$order->payment_status=$request->payment_status;
$order->save();
Toastr::success('Status Updated Successfully');
return back();
}
public function view($id){
$order = Order::where('order_id',$id)->first();
$items = OrderItem::where('order_id',$id)->get();
$vendor_order = VendorOrder::where('order_id',$id)->first();
$notification = AdminNotification::where('data',$order->order_id)->where('admin_reciver',"yes")->first();
if(isset($notification))
{
if($notification->admin_seen == '')
{
$notification->admin_seen= Carbon::now();
$notification->save();
}
}
return view('backend.pages.order.view',compact('order','items','vendor_order'));
}
}