<?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 HomeController extends Controller
{ 
    public function __construct(Request $request) {
        if($request->has('debug') && $request->input('debug') == true) {
            $this->debug = true;			
        }
    }
	
	public function getPromotion(Request $request)
    {      
	    $result = array(
			"type" => "default",
			"ad_image" => "",
			"ad_action" => "",
			"url_screen_name" => ""
		);
		if ($request->has('accessToken') && $request->input('accessToken')!='') {
           // $auth = new authentication();
           $token = $request->input('accessToken');
           if(empty($token)){
			   $code = 2013;
				$message = "User not found.";
			}else{
				$result['type'] = 'AD';
				$result['ad_image'] = 'https://www.steelmint.com/images/manage_banner/images/bannerads/home/2/14052019044001.jpg';
				$result['ad_action'] = 'open_url';
				$result['url_screen_name'] = 'https://www.steelmint.com/report/Indian-Iron-and-Steel-Industry-19-18.php?utm_source=website&utm_medium=mailer&utm_campaign=special_report_fy_18_19';
				$code = 1001;
				$message = "Success";
			}
        }else{
			
			$code = 1001;
			$message = "Success";
		}
	   return new JsonResponse(array("status"=>array("code" => $code, "message" => $message), "data"=> $result));
    }  
	
	public function getPhotoStories(Request $request)
    {      
	    $result = array();
		include_once "/home/steelmin/public_html/api/storage/v2019/photo_pre.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));
    } 
	
	public function upcomingEvents(Request $request)
    {      
	   $result = array();
	   include_once "/home/steelmin/public_html/api/storage/v2019/event_pre.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));
    } 
	
}
