i'm new in YII and I want to set in my constructor something like
public function __construct(Car $car)
{
$this->car= $car;
}
and use my model to peform the query anything like
public function actionIndex()
{
$this->car->select('id','color')->all();
$this->render('index', array( 'car' => $car));
}
If you're using Yii than there is no need to inject $car in controller constructor.
public function actionIndex()
{
$cars = Car::find()->all();
return $this->render('index', [
'cars' => $cars
]);
}