"Updated MainController, OrderItem model, adminheader, footer, header, and orders blade files with changes to myOrders function, datatables, and modal implementation."

This commit is contained in:
UronShrestha
2024-07-15 11:23:50 +05:45
parent f171e49b3f
commit d8e17eef70
6 changed files with 179 additions and 98 deletions

View File

@ -214,15 +214,49 @@ class MainController extends Controller
}
// public function myOrders()
// {
// if (session()->has('id')) {
// $orders = Order::where('customerId', session()->get('id'))->get();
// // dd($orders);
// $items = DB::table('products')
// ->join('order_items', 'order_items.productId', '=', 'products.id')
// ->select('products.name', 'products.picture', 'products.*')
// ->get();
// return view('orders', compact('orders', 'items'));
// }
// return view('login');
// }
//old myOrders
// public function myOrders()
// {
// if (session()->has('id')) {
// $orders = Order::where('customerId', session()->get('id'))->get();
// $items = DB::table('products')
// ->join('order_items', 'order_items.productId', '=', 'products.id')
// ->select('products.name', 'products.picture', 'products.*', 'order_items.orderId')
// ->get();
// return view('orders', compact('orders', 'items'));
// }
// return view('login');
// }
//new myOrders
public function myOrders()
{
if (session()->has('id')) {
$orders = Order::where('customerId', session()->get('id'))->get();
$items = DB::table('products')
->join('order_items', 'order_items.productId', '=', 'products.id')
->select('products.name', 'products.picture', 'products.*')
->select('products.name', 'products.picture', 'order_items.*')
->get();
return view('orders', compact('orders', 'items'));
@ -232,6 +266,8 @@ class MainController extends Controller
}
public function profile()
{
if (session()->get('type') == 'Customer') {

View File

@ -8,4 +8,5 @@ use Illuminate\Database\Eloquent\Model;
class OrderItem extends Model
{
use HasFactory;
}