public function getClients($id) { $vendedor = Vendedor::find($id); $client = Client::select('name', 'telephone')->with('vendedor')->where('vendedor_id', '=', $id)->get(); //dd($clients->toArray()); return view("vendedores.clients")->with(array('vendedor' => $vendedor, 'client' => $client)); return redirect()->back(); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Vendedor::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['telefonoVendedor' => $this->telefonoVendedor]); $query->andFilterWhere(['like', 'rutVendedor', $this->rutVendedor])->andFilterWhere(['like', 'nombreVendedor', $this->nombreVendedor]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getVendedorIdvendedor() { return $this->hasOne(Vendedor::className(), ['idvendedor' => 'vendedor_idvendedor']); }
/** * @return \yii\db\ActiveQuery */ public function getVendedors() { return $this->hasMany(Vendedor::className(), ['loja_id' => 'idloja']); }
public function actionListarRemoto($search = null, $id = null) { $out = ['more' => false]; if (!is_null($search)) { $query = new Query(); $query->select('idvendedor AS id, nome AS text')->from('vendedor')->where('nome LIKE "%' . $search . '%"')->limit(200); $command = $query->createCommand(); $data = $command->queryAll(); $out['results'] = array_values($data); } elseif ($id > 0) { $out['results'] = ['id' => $id, 'text' => Vendedor::findOne($id)->nome]; } else { $out['results'] = ['id' => 0, 'text' => 'No matching records found']; } echo Json::encode($out); }