i'm making my first e-commerce website but i didn't know how to create and view the orders of customers in the admin panel. i tried to follow diffrent tutorials but it didn't work for me. and as i'm new to laravel i'm not sure where to add the lines.
this is my OrdersController
class OrdersController extends Controller
{
public function index () {
$session_id = Session::get('session_id');
$cart_datas = Cart_model::where('session_id', $session_id)->get();
$total_price = 0;
foreach ($cart_datas as $cart_data) {
$total_price += $cart_data->price * $cart_data->quantity;
}
$shipping_address = DB::table('delivery_address')->where('users_id', Auth::id())->first();
return view('checkout.review_order', compact('shipping_address', 'cart_datas', 'total_price'));
}
public function order (Request $request) {
$input_data = $request->all();
$payment_method = $input_data['payment_method'];
Orders_model::create($input_data);
if ( $payment_method == "COD" ) {
return redirect('/cod');
} else {
return redirect('/paypal');
}
}
public function cod () {
$user_order = Orders_model::where('users_id', Auth::id())->first();
return view('payment.cod', compact('user_order'));
}
public function paypal (Request $request) {
$who_buying = Orders_model::where('users_id', Auth::id())->first();
return view('payment.paypal', compact('who_buying'));
}
public function show($id) {}
}
this is **web.php **
/* Admin Location */
Auth::routes(['register'=>false]);
Route::get('/home', 'HomeController@index')->name('home');
Route::group(['prefix'=>'admin','middleware'=>['auth','admin']],function () {
Route::get('/', 'AdminController@index')->name('admin_home');
/// Setting Area
Route::get('/settings', 'AdminController@settings');
Route::get('/check-pwd', 'AdminController@chkPassword');
Route::post('/update-pwd', 'AdminController@updatAdminPwd');
/// Category Area
Route::resource('/category', 'CategoryController');
Route::get('delete-category/{id}', 'CategoryController@destroy');
Route::get('/check_category_name', 'CategoryController@checkCateName');
/// Products Area
Route::resource('/product', 'ProductsController');
Route::get('delete-product/{id}', 'ProductsController@destroy');
Route::get('delete-image/{id}', 'ProductsController@deleteImage');
/// Product Attribute
Route::resource('/product_attr', 'ProductAtrrController');
Route::get('delete-attribute/{id}', 'ProductAtrrController@deleteAttr');
/// Product Images Gallery
Route::resource('/image-gallery', 'ImagesController');
Route::get('delete-imageGallery/{id}', 'ImagesController@destroy');
/// ///////// Coupons Area //////////
Route::resource('/coupon', 'CouponController');
Route::get('delete-coupon/{id}', 'CouponController@destroy');
//Admin orders Routes
Route::resource('/view-Orders', 'OrdersController@index');
});
this is my adminside bar
<!--sidebar-menu-->
<div id="sidebar"><a href="{{url('/admin')}}" class="visible-phone"><i class="icon icon-home"></i> Dashboard</a>
<ul>
<li{{$menu_active==1? ' class=active':''}}><a href="{{url('/admin')}}"><i class="icon icon-home"></i> <span>Dashboard</span></a> </li>
<li class="submenu {{$menu_active==2? ' active':''}}"> <a href="#"><i class="icon icon-th-list"></i> <span>Categories</span></a>
<ul>
<li><a href="{{url('/admin/category/create')}}">Add New Category</a></li>
<li><a href="{{route('category.index')}}">List Categories</a></li>
</ul>
</li>
<li class="submenu {{$menu_active==3? ' active':''}}"> <a href="#"><i class="icon icon-th-list"></i> <span>Products</span></a>
<ul>
<li><a href="{{url('/admin/product/create')}}">Add New Products</a></li>
<li><a href="{{route('product.index')}}">List Products</a></li>
</ul>
</li>
<li class="submenu {{$menu_active==3? ' active':''}}"> <a href="#"><i class="icon icon-th-list"></i> <span>Orders</span></a>
<ul>
<li><a href="{{url('/admin/view-orders')}}">list orders</a></li>
</ul>
</li>
</ul>
</div>
<!--sidebar-menu-->