Current File : /home/itiffy/public_html/app/Http/Controllers/Frontend/FrontController.php
<?php

namespace App\Http\Controllers\Frontend;

use App\Http\Controllers\Controller;
use App\Role;
use App\User;
use App\ContactFormDb;
use App\RequestAQuote;
use App\Transaction;
use App\Gatway;
use App\Metatags;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Mail;
use Illuminate\Support\Facades\Input;
use View;

class FrontController extends Controller
{
    /**
     * Show a list of users
     * @return \Illuminate\View\View
     */
    private $mode;
    private $sellerId;
    private $publishableKey;
    private $privateKey;
    private $gatewayUrl;

    public function __construct(){
        
        $gateway_details=Gatway::find(1);
        //2checkout credentials
       $this->mode=trim($gateway_details->mode); //sandbox,production
        $this->sellerId=trim($gateway_details->account_number);
        $this->publishableKey=trim($gateway_details->publish_key);
        $this->privateKey=trim($gateway_details->private_key);
        if($this->mode=='sandbox'){
            $this->gatewayUrl='https://sandbox.2checkout.com/checkout/api/1/'.$this->sellerId.'/rs/authService';
        }else{
            $this->gatewayUrl='https://www.2checkout.com/checkout/api/1/'.$this->sellerId.'/rs/authService';
        }
        $country_array=array(
                "IND"=>'India',
                "USA"=>'United States',
                "GBR"=>'United Kingdom',
                "CAN"=>'Canada',
                "AUS"=>'Australia',
                "ALA"=>'Åland Islands',
                "AFG"=>'Afghanistan',
                "ALB"=>'Albania',
                "DZA"=>'Algeria',
                "ASM"=>'American Samoa',
                "AND"=>'Andorra',
                "AGO"=>'Angola',
                "AIA"=>'Anguilla',
                "ATA"=>'Antarctica',
                "ATG"=>'Antigua and Barbuda',
                "ARG"=>'Argentina',
                "ARM"=>'Armenia',
                "ABW"=>'Aruba',
                "AUS"=>'Australia',
                "AUT"=>'Austria',
                "AZE"=>'Azerbaijan',
                "BHS"=>'Bahamas',
                "BHR"=>'Bahrain',
                "BGD"=>'Bangladesh',
                "BRB"=>'Barbados',
                "BLR"=>'Belarus',
                "BEL"=>'Belgium',
                "BLZ"=>'Belize',
                "BEN"=>'Benin',
                "BMU"=>'Bermuda',
                "BTN"=>'Bhutan',
                "BOL"=>'Bolivia',
                "BES"=>'Bonaire, Sint Eustatius and Saba',
                "BIH"=>'Bosnia and Herzegovina',
                "BWA"=>'Botswana',
                "BVT"=>'Bouvet Island',
                "BRA"=>'Brazil',
                "IOT"=>'British Indian Ocean Territory',
                "BRN"=>'Brunei Darussalam',
                "BGR"=>'Bulgaria',
                "BFA"=>'Burkina Faso',
                "BDI"=>'Burundi',
                "KHM"=>'Cambodia',
                "CMR"=>'Cameroon',
                "CAN"=>'Canada',
                "CPV"=>'Cape Verde',
                "CYM"=>'Cayman Islands',
                "CAF"=>'Central African Republic',
                "TCD"=>'Chad',
                "CHL"=>'Chile',
                "CHN"=>'China',
                "CXR"=>'Christmas Island',
                "CCK"=>'Cocos (Keeling) Islands',
                "COL"=>'Colombia',
                "COM"=>'Comoros',
                "COG"=>'Congo',
                "COD"=>'Congo, the Democratic Republic of the',
                "COK"=>'Cook Islands',
                "CRI"=>'Costa Rica',
                "CIV"=>'Cote D\'ivoire',
                "HRV"=>'Croatia (Hrvatska)',
                "CYP"=>'Cyprus',
                "CZE"=>'Czech Republic',
                "DNK"=>'Denmark',
                "DJI"=>'Djibouti',
                "DMA"=>'Dominica',
                "DOM"=>'Dominican Republic',
                "ECU"=>'Ecuador',
                "EGY"=>'Egypt',
                "SLV"=>'El Salvador',
                "GNQ"=>'Equatorial Guinea',
                "ERI"=>'Eritrea',
                "EST"=>'Estonia',
                "ETH"=>'Ethiopia',
                "FLK"=>'Falkland Islands (Malvinas)',
                "FRO"=>'Faroe Islands',
                "FJI"=>'Fiji',
                "FIN"=>'Finland',
                "FRA"=>'France',
                "FXX"=>'France, Metropolitan',
                "GUF"=>'French Guiana',
                "PYF"=>'French Polynesia',
                "ATF"=>'French Southern Territories',
                "GAB"=>'Gabon',
                "GMB"=>'Gambia',
                "GEO"=>'Georgia',
                "DEU"=>'Germany',
                "GHA"=>'Ghana',
                "GIB"=>'Gibraltar',
                "GRC"=>'Greece',
                "GRL"=>'Greenland',
                "GRD"=>'Grenada',
                "GLP"=>'Guadeloupe',
                "GUM"=>'Guam',
                "GTM"=>'Guatemala',
                "GGY"=>'Guernsey',
                "GIN"=>'Guinea',
                "GNB"=>'Guinea-Bissau',
                "GUY"=>'Guyana',
                "HTI"=>'Haiti',
                "HMD"=>'Heard Island and Mcdonald Islands',
                "HND"=>'Honduras',
                "HKG"=>'Hong Kong',
                "HUN"=>'Hungary',
                "ISL"=>'Iceland',
                "IND"=>'India',
                "IDN"=>'Indonesia',
                "IRQ"=>'Iraq',
                "IRL"=>'Ireland',
                "IMN"=>'Isle of Man',
                "ISR"=>'Israel',
                "ITA"=>'Italy',
                "JAM"=>'Jamaica',
                "JPN"=>'Japan',
                "JEY"=>'Jersey',
                "JOR"=>'Jordan',
                "KAZ"=>'Kazakhstan',
                "KEN"=>'Kenya',
                "KIR"=>'Kiribati',
                "KOR"=>'Korea, Republic of',
                "KWT"=>'Kuwait',
                "KGZ"=>'Kyrgyzstan',
                "LAO"=>"Lao People\'s Democratic Republic",
                "LVA"=>'Latvia',
                "LBN"=>'Lebanon',
                "LSO"=>'Lesotho',
                "LBR"=>'Liberia',
                "LBY"=>'Libyan Arab Jamahiriya',
                "LIE"=>'Liechtenstein',
                "LTU"=>'Lithuania',
                "LUX"=>'Luxembourg',
                "MAC"=>'Macao',
                "MKD"=>'Macedonia',
                "MDG"=>'Madagascar',
                "MWI"=>'Malawi',
                "MYS"=>'Malaysia',
                "MDV"=>'Maldives',
                "MLI"=>'Mali',
                "MLT"=>'Malta',
                "MHL"=>'Marshall Islands',
                "MTQ"=>'Martinique',
                "MRT"=>'Mauritania',
                "MUS"=>'Mauritius',
                "MYT"=>'Mayotte',
                "MEX"=>'Mexico',
                "FSM"=>'Micronesia, Federated States of',
                "MDA"=>'Moldova, Republic of',
                "MCO"=>'Monaco',
                "MNG"=>'Mongolia',
                "MNE"=>'Montenegro',
                "MSR"=>'Montserrat',
                "MAR"=>'Morocco',
                "MOZ"=>'Mozambique',
                "MMR"=>'Myanmar',
                "NAM"=>'Namibia',
                "NRU"=>'Nauru',
                "NPL"=>'Nepal',
                "NLD"=>'Netherlands',
                "ANT"=>'Netherlands Antilles',
                "NCL"=>'New Caledonia',
                "NZL"=>'New Zealand',
                "NIC"=>'Nicaragua',
                "NER"=>'Niger',
                "NGA"=>'Nigeria',
                "NIU"=>'Niue',
                "NFK"=>'Norfolk Island',
                "MNP"=>'Northern Mariana Islands',
                "NOR"=>'Norway',
                "OMN"=>'Oman',
                "PAK"=>'Pakistan',
                "PLW"=>'Palau',
                "PSE"=>'Palestinian Territory, Occupied',
                "PAN"=>'Panama',
                "PNG"=>'Papua New Guinea',
                "PRY"=>'Paraguay',
                "PER"=>'Peru',
                "PHL"=>'Philippines',
                "PCN"=>'Pitcairn',
                "POL"=>'Poland',
                "PRT"=>'Portugal',
                "PRI"=>'Puerto Rico',
                "QAT"=>'Qatar',
                "REU"=>'Reunion',
                "ROU"=>'Romania',
                "RUS"=>'Russian Federation',
                "RWA"=>'Rwanda',
                "SHN"=>'Saint Helena',
                "KNA"=>'Saint Kitts and Nevis',
                "LCA"=>'Saint Lucia',
                "SPM"=>'Saint Pierre and Miquelon',
                "VCT"=>'Saint Vincent and the Grenadines',
                "WSM"=>'Samoa',
                "SMR"=>'San Marino',
                "STP"=>'Sao Tome and Principe',
                "SAU"=>'Saudi Arabia',
                "SEN"=>'Senegal',
                "SRB"=>'Serbia',
                "SCG"=>'Serbia and Montenegro',
                "SYC"=>'Seychelles',
                "SLE"=>'Sierra Leone',
                "SGP"=>'Singapore',
                "SVK"=>'Slovakia',
                "SVN"=>'Slovenia',
                "SLB"=>'Solomon Islands',
                "SOM"=>'Somalia',
                "ZAF"=>'South Africa',
                "SGS"=>'South Georgia and the South Sandwich Islands',
                "ESP"=>'Spain',
                "LKA"=>'Sri Lanka',
                "SUR"=>'Suriname',
                "SJM"=>'Svalbard and Jan Mayen Islands',
                "SWZ"=>'Swaziland',
                "SWE"=>'Sweden',
                "CHE"=>'Switzerland',
                "TWN"=>'Taiwan',
                "TJK"=>'Tajikistan',
                "TZA"=>'Tanzania, United Republic of',
                "THA"=>'Thailand',
                "TLS"=>'Timor-Leste',
                "TGO"=>'Togo',
                "TKL"=>'Tokelau',
                "TON"=>'Tonga',
                "TTO"=>'Trinidad and Tobago',
                "TUN"=>'Tunisia',
                "TUR"=>'Turkey',
                "TKM"=>'Turkmenistan',
                "TCA"=>'Turks and Caicos Islands',
                "TUV"=>'Tuvalu',
                "UGA"=>'Uganda',
                "UKR"=>'Ukraine',
                "ARE"=>'United Arab Emirates',
                "GBR"=>'United Kingdom',
                "USA"=>'United States',
                "UMI"=>'United States Minor Outlying Islands',
                "URY"=>'Uruguay',
                "UZB"=>'Uzbekistan',
                "VUT"=>'Vanuatu',
                "VAT"=>'Vatican City State (Holy See)',
                "VEN"=>'Venezuela',
                "VNM"=>'Viet Nam',
                "VGB"=>'Virgin Islands, British',
                "VIR"=>'Virgin Islands, U.S.',
                "WLF"=>'Wallis and Futuna Islands',
                "ESH"=>'Western Sahara',
                "YEM"=>'Yemen',
                "YUG"=>'Yugoslavia',
                "ZAR"=>'Zaire',
                "ZMB"=>'Zambia',
                "ZWE"=>'Zimbabwe'
            );
        View::share('gateway_credentials', array('mode'=>$this->mode,'sellerId'=>$this->sellerId,'publishableKey'=>$this->publishableKey,'privateKey'=>$this->privateKey,'country_array'=>$country_array));
    } 
     
