<?php
namespace App\Http\Controllers\API;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\User;
use App\Models\Order;
use Illuminate\Support\Facades\Auth;
use Validator;
use PDO;
class OrderController extends Controller
{
public $successStatus = 200;

public function order_view(){
// return   Order::get();
    return view('order_view');
}

public function order(Request $request){
            $user_id='1';
            $order=new Order;
            if ($request->hasFile('image')) {
                $image = $request->file('image');
                 $image_name = time().'.'.$image->getClientOriginalExtension();
                 $destinationPath = base_path('Uploads');
                 $image->move($destinationPath, $image_name);
                 $order->image=$image_name;
                }
            if ($request->hasFile('voice_note')) {
                $audio = $request->file('voice_note');
                    $audio_name = time().'.'.$audio->getClientOriginalExtension();
                    $destinationPaths = base_path('Uploads');
                    $audio->move($destinationPaths, $audio_name);
                    $order->voice_note=$audio_name;
                }

            $order->user_id=$user_id;
            $order->shop_type=$request->shop_type;
            $order->text=$request->text;
            $order->save();
            return response()->json(['success'=>'Order Successfull Done'],$this->successStatus);

    }


}
