Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace App\Http\Controllers\Invoice; use App\Http\Controllers\Controller; ..

Decoded Output download

<?php 
 
namespace App\Http\Controllers\Invoice; 
 
use App\Http\Controllers\Controller; 
use App\Http\Requests\PatientBillingInvoiceRequest; 
use App\Models\BedList; 
use App\Models\Patient; 
use App\Models\PatientBillingInvoice; 
use App\Models\Payment; 
use App\Models\Service; 
use App\Models\Setting; 
use App\Models\SmartBilling; 
use App\Repository\PatientBillingInvoiceRepositoryInterface; 
use Carbon\Carbon; 
use Exception; 
use Illuminate\Support\Facades\DB; 
use Mpdf\Mpdf; 
use Yajra\DataTables\Facades\DataTables; 
 
class PatientBillingInvoiceController extends Controller { 
    private $repository; 
 
    public function __construct(PatientBillingInvoiceRepositoryInterface $repository) { 
        $this->repository = $repository; 
    } 
 
    public function index(PatientBillingInvoiceRequest $request) { 
        try { 
 
            if ($request->ajax()) { 
                /*$data = PatientBillingInvoice::latest()->get();*/ 
                $data = SmartBilling::query()->latest()->limit(5000)->get(); 
 
                return DataTables::of($data) 
                    ->addIndexColumn() 
                    ->addColumn('name', function ($row) { 
                        $f_name = $row->patient['first_name'] ?? '-'; 
                        $l_name = $row->patient['last_name'] ?? '-'; 
 
                        return $f_name . ' ' . $l_name; 
                    }) 
                    ->addColumn('pid', function ($row) { 
                        return $row->patient['pid'] ?? 'N/A'; 
                    }) 
                    ->addColumn('total', function ($row) { 
                        return $row->totalAmount ?? 'N/A'; 
                    }) 
                    ->addColumn('vat', function ($row) { 
                        return $row->vat ?? 'N/A'; 
                    }) 
                    ->addColumn('discount', function ($row) { 
                        return $row->discount ?? 'N/A'; 
                    }) 
                    ->addColumn('net_total', function ($row) { 
                        return $row->netPayable ?? 'N/A'; 
                    }) 
                    ->addColumn('action', function ($row) { 
                        $btn = '<a href="' . route('patient-billing-invoice.pdf', $row->invoice_number) . '" class="btn btn-info btn-table"><i class="fa fa-file-pdf-o f-16"></i></a>'; 
 
                        if (in_array(auth()->user()->role_id, ['1', '2'])) { 
                            $btn .= '<a href="' . route('edit.smart-bill', $row->id) . '" class="btn btn-primary btn-table"><i class="icon-pencil-alt f-16"></i></a><button data-bs-toggle="modal" data-bs-target="#danger" onclick="onDelete(this)" id="' . route('patient-billing-invoice.destroy', $row->id) . '" name="delBtn" 
                                                                class="btn btn-danger btn-table f-16 del"><i class="fa fa-trash-o f-16 del"></i></button>'; 
                        } 
 
                        return $btn; 
                    }) 
                    ->rawColumns(['action']) 
                    ->make(true); 
            } 
 
            return view('accountManager.invoice.patient-billing-invoice.index'); 
        } catch (Exception $exception) { 
            return $exception->getMessage(); 
        } 
 
    } 
 
    public function edit($uuid) { 
        $patient        = Patient::where('uuid', $uuid)->with('package')->first(); 
        $beds           = BedList::all(); 
        $bed_assigned   = DB::table('patient_histories')->where('patient_id', $patient->id)->where('category', 'BED')->where('type', 'Assigned')->whereBetween('time', [$patient->admit_date, Carbon::now()])->get(); 
        $bed_unassigned = DB::table('patient_histories')->where('patient_id', $patient->id)->where('category', 'BED')->where('type', 'Unassigned')->whereBetween('time', [$patient->admit_date, Carbon::now()])->get(); 
        $invoice        = PatientBillingInvoice::where('patient_id', $patient->id)->whereBetween('created_at', [$patient->admit_date, Carbon::now()])->first(); 
 
        if ($invoice != null) { 
            $payment = Payment::where('reference_number', 'billing-' . $invoice->invoice_number)->first(); 
        } else { 
            $payment = null; 
        } 
 
        $patient_services = DB::table('patient_services')->where('patient_id', $patient->id)->whereBetween('service_date', [$patient->admit_date, Carbon::now()])->get(); 
        $services         = Service::all(); 
 
        return view('accountManager.invoice.patient-billing-invoice.edit', ['patient' => $patient, 'bed_assigned' => $bed_assigned, 'bed_unassigned' => $bed_unassigned, 'beds' => $beds, 'services' => $services, 'invoice' => $invoice, 'payment' => $payment, 'patient_services' => $patient_services]); 
    } 
 
