splendidkeen
2 years ago
156
16
Laravel

Undefined Method/Variable problems on my 2nd system

Posted 2 years ago by splendidkeen

Hey everybody, I am not able to address methods I create within my models/controllers on my 2nd system.

For example: Business.php (Model)

 public function getCompanyName(){
        return  $this->company_name;
 }

Controller:

public function getPartnerProfile($company_name){

        $business = Business::where('company_name', $company_name)->first();

        if(!$business){
            abort(404);
        }

        return view('partner.profile.index')
            ->with('company_name', $business);
    }
}

Within view:

{{ $business->getCompanyName() }} 

Error:

Undefined variable: business

Just can't figure it out

Please sign in or create an account to participate in this conversation.