'comparing two fields and summing another field value laravel

I have three fields am working with, which are user_id, hash, and unit. on my localhost am able to achieve the desired result but on my namecheap server is not working.

cert controller generate the certificate, with correct unit count CertController.php

<?php
    
    namespace App\Http\Controllers;
    
    use Illuminate\Http\Request;
    use App\ShareTransaction;
    use PDF;
    
    class CertController extends Controller
    {
        //  * @return \Illuminate\Http\Response
    
    using data variable am getting the user id, comparing if the hash is same hash then sum unit associated to him/she which worked perfect on local host.
    public function generateCert()
    
    {
        
        $user = \Auth::user();
        $myShare = ShareTransaction::where('user_id', $user->id)->first();
        $data = ShareTransaction::where('user_id', 'hash' == 'hash')->sum('unit');
        $pdf = PDF::loadView('pdf.cert',compact('myShare', 'data'));
    
        //return view('pdf.cert',compact('myShare')); 
        return $pdf->download('certificate.pdf');
    
    }
        
    
    }


    wallet controller
    use App\Kyc;
    use App\Share;
    use App\ShareTransaction;
    use App\Quantity;
    use Illuminate\Http\Request;
    use Illuminate\Support\Facades\Auth;
    use Illuminate\Support\Facades\Session;
    use Illuminate\Support\Facades\DB;
    
    class SharesController extends Controller
    {

    /**
     * Create a new controller instance.
     *
     * @return void
     */
   

     public function __construct()
        {
            $this->middleware('auth');
        }

        public function wallet()
        {
           
            $data = ShareTransaction::where('user_id','hash' == 'hash', )->sum('unit');
            return view('shares.wallet', compact('data'));
             
        }  
    }

wallet.blade.php

    <div class="cards-slider owl-carousel mb-4">
                    <div class="items">
                        <div class="wallet-card bg-success" style="background-image:url('images/pattern/pattern2.png');">
                            <div class="head">
                        
                            <p class="fs-14 text-white mb-0 op6 font-w100">Shares Quantity</p>
                            
                               
                               <span>
                                  
                                   {{$data}} 
                                  
                                   </span>
                             
                           </div>

  

On my namecheap server the code does not work, instead of counting the number of units it shows zero and there is no error i have spotted to have cause the error [![show count zero][1]][1] [1]: https://i.stack.imgur.com/cABnq.jpg



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source