    public function store(PatientBillingInvoiceRequest $request) { 
        $service_name = []; 
        $service_id   = []; 
 
        if ($request->service_id[0] != null) { 
 
            foreach ($request->service_id as $service) { 
 
                if ($service != null) { 
                    $item = explode('-', $service); 
                    array_push($service_id, $item[0]); 
                    array_push($service_name, $item[1]); 
                } 
 
            } 
 
        } 
 
        $details = []; 
 
        if ($request->package_name != null) { 
 
            foreach ($request->package_name as $key => $title) { 
                array_push($details, [ 
                    'title' => $title, 
                    'price' => $request->package_price[$key], 
                ]); 
            } 
 
        } 
 
        if ($request->bed_name != null) { 
 
            foreach ($request->bed_name as $key => $title) { 
                array_push($details, [ 
                    'title' => $title, 
                    'price' => $request->bed_price[$key], 
                ]); 
            } 
 
        } 
 
        if ($service_name != null) { 
 
            foreach ($service_name as $key => $title) { 
                array_push($details, [ 
                    'title' => $title, 
                    'price' => $request->service_price[$key], 
                ]); 
            } 
 
        } 
 
        try { 
 
            if (auth()->user()->profile != null) { 
                $data = $request->all(); 
                $this->repository->createInvoice($request, $details, $service_id); 
 
                return redirect()->route('patient.index')->with('success', 'Invoice Created Successfully'); 
            } else { 
                throw new Exception('User does not have a name in system'); 
            } 
 
        } catch (Exception $exception) { 
            return redirect()->route('patient-billing-invoice.index')->withErrors(['errors' => $exception->getMessage()]); 
        } 
 
    } 
 
    public function update(PatientBillingInvoiceRequest $request, $uuid) { 
        $service_name = []; 
        $service_id   = []; 
 
        if ($request->service_id[0] != null) { 
 
            foreach ($request->service_id as $service) { 
 
                if ($service != null) { 
                    $item = explode('-', $service); 
                    array_push($service_id, $item[0]); 
                    array_push($service_name, $item[1]); 
                } 
 
            } 
 
        } 
 
        $details = []; 
 
        if ($request->package_name != null) { 
 
            foreach ($request->package_name as $key => $title) { 
                array_push($details, [ 
                    'title' => $title, 
                    'price' => $request->package_price[$key], 
                ]); 
            } 
 
        } 
 
        if ($request->bed_name != null) { 
 
            foreach ($request->bed_name as $key => $title) { 
                array_push($details, [ 
                    'title' => $title, 
                    'price' => $request->bed_price[$key], 
                ]); 
            } 
 
        } 
 
        if ($service_name != null) { 
 
            foreach ($service_name as $key => $title) { 
                array_push($details, [ 
                    'title' => $title, 
                    'price' => $request->service_price[$key], 
                ]); 
            } 
 
        } 
 
        try { 
 
            if (auth()->user()->profile != null) { 
                $data = $request->all(); 
                $this->repository->updateInvoice($uuid, $data, $details, $service_id); 
 
                return redirect()->route('patient-billing-invoice.index')->with('success', 'Billing Invoice Updated Successfully'); 
            } else { 
                throw new Exception('User does not have a name in system'); 
            } 
 
        } catch (Exception $exception) { 
            return $exception->getMessage(); 
 
        } 
 
    } 
 
    public function destroy($uuid) { 
        try { 
            SmartBilling::query()->where('id', $uuid)->delete(); 
 
            return redirect()->route('patient-billing-invoice.index')->with('success', 'Test Invoice Deleted Successfully'); 
        } catch (Exception $exception) { 
            return redirect()->route('patient-billing-invoice.index')->withErrors(['errors' => $exception->getMessage()]); 
        } 
 
    } 
 
    public function pdf($invoiceNumber) { 
        $smart_billing = SmartBilling::query()->with('patient')->where('invoice_number', $invoiceNumber)->first(); 
        $setting       = Setting::find(1); 
 
        return view('accountManager.invoice.patient-billing-invoice.patientBillingInvoicePdf', compact('smart_billing', 'setting')); 
 
        return view('accountManager.invoice.patient-billing-invoice.patientBillingInvoicePdf', compact('smartBill', 'settings')); 
        $mpdf = new Mpdf([ 
            'format'        => 'A4', 
            'margin_top'    => 30, 
            'margin_left'   => 10, 
            'margin_right'  => 10, 
            'margin_bottom' => 10, 
        ]); 
 
        $fileName    = 'Invoice_' . $invoiceNumber . 'pdf'; 
        $html        = iew('accountManager.invoice.patient-billing-invoice.patientBillingInvoicePdf', compact('smartBill', 'settings')); 
        $html        = $html->render(); 
        $stylesheet1 = file_get_contents(public_path('assets/css/testInvoicePdf.css')); 
        $mpdf->SetTitle($invoiceNumber); 
        $mpdf->WriteHTML($stylesheet1, 1); 
        $mpdf->WriteHTML($html, 0); 
        $mpdf->Output($fileName, 'I'); 
    } 
 
} 
 ?>

