Trying to access array offset on value of type bool in Laravel

  laravel, laravel-blade

I have some problem. I am new to laravel. Here my situation:

I create model:find($id) in my controller and assign variable to get the value from my model:find($id)

My controller:

 public function viewemployerdetails($id)
    {
            $employerdetails = Employer::find($id);  
            
            $empname = $employerdetails ->name;
        
            //different db
            $sql = "SELECT * 
            FROM EMPLOYER
            WHERE EMP_LOGIN_NAME = '$empname'";

            if ($conn) 
            {
                $stmt = db2_exec($conn, $sql);
                $row = db2_fetch_assoc($stmt);

                db2_close($conn);
            }

            return view('viewemployer', compact('employerdetails', 'row'));
    } 

My blade:

<div class="col-9">
   {{$row['EMPLOYER_NAME']}}
</div>

Now it shows error Trying to access array offset on value of type bool at blade.
My suspicion was at controller when I assign $empname = $employerdetails ->name; but I did not know how to solve it. Thank you

Source: Laravel

Leave a Reply