Undefined property: stdClass::$title

Updated at 21-Aug-2021, By samar

Undefined property: stdClass::$title

In this session, we are going to try to solve the "Undefined property: stdClass::$title" puzzle by using the computer language.

You are trying to access the undefine property:: stdClass::$title in laravel view file. Just define the key and value to the object which you are trying to access in your view file in laravel. In my case, I did not define the title property and try to access it.
  • Change array to object in controller and access in view file in laravel

    //routes\web.php
    Route::get('/array-to-object', function(){
        $array = array('title' => 'hello world');
        $object = (object)$array;
        return view('index')->with(compact('object'));
    });
    
    //resources\views\index.blade.php
    {{ $object->title }}
    

Back to code snippet queries related laravel