<?php

namespace App\Http\Controllers\Api\v1;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use App\Http\Controllers\AppController;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use App\Models\User;
use App\Models\UserData;
use App\Models\UserDocuments;
use App\Http\Resources\User as UserResource;

class OrderController extends AppController
{
    /**
     * @param Request $request
     * @return JsonResponse
     */
    public function checkout(Request $request){
        try {
            //Validated
            $validate = Validator::make($request->all(), 
            [
                'user_type' => 'required',
                'user_name' => 'required',
              //  'email' => 'required|email|unique:users,email',
               // 'password' => 'required'
            ]);

            if($validate->fails()){
                return response()->json([
                    'status' => false,
                    'message' => 'validation error',
                    'errors' => $validate->errors()
                ], 400);
            }

        } catch (\Throwable $e) {
            return response()->json([
                'status' => false,
                'message' => $e->getMessage()
            ], 500);
        }
    }
    /**
     * @param Request $request
     * @return JsonResponse
     */
    public function place_order(Request $request){
        try {
            //Validated
            $validate = Validator::make($request->all(), 
            [
                'user_type' => 'required',
                'user_name' => 'required',
              //  'email' => 'required|email|unique:users,email',
               // 'password' => 'required'
            ]);

            if($validate->fails()){
                return response()->json([
                    'status' => false,
                    'message' => 'validation error',
                    'errors' => $validate->errors()
                ], 400);
            }

        } catch (\Throwable $e) {
            return response()->json([
                'status' => false,
                'message' => $e->getMessage()
            ], 500);
        }
    }
}
