<?php

namespace App\Http\Controllers;

use App\Models\orderdone;
use Illuminate\Http\Request;
use App\Models\checkout;
use Illuminate\Support\Facades\DB;
use App\Models\order_toppings_complete;
use App\Models\product_ckeckout_attr;
use Carbon\Carbon;


class OrderdoneController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        if ($request->session()->has('FRONT_USER_LOGIN')) {
            $uid = $request->session()->get('FRONT_USER_ID');
            $user_type = "Reg";
        } else {
            $uid = getUserTempId();
            $user_type = "Not-Reg";
        }

        //dd($request->session()->all());
        // if ($request->session()->has('id')) {
        //     echo $request->session()->get('my_name');
        // } else {
        //     echo 'No data in the session';
        // }
        $getsessionid = $request->session()->get('checkouts_id');

        $result['order_Completes'] = checkout::query()->where('user_id', $uid)->where('id', $getsessionid)->get();

        //  $result['order_Completes'] =
        //     DB::table('checkouts')
        //      ->leftJoin('add_to_carts','add_to_carts.checkouts_id', '=', 'checkouts.id')
        //      ->leftJoin('insert_toppings', 'add_to_carts.id', '=', 'insert_toppings.add_to_cart_id')
        //     ->get();

        return view('front/thankyou')->with($result);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Models\orderdone  $orderdone
     * @return \Illuminate\Http\Response
     */
    public function show(orderdone $orderdone)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Models\orderdone  $orderdone
     * @return \Illuminate\Http\Response
     */
    public function edit(orderdone $orderdone)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\orderdone  $orderdone
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, orderdone $orderdone)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Models\orderdone  $orderdone
     * @return \Illuminate\Http\Response
     */
    public function destroy(orderdone $orderdone)
    {
        //
    }
}
