本文整理汇总了PHP中app\models\Contact::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::find方法的具体用法?PHP Contact::find怎么用?PHP Contact::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Contact
的用法示例。
在下文中一共展示了Contact::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Contact::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(['id' => $this->id, 'phone' => $this->phone]);
$query->andFilterWhere(['like', 'company', $this->company])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'postal', $this->postal])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'lat', $this->lat])->andFilterWhere(['like', 'lng', $this->lng]);
return $dataProvider;
}
示例2: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Contact::find();
$dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['regdate' => 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, 'usebefore' => $this->usebefore, 'receiveinfo' => $this->receiveinfo, 'regdate' => $this->regdate, 'status' => $this->status]);
$query->andFilterWhere(['like', 'fullname', $this->fullname])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'nation', $this->nation])->andFilterWhere(['like', 'message', $this->message])->andFilterWhere(['like', 'knwthrough', $this->knwthrough]);
return $dataProvider;
}
示例3: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Contact::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(['id' => $this->id, 'floor' => $this->floor, 'room' => $this->room, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
$query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'second_name', $this->second_name])->andFilterWhere(['like', 'middle_name', $this->middle_name])->andFilterWhere(['like', 'phone', $this->phone]);
return $dataProvider;
}
示例4: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Contact::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->joinWith('tambon');
$query->andFilterWhere(['id' => $this->id]);
$query->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'base_tambon.tambon_name', $this->tambon_id]);
return $dataProvider;
}
示例5: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Contact::find();
// add conditions that should always apply here
$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;
}
// grid filtering conditions
$query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'date' => $this->date]);
$query->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'subject', $this->subject])->andFilterWhere(['like', 'body', $this->body]);
return $dataProvider;
}
示例6: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Contact::find();
// add conditions that should always apply here
$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;
}
// grid filtering conditions
$query->andFilterWhere(['id' => $this->id, 'isFriend' => $this->isFriend]);
$query->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'mail', $this->mail])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'zip', $this->zip]);
return $dataProvider;
}
示例7: postContact
public function postContact(FormContactRequest $request)
{
if (!empty($request)) {
$data = $request->all();
$data['customer_id'] = Auth::customer()->user()->id;
$data['flagactive'] = $request->get('flagactive', 1);
if ($request->id) {
$obj = Contact::find($request->id);
$obj->update($data);
} else {
$obj = Contact::create($data);
}
return array('msg' => 'ok', 'state' => 1, 'data' => null);
}
return array('msg' => 'Error al guardar el modelo', 'state' => 0, 'data' => null);
}
示例8: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Contact::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
$query->select('contact.*,u.username');
$query->leftJoin('user u', 'u.id = author_id');
if (Yii::$app->authManager->getAssignment(AclHelper::ROLE_ADMIN, \Yii::$app->user->id) === null) {
$query->where(['author_id' => Yii::$app->get('user', false)->id]);
// $params['ContactSearch']['user_id'] = Yii::$app->get('user', false)->id;
}
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'create_stamp' => $this->create_stamp, 'update_stamp' => $this->update_stamp]);
$query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'surname', $this->surname])->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'phone', $this->phone]);
return $dataProvider;
}
示例9: actionIndex
public function actionIndex()
{
$model = new Contact();
$msgs = Contact::find()->orderBy('id DESC')->limit('50')->all();
if ($model->load(Yii::$app->request->post())) {
$model->admin_id = Yii::$app->user->id;
$model->time = time();
$model->save();
$this->redirect('contact');
}
// проверка на время публикации (1 час)
$openContactForm = true;
$restTime = 0;
foreach ($msgs as $one) {
if ($one['admin_id'] == Yii::$app->user->id && $one['time'] >= time() - 60 * 60) {
$openContactForm = false;
$restTime = ceil(($one['time'] - (time() - 60 * 60)) / 60);
break;
}
}
return $this->render('index', ['model' => $model, 'msgs' => $msgs, 'openContactForm' => $openContactForm, 'restTime' => $restTime]);
}
示例10: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
$press = Contact::find($id);
$press->delete();
return Redirect::route('contact.index');
}
示例11: actionQuery1
public function actionQuery1()
{
$data = Contact::find()->where('id>2')->orderBy('firstname', 'lastname');
$dataProvider = new ActiveDataProvider(['query' => $data]);
return $this->render('query1', ['dataProvider' => $dataProvider]);
}
示例12: deleteContact
/**
* Deletes the comment selected by the admin
* @return type Redirect
*/
public function deleteContact()
{
if (Auth::check()) {
$id = Input::get('id', true);
$contact = Contact::find($id);
$contact->delete();
die;
} else {
return Redirect::route('admin');
}
}
示例13: actionMap
public function actionMap()
{
$contacts = Contact::find()->all();
return $this->render('map', ['contacts' => $contacts]);
}
示例14: workersDataProvider
protected function workersDataProvider($dept_id)
{
$dp = new ActiveDataProvider(['query' => Contact::find()->where(['dept' => $dept_id]), 'sort' => false]);
return $dp;
}
示例15: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
// destroy a user
$contact = \App\Models\Contact::find($id);
$contact->delete();
redirect('contact/');
}