本文整理汇总了PHP中backend\models\User::find方法的典型用法代码示例。如果您正苦于以下问题:PHP User::find方法的具体用法?PHP User::find怎么用?PHP User::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backend\models\User
的用法示例。
在下文中一共展示了User::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionSave
public function actionSave()
{
$accountId = $this->getAccountId();
$request = Yii::$app->request;
$operatorId = $request->post('operatorId', '');
$sampleId = $request->post('sampleId', '');
$name = $request->post('name', '');
$quantity = $request->post('quantity', '');
$imgUrl = $request->post('imgUrl', '');
$operator = User::find()->where(['_id' => $operatorId])->one();
if ($operator === null) {
return ['code' => 1309, 'msg' => 'not login'];
}
if ($name == '') {
return ['code' => 1300, 'msg' => 'name not get'];
}
if ($quantity == '') {
return ['code' => 1300, 'msg' => 'quantity not get'];
}
$sample = Sample::find()->where(['_id' => $sampleId])->one();
if ($sampleId == '' || $sample == null) {
$sample = new Sample();
$sample->usedNumber = 0;
}
$sample->name = $name;
$sample->quantity = $quantity;
$sample->operator = $operator->name;
$sample->imgUrl = $imgUrl;
$sample->accountId = $accountId;
$sample->save();
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
return ['code' => 200, 'msg' => 'OK'];
}
示例2: actionStockPedidos
public function actionStockPedidos($idComercio, $idRutaDiaria)
{
$rutaDiaria = RutaDiaria::find()->where(['id' => $idRutaDiaria])->one();
$usuario = User::find()->where(['id' => $rutaDiaria->id_usuario])->one();
$rutaDiariaComercio = $this->findRutaDiariaComercio($idComercio, $idRutaDiaria);
$datosGrillaStock = [];
$datosGrillaPedidos = [];
$i = 0;
if ($rutaDiariaComercio->getStocks()->count() > 0) {
$datosStock = $this->findStockComercio($rutaDiariaComercio->id);
foreach ($datosStock as $stock) {
$nombreProducto = nombreProducto($stock->id_producto);
$datosGrillaStock[$i] = ['tipo' => Yii::t('core', 'Stock'), 'producto' => $nombreProducto, 'cantidad' => $stock->cantidad];
$i++;
}
}
$i = 0;
if ($rutaDiariaComercio->getPedidos()->count() > 0) {
$datosPedidos = $this->findPedidosComercio($rutaDiariaComercio->id);
foreach ($datosPedidos as $pedido) {
$nombrePedido = nombreProducto($pedido->id_producto);
$datosGrillaPedidos[$i] = ['tipo' => Yii::t('core', 'Order'), 'producto' => $nombrePedido, 'cantidad' => $pedido->cantidad];
$i++;
}
}
return $this->render('stockPedidos', ['model' => $rutaDiariaComercio, 'datosGrillaStock' => $datosGrillaStock, 'datosGrillaPedidos' => $datosGrillaPedidos, 'fecha' => $rutaDiaria->fecha, 'usuario' => $usuario->username, 'ruta' => $rutaDiaria->id]);
}
示例3: getUser
/**
* Finds user by [[username]]
*
* @return User|null
*/
public function getUser()
{
if ($this->user === false) {
$this->user = User::find()->andWhere(['or', ['username' => $this->username], ['email' => $this->username]])->one();
}
return $this->user;
}
示例4: actionIndex
public function actionIndex()
{
$query = User::find();
$pagination = new Pagination(['defaultPageSize' => 10, 'totalCount' => $query->count()]);
$countries = $query->orderBy('registerTime DESC')->offset($pagination->offset)->limit($pagination->limit)->all();
return $this->render(Variable::$userMange_view, ['countries' => $countries, 'pagination' => $pagination]);
}
示例5: actionShowTo
public function actionShowTo()
{
\Yii::$app->response->format = Response::FORMAT_JSON;
$id = $_POST['id'];
$todoList = User::find()->where(['id' => $id])->with('todos')->asArray()->one();
//print_r($done);
return $todoList;
}
示例6: isManager
/**
* @return bool
*/
public function isManager()
{
$model = User::find()->where(['username' => $this->username])->andWhere(['status' => 1])->one();
$manager = Manager::find()->where(['user_id' => $model->id, 'status' => 1])->one();
if ($manager) {
return true;
}
return false;
}
示例7: actionUpdate
public function actionUpdate()
{
$model = User::find()->where(['id' => \App::$app->user->identity->getId()])->One();
$model->setScenario('admin-update');
if ($model->load(\App::$app->request->post()) && $model->save()) {
return $this->redirect(['update', 'id' => $model->id]);
} else {
return $this->render('update', ['model' => $model]);
}
}
示例8: actionIndex
/**
* Lists all User models.
* @return mixed
*/
public function actionIndex()
{
if (!$this->is_access('user/index')) {
Yii::$app->session->setFlash('error', $this->errorInfo);
return $this->redirect($this->redirectUrl);
}
$dataProvider = new ActiveDataProvider(['query' => User::find()->where(['<>', 'id', '1']), 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
Yii::$app->view->params['meta_title'] = '管理员列表';
return $this->render('index', ['dataProvider' => $dataProvider]);
}
示例9: search
public function search($params)
{
$query = User::find();
$query->joinWith('authAssignment');
$dataProvider = new ActiveDataProvider(['query' => $query]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['like', 'username', $this->content])->andFilterWhere(['like', 'email', $this->status])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'created_at', $this->created_at])->andFilterWhere(['like', 'updated_at', $this->updated_at])->andFilterWhere(['like', 'authAssignment.item_name', $this->item_name]);
return $dataProvider;
}
示例10: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = User::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'role' => $this->role, 'status' => $this->status, 'truename' => $this->truename, 'realcard' => $this->realcard, 'updated_at' => $this->updated_at]);
$query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'username', $this->truename])->andFilterWhere(['like', 'username', $this->realcard])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['>', 'created_at', strtotime($this->created_at)]);
return $dataProvider;
}
示例11: actionLogin
public function actionLogin()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$username = Yii::$app->request->post('login');
$password = Yii::$app->request->post('password');
$model = User::find()->where(['username' => Yii::$app->request->post('login')])->one();
if (!$model) {
return ['status' => 'error', 'error' => array('login' => 'User with login ' . $username . ' is not registered.')];
} elseif (!Yii::$app->security->validatePassword($password, $model->password_hash)) {
return ['status' => 'error', 'error' => array('password' => 'Password incorrect.')];
} else {
return ['status' => 'success', 'data' => $model];
}
}
示例12: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = User::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'create_time' => $this->create_time]);
$query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'pwd', $this->pwd]);
return $dataProvider;
}
示例13: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = User::find();
$dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
$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(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'dob' => $this->dob, 'gender' => $this->gender]);
$query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'image_path', $this->image_path]);
return $dataProvider;
}
示例14: onSwitch
public function onSwitch()
{
$id = post('user_id');
$name = post('col');
$value = !post($name);
$profile = ProfileModel::where('user_id', $id)->get();
//ensure that user always has a profile
if (!$profile) {
ProfileModel::getFromUser(UserModel::find($id));
$profile = ProfileModel::where('user_id', $id)->get();
}
ProfileModel::where('user_id', $id)->update([$name => $value]);
return ['value' => $value];
}
示例15: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = User::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
$query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'fullname', $this->username])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'email', $this->email]);
return $dataProvider;
}