PHP warning

Attempt to read property "id" on null

C:\www\special\plaza-mercedes\protected\controllers\SiteController.php(160)

148         if(empty($car)) $this->redirect('/');
149         if(empty($model)) $this->redirect('/');
150         Yii::import('application.modules.Car.models.Cars');
151         Yii::import('application.modules.Models.models.Models');
152         $model=Models::model()->cache(Yii::app()->params['CT'])->with('cars:ON')->findByAttributes(
153             [
154                 'slug'=>$model
155             ]
156         );
157         $car=Cars::model()->cache(Yii::app()->params['CT'])->ON()->findByAttributes(
158             [
159                 'order_number'=>$car,
160                 'model_id'=>$model->id,
161             ]
162         );
163         if(isset($car->id))$car->SetViewedCarsCookies($car->id);
164         
165 
166         if(empty($car)) $this->redirect('/');
167         if(empty($model)) $this->redirect('/');
168         $this->render(
169             'frontend/car',
170             [
171                 'car'=>$car,
172                 'model'=>$model,

Stack Trace

#7
+
 C:\www\special\plaza-mercedes\public\index.php(11): CApplication->run()
06 
07 // remove the following line when in production mode
08  defined('YII_DEBUG') or define('YII_DEBUG',true);
09 
10 require_once($yii);
11 Yii::createWebApplication($config)->run();
2024-03-19 13:05:30 nginx/1.25.3 Yii Framework/1.1.15