<?php
namespace App\Http\Controllers\API;

use App\Models\User;
use Illuminate\Http\Request;
use App\Http\Controllers\AppBaseController;
use InfyOm\Generator\Criteria\LimitOffsetCriteria;
use App\Http\Controllers\API\Criteria\OrderbyPositionCriteria;
use Prettus\Repository\Criteria\RequestCriteria;
use Response;
use App\Http\Resources\User\UserResource;
use App\Http\Resources\ApiResourceCollection;
use Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Log;
use Carbon\Carbon;
/**
 * Class DemoController
 * @package App\Http\Controllers\API
 */

class UserAPIController extends AppBaseController
{
    

    // private function getValidation($input){
    //     return Validator::make($input, [
    //         'dob' => 'nullable|date',
    //         'gender' => 'nullable|in:MALE,FEMALE',
    //     ]);
    // }

    
    public function getUserDetail(){
        $user = Auth::user();
        Log::info('user id '.$user->id);
        return new UserResource($user);
    }


    // public function saveMessage(Request $request){
    //      $input = $request->all();

    //      $validator = Validator::make($input, [
    //          'email' => 'required|email',
    //          'phone' => 'required',
    //          'content' => 'required',
    //          'subject' => 'required'
    //      ]);

    //     if ($validator->fails()) {
    //         return $this->sendValidationError($validator->messages());
    //     }

    //      Message::create([
    //          'email' => $input['email'],
    //          'phone' => $input['phone'],
    //          'subject' => $input['subject'],
    //          'content' => $input['content'],
    //          'created_at' => Carbon::now()
    //      ]); 
    //      return $this->sendResponse('Message saved succesfully');  
    // }

    // public function getBirthdayDetails(){
    //     $user = Auth::user();
    //     if(empty($user)){
    //         return $this->sendValidationError('Login Required');
    //     }

    //     $today = Carbon::today()->toDateString();
    //     $todayDate = Carbon::parse($today);
    //     if(!empty($user->dob)){
    //         $dob = Carbon::parse($user->dob->toDateString());
    //         if($todayDate->equalTo($dob)){
    //             return (new \App\Http\Resources\BirthdayAPIResource($user))->withAd();     
    //         }     
    //     }
       
        
    //     return $this->sendTwoHundredErrorResponse('No Birthday today');  
    // }
}