Did this file decode correctly?

Original Code

<?php

namespace App\Http\Controllers\Invoice;

use App\Http\Controllers\Controller;
use App\Http\Requests\PatientBillingInvoiceRequest;
use App\Models\BedList;
use App\Models\Patient;
use App\Models\PatientBillingInvoice;
use App\Models\Payment;
use App\Models\Service;
use App\Models\Setting;
use App\Models\SmartBilling;
use App\Repository\PatientBillingInvoiceRepositoryInterface;
use Carbon\Carbon;
use Exception;
use Illuminate\Support\Facades\DB;
use Mpdf\Mpdf;
use Yajra\DataTables\Facades\DataTables;

class PatientBillingInvoiceController extends Controller {
    private $repository;

    public function __construct(PatientBillingInvoiceRepositoryInterface $repository) {
        $this->repository = $repository;
    }

    public function index(PatientBillingInvoiceRequest $request) {
        try {

            if ($request->ajax()) {
                /*$data = PatientBillingInvoice::latest()->get();*/
                $data = SmartBilling::query()->latest()->limit(5000)->get();

                return DataTables::of($data)
                    ->addIndexColumn()
                    ->addColumn('name', function ($row) {
                        $f_name = $row->patient['first_name'] ?? '-';
                        $l_name = $row->patient['last_name'] ?? '-';

                        return $f_name . ' ' . $l_name;
                    })
                    ->addColumn('pid', function ($row) {
                        return $row->patient['pid'] ?? 'N/A';
                    })
                    ->addColumn('total', function ($row) {
                        return $row->totalAmount ?? 'N/A';
                    })
                    ->addColumn('vat', function ($row) {
                        return $row->vat ?? 'N/A';
                    })
                    ->addColumn('discount', function ($row) {
                        return $row->discount ?? 'N/A';
                    })
                    ->addColumn('net_total', function ($row) {
                        return $row->netPayable ?? 'N/A';
                    })
                    ->addColumn('action', function ($row) {
                        $btn = '<a href="' . route('patient-billing-invoice.pdf', $row->invoice_number) . '" class="btn btn-info btn-table"><i class="fa fa-file-pdf-o f-16"></i></a>';

                        if (in_array(auth()->user()->role_id, ['1', '2'])) {
                            $btn .= '<a href="' . route('edit.smart-bill', $row->id) . '" class="btn btn-primary btn-table"><i class="icon-pencil-alt f-16"></i></a><button data-bs-toggle="modal" data-bs-target="#danger" onclick="onDelete(this)" id="' . route('patient-billing-invoice.destroy', $row->id) . '" name="delBtn"
                                                                class="btn btn-danger btn-table f-16 del"><i class="fa fa-trash-o f-16 del"></i></button>';
                        }

                        return $btn;
                    })
                    ->rawColumns(['action'])
                    ->make(true);
            }

            return view('accountManager.invoice.patient-billing-invoice.index');
        } catch (Exception $exception) {
            return $exception->getMessage();
        }

    }

    public function edit($uuid) {
        $patient        = Patient::where('uuid', $uuid)->with('package')->first();
        $beds           = BedList::all();
        $bed_assigned   = DB::table('patient_histories')->where('patient_id', $patient->id)->where('category', 'BED')->where('type', 'Assigned')->whereBetween('time', [$patient->admit_date, Carbon::now()])->get();
        $bed_unassigned = DB::table('patient_histories')->where('patient_id', $patient->id)->where('category', 'BED')->where('type', 'Unassigned')->whereBetween('time', [$patient->admit_date, Carbon::now()])->get();
        $invoice        = PatientBillingInvoice::where('patient_id', $patient->id)->whereBetween('created_at', [$patient->admit_date, Carbon::now()])->first();

        if ($invoice != null) {
            $payment = Payment::where('reference_number', 'billing-' . $invoice->invoice_number)->first();
        } else {
            $payment = null;
        }

        $patient_services = DB::table('patient_services')->where('patient_id', $patient->id)->whereBetween('service_date', [$patient->admit_date, Carbon::now()])->get();
        $services         = Service::all();

        return view('accountManager.invoice.patient-billing-invoice.edit', ['patient' => $patient, 'bed_assigned' => $bed_assigned, 'bed_unassigned' => $bed_unassigned, 'beds' => $beds, 'services' => $services, 'invoice' => $invoice, 'payment' => $payment, 'patient_services' => $patient_services]);
    }

