<?php

use App\vipbooking;
use App\Deal;
use App\Event;
$lastId = vipbooking::get()->last();
$lastinvoice = vipbooking::where('id', $lastId->id)->get();
foreach ($lastinvoice as $inv) {
    $leadcode = $inv->leadcode;
    $token = $inv['confirmation_code'];
    $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 registration form.	</p>								
										
	<p>Please find the attachment of delegate confirmation form</p>	


							
										
	<p>Thanks and Regards</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';
     }
 }
<?php

use App\vipbooking;
use App\Deal;
use App\Event;
foreach ($selectdata as $data) {
    $email = $data->email;
    $empid = $data->empid;
    $leadcode = $data->leadcode;
    $dealid = $data->deal_id;
    $rcom = $data->rcomments;
}
$lastId = vipbooking::get()->where('leadcode', $leadcode)->last();
$lastinvoice = vipbooking::where('id', $lastId->id)->where('id', DB::raw("(select max(`id`) from vipbooking)"))->get();
foreach ($lastinvoice as $inv) {
    $leadcode = $inv->leadcode;
    $token = $inv['confirmation_code'];
    $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 regret  to inform that  your registration form for our initiative <b>{{$lead->Eventname}}</b>  is declined due to following reason;									
 public function postRejectvip(Request $request)
 {
     $post = Input::get();
     //dd($post);
     $vipid = Input::get('rejid');
     $leadcode = Input::get('leadcode');
     $email = Input::get('email');
     $status = Input::get('reject_status');
     $rcm = Input::get('reject_comment');
     $i = vipbooking::where('id', $vipid)->update(array('status' => $status, 'rcomments' => $rcm));
     $i = delegatedealinfo::where('leadcode', $leadcode)->update(array('vip' => 'NULL'));
     $getdetails = DB::table('deal')->join('vipbooking', 'deal.leadcode', '=', 'vipbooking.leadcode')->where('deal.leadcode', '=', $leadcode)->where('vipbooking.leadcode', '=', $leadcode)->get();
     foreach ($getdetails as $get) {
         $email = $get->email;
     }
     // dd($confirmation_code);
     $subject = "hi";
     if ($i > 0) {
         $subject = 'hi';
         Mail::send('emails.booking', ['Booking' => 'sdsad'], function ($message) use($subject, $email) {
             // note: if you don't set this, it will use the defaults from config/mail.php
             $message->from('*****@*****.**', 'IDE Consulting Services Pvt Ltd');
             $message->to($email)->subject($subject);
         });
         $request->session()->flash('alert-success', 'Invoice has been sent to client !');
         return Redirect::back();
     }
     //$request->session()->flash('alert-success', 'VIP Booking Form has been sent to client');
     //return Redirect::back();
 }
 public function getViewdetails($dealid)
 {
     $leadsheet = leadsheet::where('leadcode', $dealid)->get();
     // dd($leadsheet);
     $varr = Auth::user()->empid;
     $evarr = User::where('empid', $varr)->get();
     $emp = Employee::where('emp_ide_id', $varr)->get();
     foreach ($emp as $empp) {
         $fromemail = $empp->email;
     }
     // dd($fromemail);
     $lead_id = Deal::where('leadcode', $dealid)->get();
     foreach ($lead_id as $editlead) {
         $dealid = $editlead->Id;
         $leadcode = $editlead->leadcode;
     }
     // dd($dealid);
     $editlead = vipbooking::where('leadcode', $leadcode)->where('deal_id', $dealid)->where('id', DB::raw("(select max(`id`) from vipbooking)"))->get();
     $delegateinfo = delegatedealinfo::where('leadcode', $leadcode)->where('deal_id', $dealid)->get();
     //dd(count($editlead));
     return View('initiator/viewdetails')->with(array('lead_id' => $lead_id, 'editlead' => $editlead, 'emp' => $emp, 'delegateinfo' => $delegateinfo, 'leadsheet' => $leadsheet));
 }
 public function getUpdatedeal($leadcode)
 {
     // dd($leadcode);
     $varr = Auth::user()->empid;
     $evarr = User::where('empid', $varr)->get();
     $edetails = Employee::where('emp_ide_id', $varr)->get();
     $deal = Deal::where('leadcode', $leadcode)->get();
     $vip = vipbooking::where('leadcode', $leadcode)->get();
     $benefits = benefits::where('leadcode', $leadcode)->get();
     return view('reviewer/updatedeal')->with(array('vip' => $vip, 'benefits' => $benefits, 'edetails' => $edetails, 'deal' => $deal));
 }