    public function index(){
        $blog_url=url('/blog/wp-json/wp/v2/posts?_embed&per_page=1');
        $ch = curl_init($blog_url);                                                                      
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");                                                                                                                                      
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
            curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
                'Content-Type: application/json')                                                                                                                                                     
            );                                                                                                                   
                                                                                                                             
            $result = curl_exec($ch);
        
            $blog=json_decode($result); 
            $feature_image= 'wp:featuredmedia';
            if(isset($blog[0]->_embedded->$feature_image[0]->media_details->sizes->custom_featured_image->source_url)){
                $image_url=$blog[0]->_embedded->$feature_image[0]->media_details->sizes->custom_featured_image->source_url;
            }else{
                $image_url='';
            }
            //======Get meta details======//
            $metatags=Metatags::where('slug','home')->first();
            $title=$metatags->title;
            $description=$metatags->description;
            $keywords=$metatags->keywords;
            //======End=========//
            return view('frontend.index', compact('title','description','keywords','blog','image_url'));
    }

    public function about_us(){ 
        //======Get meta details======//
        $metatags=Metatags::where('slug','about_us')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.about_us', compact('title','description','keywords'));
    }
    public function terms_and_conditions(){ 
        //======Get meta details======//
        $metatags=Metatags::where('slug','terms_and_conditions')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.terms_and_conditions', compact('title','description','keywords'));
    }
    public function faqs(){ 
        //======Get meta details======//
        $metatags=Metatags::where('slug','faqs')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.faqs', compact('title','description','keywords'));
    }
    public function refund_and_cancellation_policy(){ 
        //======Get meta details======//
        $metatags=Metatags::where('slug','refund_and_cancellation_policy')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.refund_and_cancellation_policy', compact('title','description','keywords'));
    }
    public function privacy_policy(){ 
        //======Get meta details======//
        $metatags=Metatags::where('slug','privacy_policy')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.privacy_policy', compact('title','description','keywords'));
    }
    public function sitemap(){ 
        //======Get meta details======//
        $metatags=Metatags::where('slug','sitemap')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.sitemap', compact('title','description','keywords'));
    }

    public function paypal_success(Request $request){ 
        $paypal_response=$request->all();
        if(isset($paypal_response['txn_id']) && ($paypal_response['payment_status']=='Pending' || $paypal_response['payment_status']=='Completed')){
            $payment_status=1;
            $status="Success";
        }else{
            $payment_status=0;
            $status="Failed";
        }
        //======Get meta details======//
        $metatags=Metatags::where('slug','sitemap')->first();
        $title=$metatags->title.' '.$status;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        $title='Paypal Payment '.$status;
        return view('frontend.paypal_success', compact('title','description','keywords','payment_status'));
    }

    public function contact_us(Request $request){ 
        if ($request->isMethod('post')) {
           $data=$request->all();
           ContactFormDb::create($data) ;
           //=====mail send to admin=========//
            $admin_email=User::where('role_id',1)->first();
            if(count($admin_email)){
             $admin_users_email=$admin_email->email;
            }else{
            $admin_users_email='info@itiffy.com';
            }
            $user_name = $data['name'];
            $user_email = $data['email'];
            $user_phone =$data['phone_number'];
            $user_domain =$data['domain_name'];
            $comment = $data['comment'];
            $sent = Mail::send('frontend.mail_templates.contact_mail', array('fullname'=>$user_name,'email'=>$user_email,'phone_number'=>$user_phone,'domain_name'=>$user_domain,'comment'=>$comment), 
             function($message) use ($admin_users_email, $user_email,$user_name,$admin_email)
             {
             $message->from($user_email,'Itiffy');
             $message->to($admin_users_email, $admin_email->name)->subject('Contact Us');
             });
           return redirect()->route('contact-us')->withSuccess('Thanks for contacting us, we will get back to you shortly.');
        }
        //======Get meta details======//
        $metatags=Metatags::where('slug','contact_us')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.contact_us', compact('title','description','keywords'));
    }

    public function services(){ 
        //======Get meta details======//
        $metatags=Metatags::where('slug','services')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.services', compact('title','description','keywords'));
    }

    public function graphic_designing(){ 
        //======Get meta details======//
        $metatags=Metatags::where('slug','graphic_designing')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.graphic_designing', compact('title','description','keywords'));
    }
    public function web_design_and_development(){
        //======Get meta details======//
        $metatags=Metatags::where('slug','web_design_and_development')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.web-design-and-development', compact('title','description','keywords')); 
    }
    public function web_development(){
        //======Get meta details======//
        $metatags=Metatags::where('slug','web_development')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.web-development', compact('title','description','keywords')); 
    }
    public function mobile_apps_development(){
        //======Get meta details======//
        $metatags=Metatags::where('slug','mobile_apps_development')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.mobile-apps-development', compact('title','description','keywords')); 
    }
    public function seo(){
        //======Get meta details======//
        $metatags=Metatags::where('slug','seo')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.seo', compact('title','description','keywords')); 
    }
    public function local_seo(){
         //======Get meta details======//
        $metatags=Metatags::where('slug','local_seo')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.local-seo', compact('title','description','keywords')); 
    }

    public function request_a_quote(Request $request){ 
        if ($request->isMethod('post')) {
           $data=$request->all();
           if(Input::file('attachment')){
            if (Input::file('attachment')->isValid()) {
                $destinationPath = 'public/uploads'; // upload path
                //$thumbPath = 'uploads/thumb';
                $extension = Input::file('attachment')->getClientOriginalExtension(); // getting image extension
                $fileName = rand(11111,99999).'.'.$extension; // renameing image
                if(Input::file('attachment')->move($destinationPath, $fileName)){ // uploading file to given path
                //Image::make($destinationPath.'/'.$fileName)->resize(100, 100)->save($thumbPath.'/'.$fileName);
                $data['attachment']=$fileName;
                }
              }
          }
           RequestAQuote::create($data) ;
           //=====mail send to admin=========//
            $admin_email=User::where('role_id',1)->first();
            if(count($admin_email)){
             $admin_users_email=$admin_email->email;
            }else{
            $admin_users_email='info@itiffy.com';
            }
            $user_name = $data['full_name'];
            $user_email = $data['email'];
            $user_phone =$data['phone_number'];
            $user_address=$data['address'];
            $user_domain =$data['domain_name'];
            $user_hosting = $data['do_you_have_hosting'];
            $comment = $data['project_description'];
            $sent = Mail::send('frontend.mail_templates.requesr_a_quote', array('fullname'=>$user_name,'email'=>$user_email,'phone_number'=>$user_phone,'domain_name'=>$user_domain,'comment'=>$comment,'address'=>$user_address,'hosting'=>$user_hosting),
            function($message) use ($admin_users_email, $user_email,$user_name,$admin_email,$data)
            {
            $message->from($user_email,'Itiffy');
            $message->to($admin_users_email, $admin_email->name)->subject('Request A Quote');
            if(Input::file('attachment')){
                $message->attach(public_path('uploads').'/'.$data['attachment'], [
            'as' => $data['attachment'], 
           // 'mime' => Input::file('attachment')->getMimeType()
                ]);
            }
            });
           return redirect()->route('request-a-quote')->withSuccess('Thanks for contacting us, we will get back to you shortly.');
        }
        //======Get meta details======//
        $metatags=Metatags::where('slug','request_a_quote')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.request-a-quote', compact('title','description','keywords'));
    }

    public function portfolio_cms(){
        //======Get meta details======//
        $metatags=Metatags::where('slug','portfolio_cms')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.portfolio-cms', compact('title','description','keywords')); 
    }

    public function portfolio_ecommerce(){
        //======Get meta details======//
        $metatags=Metatags::where('slug','portfolio_ecommerce')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.portfolio-ecommerce', compact('title','description','keywords')); 
    }

    public function portfolio_crm(){
        //======Get meta details======//
        $metatags=Metatags::where('slug','portfolio_crm')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.portfolio-crm', compact('title','description','keywords')); 
    }

    public function portfolio_social_media(){
        //======Get meta details======//
        $metatags=Metatags::where('slug','portfolio_social_media')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.portfolio-social-media', compact('title','description','keywords')); 
    }

    public function portfolio_landingpage(){
        //======Get meta details======//
        $metatags=Metatags::where('slug','portfolio_landingpage')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.portfolio-landingpage', compact('title','description','keywords')); 
    }

     public function portfolio_mobile_app(){
        //======Get meta details======//
        $metatags=Metatags::where('slug','portfolio_mobile_app')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.portfolio-mobile-app', compact('title','description','keywords')); 
    }
    public function portfolio_graphic_logo(){
        //======Get meta details======//
        $metatags=Metatags::where('slug','portfolio_graphic_logo')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.portfolio-graphic-logo', compact('title','description','keywords')); 
    }
    public function portfolio_graphic_brochure(){
        //======Get meta details======//
        $metatags=Metatags::where('slug','portfolio_graphic_brochure')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.portfolio-graphic-brochure', compact('title','description','keywords')); 
    }
    public function portfolio_graphic_advertisement(){
        //======Get meta details======//
        $metatags=Metatags::where('slug','portfolio_graphic_advertisement')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.portfolio-graphic-advertisement', compact('title','description','keywords')); 
    }
    public function portfolio_graphic_social(){
        //======Get meta details======//
        $metatags=Metatags::where('slug','portfolio_graphic_social')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.portfolio-graphic-social', compact('title','description','keywords')); 
    }
    public function dedicated_hire(){
        //======Get meta details======//
        $metatags=Metatags::where('slug','dedicated_hire')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.dedicated-hire', compact('title','description','keywords')); 
    }
    public function hosting(){
         //======Get meta details======//
        $metatags=Metatags::where('slug','hosting')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.hosting', compact('title','description','keywords')); 
    }
    public function website_packages(){
        //======Get meta details======//
        $metatags=Metatags::where('slug','website_packages')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
        return view('frontend.website-packages', compact('title','description','keywords')); 
    }

    public function payment_create(Request $request){
        $message="";
        if ($request->isMethod('post')) {
            $data=$request->all();
           $data_card = array (
                  'sellerId' => $this->sellerId,
                  'privateKey' => $this->privateKey,
                  'merchantOrderId' => 'Dedicated hire for '.$data['hires_for'],
                  'token' => $data['token'],
                  'currency' => $data['currency_code'],
                  'total' => $data['price'],
                  'billingAddr' => 
                  array (
                    'name' => $data['name'],
                    'addrLine1' => $data['address'],
                    'city' => $data['city'],
                    'state' => $data['state'],
                    'zipCode' => $data['zip_code'],
                    'country' => $data['country'],
                    'email' => $data['email'],
                    'phoneNumber' => $data['phone_number'],
                  ),
                );
            $data_string = json_encode($data_card);                                                                                   
                                                                                                                     
            $ch = curl_init($this->gatewayUrl);                                                                      
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                  
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
            curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
                'Content-Type: application/json',                                                                                
                'Content-Length: ' . strlen($data_string))                                                                       
            );                                                                                                                   
                                                                                                                             
            $result = curl_exec($ch);
            $result=json_decode($result); 
            if(isset($result->response) && $result->response->responseCode=='APPROVED'){
                $data['transaction_id']= $result->response->transactionId; 
                $data['order_number']  = $result->response->orderNumber;
                Transaction::create($data) ;    
                $payment_status=1;
                $status="Success";
                //=====mail send to admin=========//
                $admin_email=User::where('role_id',1)->first();
                if(count($admin_email)){
                 $admin_users_email=$admin_email->email;
                }else{
                $admin_users_email='info@itiffy.com';
                }
                $sent = Mail::send('frontend.mail_templates.payment-received-for-admin',array('data'=>$data) ,
                function($message) use ($admin_users_email,$admin_email,$data)
                {
                $message->from($data['email'],'Itiffy');
                $message->to($admin_users_email, $admin_email->name)->subject('Payment Received');
                });
                //END//
                 //=====mail send to user=========//
                $admin_email=User::where('role_id',1)->first();
                if(count($admin_email)){
                 $admin_users_email=$admin_email->email;
                }else{
                $admin_users_email='info@itiffy.com';
                }
                $sent = Mail::send('frontend.mail_templates.payment-received',array('data'=>$data) ,
                function($message) use ($admin_users_email,$data)
                {
                $message->from($admin_users_email,'Itiffy');
                $message->to($data['email'], $data['name'])->subject('Thanks for your payment');
                });
                //END//
            }else{
                $payment_status=0;
                $status="Failed";
                if(isset($result->exception->errorMsg)){
                	$message=$result->exception->errorMsg;
                }
                
            }
            $title='Payment '.$status;
            }
            else{
                $payment_status=0;
                $status="Failed";
                $title='Payment '.$status;
                
                
            }
            return view('frontend.paypal_success', compact('title','description','keywords','payment_status','message')); 
        }
        public function express(){
            //======Get meta details======//
        $metatags=Metatags::where('slug','express')->first();
        $title=$metatags->title;
        $description=$metatags->description;
        $keywords=$metatags->keywords;
        //======End=========//
            return view('frontend.express', compact('title','description','keywords')); 
        }
}