    public function store(PatientBillingInvoiceRequest $request) {
        $service_name = [];
        $service_id   = [];

        if ($request->service_id[0] != null) {

            foreach ($request->service_id as $service) {

                if ($service != null) {
                    $item = explode('-', $service);
                    array_push($service_id, $item[0]);
                    array_push($service_name, $item[1]);
                }

            }

        }

        $details = [];

        if ($request->package_name != null) {

            foreach ($request->package_name as $key => $title) {
                array_push($details, [
                    'title' => $title,
                    'price' => $request->package_price[$key],
                ]);
            }

        }

        if ($request->bed_name != null) {

            foreach ($request->bed_name as $key => $title) {
                array_push($details, [
                    'title' => $title,
                    'price' => $request->bed_price[$key],
                ]);
            }

        }

        if ($service_name != null) {

            foreach ($service_name as $key => $title) {
                array_push($details, [
                    'title' => $title,
                    'price' => $request->service_price[$key],
                ]);
            }

        }

        try {

            if (auth()->user()->profile != null) {
                $data = $request->all();
                $this->repository->createInvoice($request, $details, $service_id);

                return redirect()->route('patient.index')->with('success', 'Invoice Created Successfully');
            } else {
                throw new Exception('User does not have a name in system');
            }

        } catch (Exception $exception) {
            return redirect()->route('patient-billing-invoice.index')->withErrors(['errors' => $exception->getMessage()]);
        }

    }

    public function update(PatientBillingInvoiceRequest $request, $uuid) {
        $service_name = [];
        $service_id   = [];

        if ($request->service_id[0] != null) {

            foreach ($request->service_id as $service) {

                if ($service != null) {
                    $item = explode('-', $service);
                    array_push($service_id, $item[0]);
                    array_push($service_name, $item[1]);
                }

            }

        }

        $details = [];

        if ($request->package_name != null) {

            foreach ($request->package_name as $key => $title) {
                array_push($details, [
                    'title' => $title,
                    'price' => $request->package_price[$key],
                ]);
            }

        }

        if ($request->bed_name != null) {

            foreach ($request->bed_name as $key => $title) {
                array_push($details, [
                    'title' => $title,
                    'price' => $request->bed_price[$key],
                ]);
            }

        }

        if ($service_name != null) {

            foreach ($service_name as $key => $title) {
                array_push($details, [
                    'title' => $title,
                    'price' => $request->service_price[$key],
                ]);
            }

        }

        try {

            if (auth()->user()->profile != null) {
                $data = $request->all();
                $this->repository->updateInvoice($uuid, $data, $details, $service_id);

                return redirect()->route('patient-billing-invoice.index')->with('success', 'Billing Invoice Updated Successfully');
            } else {
                throw new Exception('User does not have a name in system');
            }

        } catch (Exception $exception) {
            return $exception->getMessage();

        }

    }

    public function destroy($uuid) {
        try {
            SmartBilling::query()->where('id', $uuid)->delete();

            return redirect()->route('patient-billing-invoice.index')->with('success', 'Test Invoice Deleted Successfully');
        } catch (Exception $exception) {
            return redirect()->route('patient-billing-invoice.index')->withErrors(['errors' => $exception->getMessage()]);
        }

    }

    public function pdf($invoiceNumber) {
        $smart_billing = SmartBilling::query()->with('patient')->where('invoice_number', $invoiceNumber)->first();
        $setting       = Setting::find(1);

        return view('accountManager.invoice.patient-billing-invoice.patientBillingInvoicePdf', compact('smart_billing', 'setting'));

        return view('accountManager.invoice.patient-billing-invoice.patientBillingInvoicePdf', compact('smartBill', 'settings'));
        $mpdf = new Mpdf([
            'format'        => 'A4',
            'margin_top'    => 30,
            'margin_left'   => 10,
            'margin_right'  => 10,
            'margin_bottom' => 10,
        ]);

        $fileName    = 'Invoice_' . $invoiceNumber . 'pdf';
        $html        = \view('accountManager.invoice.patient-billing-invoice.patientBillingInvoicePdf', compact('smartBill', 'settings'));
        $html        = $html->render();
        $stylesheet1 = file_get_contents(public_path('assets/css/testInvoicePdf.css'));
        $mpdf->SetTitle($invoiceNumber);
        $mpdf->WriteHTML($stylesheet1, 1);
        $mpdf->WriteHTML($html, 0);
        $mpdf->Output($fileName, 'I');
    }

}

Function Calls

None

Variables

None

Stats

MD5 25fe17829674da77ca12e33eace50040
Eval Count 0
Decode Time 68 ms