"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:
@ -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') {
|
||||
|
@ -8,4 +8,5 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class OrderItem extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user