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

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\JsonResponse;

class TrendingController extends Controller
{ 
    public function __construct(Request $request) {
        if($request->has('debug') && $request->input('debug') == true) {
            $this->debug = true;			
        }
    }
	
	public function getTrending(Request $request)
    {      
	    
		$result = array();
		$source = $request->input('source');
				
		if ($request->has('accessToken') && $request->input('accessToken')!='') {
           // $auth = new authentication();
           $token = $request->input('accessToken');
           if(empty($token)){
			    //if($source=='home')
					include_once "/home/steelmin/public_html/api/storage/v2019/trending_pre.php";
		
				$code = 2013;
				$message = "User not found.";
			}else{
				//if($source=='home')
					include_once "/home/steelmin/public_html/api/storage/v2019/trending_post.php";
				$code = 1001;
				$message = "Success";
			}
        }else{		
			//if($source=='home')
			include_once "/home/steelmin/public_html/api/storage/v2019/trending_pre.php";
		
			$code = 1001;
			$message = "Success";
		}
	   return new JsonResponse(array("status"=>array("code" => $code, "message" => $message), "data"=> $result));
    }  
	
	public function getTrendingDetails(Request $request)
    {      
		$result = array();
		include_once "/home/steelmin/public_html/api/storage/v2019/trending_post.php";
		if ($request->has('accessToken') && $request->input('accessToken')!='') {
           // $auth = new authentication();
           $token = $request->input('accessToken');
           if(empty($token)){
			   $code = 2013;
				$message = "User not found.";
			}else{
				$code = 1001;
				$message = "Success";
			}
        }else{
			
			$code = 1001;
			$message = "Success";
		}
	   return new JsonResponse(array("status"=>array("code" => $code, "message" => $message), "data"=> $result));
    } 
	
}
