/home/kueuepay/public_html/app/Http/Controllers/Admin/NFCPayConfigController.php
<?php

namespace App\Http\Controllers\Admin;

use Exception;
use Illuminate\Http\Request;
use App\Models\Admin\NFCPayConfig;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;

class NFCPayConfigController extends Controller
{
    /**
     * Method for nfc pay view page
     * @return view 
     */
    public function index(){
        $page_title     = "NFCPay Configuration";
        $data           = NFCPayConfig::first();

        return view('admin.sections.nfc-pay.index',compact(
            'page_title',
            'data'
        ));
    }
    /**
     * Method for update nfcpay information
     * @param $slug
     * @param Illuminate\Http\Request $request
     */
    public function update(Request $request,$slug){
        $data               = NFCPayConfig::where('slug',$slug)->first();
        if(!$data) return back()->with(['error' => ['Configuration data not found!']]);
        $validator          = Validator::make($request->all(),[
            'name'          => 'required|string',
            'env'           => 'required|string',
            'version'       => 'required',
            'image'         => 'nullable'
        ]);
        if($validator->fails()) return back()->withErrors($validator)->withInput($request->all());
        
        $image = $data->image;
        if($request->hasFile('image')){
            $image = get_files_from_fileholder($request,'image');
            $upload_image = upload_files_from_path_dynamic($image,'nfcpay-config',$data->image);
            $image = $upload_image;
        }
        try{
            $data->update([
                'admin_id'      => auth()->user()->id,
                'name'          => $request->name,
                'image'         => $image,
                'env'           => $request->env,
                'version'       => $request->version
            ]);
        }catch(Exception $e){
           return back()->with(['error' => ['Something went wrong! Please try again.']]); 
        }
        return back()->with(['success'  => ['Information updated successfully.']]);
    }
}
Contact
top

Get in Touch with Us for Any Questions or Support

We’d love to hear from you! Whether you have questions, feedback, or need support, our team is here to help. Reach out to us via email, phone, or visit our office. We’re committed to providing you with exceptional service and ensuring your experience with NFC Pay is seamless and satisfying. Let’s connect!

icon

Our Location

20-22 Wenlock Road, England, N1 7GU
icon

Call us on: +03601 885399

Our office hours Monday–Friday, 9am - 9pm
icon

Email us directly

support@example.com