<?php

use App\vipbooking;
use App\Deal;
use App\Event;
use App\hotelform;
$lastId = hotelform::get()->last();
$lastinvoice = hotelform::where('id', $lastId->id)->get();
foreach ($lastinvoice as $inv) {
    $leadcode = $inv->leadcode;
    $token = $inv['token'];
    $token1 = str_random(30);
}
$details = Deal::where('leadcode', $leadcode)->get();
foreach ($details as $lead) {
    $eventc = $lead->Eventcode;
}
$event = Event::where('eventcode', $eventc)->get();
foreach ($event as $eve) {
}
?>
	<p><b>Dear {{$inv->clientname}}	</b></p>								
										
	<p>We thank  <b>{{$lead->Companyname}} </b>for giving us an opportunity to serve you at our initiative <b>{{$lead->Eventname}}</b>  to be held on <b>{{$eve->date}}</b> at <b>{{$eve->city}},{{$eve->country}}</b>								
	As part of the confirmation process you need to fill up a Service booking  form.	</p>								
										
	<p>Please follow the link to register for the initiative:</p>	


	<p>Service  Booking Form Link : {{url('form/serviceform/'.$token."===".$token1)}} </p>									
										
 public function getServiceform($token1)
 {
     $status = 0;
     $token = explode('===', $token1);
     $lead_id = hotelform::where('token', $token[0])->get();
     // dd($lead_id);
     foreach ($lead_id as $lead) {
         $leadcode = $lead->leadcode;
         if ($lead->token == $token[0]) {
             $status = 1;
         }
     }
     //dd($dealtype);
     if ($status == 1) {
         $dealtype = Deal::where('leadcode', $leadcode)->get();
         foreach ($dealtype as $dealt) {
             $evcode = $dealt->Eventcode;
             # code...
         }
         $vip = vipbooking::where('leadcode', $leadcode)->max('id');
         $event = Event::where('eventcode', $evcode)->get();
         $leadsheet = leadsheet::where('leadcode', $leadcode)->get();
         $benefits = benefits::where('leadcode', $leadcode)->get();
         return View('form/serviceform')->with(array('lead_id' => $lead_id, 'dealtype' => $dealtype, 'event' => $event, 'leadsheet' => $leadsheet, 'benefits' => $benefits, 'vip' => $vip));
     } else {
         echo 'token expired';
     }
 }