當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Client::findOne方法代碼示例

本文整理匯總了PHP中app\models\Client::findOne方法的典型用法代碼示例。如果您正苦於以下問題:PHP Client::findOne方法的具體用法?PHP Client::findOne怎麽用?PHP Client::findOne使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\Client的用法示例。


在下文中一共展示了Client::findOne方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: findModel

 /**
  * Finds the Client model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Client the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Client::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
開發者ID:Sywooch,項目名稱:arenda,代碼行數:15,代碼來源:ClientController.php

示例2: actionSendmail

 /**
  * send a email to client with checklist attached
  * @return void
  */
 public function actionSendmail()
 {
     $post = Yii::$app->request->post('SendmailForm');
     Yii::$app->response->format = 'json';
     $sm_form = new SendmailForm();
     if ($sm_form->load(Yii::$app->request->post()) && $sm_form->validate()) {
         $checklistCow = ChecklistsCow::findOne($post['checklists_cow_id']);
         if ($checklistCow->belong_to == 1) {
             $cow = Client::findOne($checklistCow->clients_or_webs_id);
             $email = $cow->email;
         } elseif ($checklistCow->belong_to == 2) {
             $cow = Website::findOne($checklistCow->clients_or_webs_id);
             $email = $cow->client->email;
         }
         // save time sending
         // checking if time sending is exist then only update else create new one
         $timeSent = ChecklistsTimeSent::find()->where(['checklists_cow_id' => $post['checklists_cow_id']])->one();
         if (!isset($timeSent)) {
             $timeSent = new ChecklistsTimeSent();
         }
         $timeSent->checklists_cow_id = $post['checklists_cow_id'];
         $timeSent->time_sent = date('Y-m-d H:i:s');
         $timeSent->save();
         // if everything is ok, then send mail. go ahead!!!
         Yii::$app->mailer->compose()->setFrom('admin@panel.com')->setTo($email)->setSubject($post['subject'])->setTextBody($post['content'])->attach(Yii::$app->basePath . '/web/upload/pdf/' . $checklistCow->file_name)->send();
         return ['errors' => ''];
     } else {
         return ['errors' => 'Something is wrong.'];
     }
 }
開發者ID:hoangngk,項目名稱:adminpanel,代碼行數:34,代碼來源:ChecklistsController.php

示例3: testTenTodayOrders

 public function testTenTodayOrders()
 {
     $this->assertEquals(10, count(Client::findOne(101)->getTenTodayOrders()->all()));
 }
開發者ID:mvcaaa,項目名稱:TestCase013,代碼行數:4,代碼來源:ClientTest.php

示例4: actionDelete

 /**
  * Deletes an existing Client model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $model = Client::findOne($id);
     Order::deleteAll(['id_client' => $model->id]);
     $model->delete();
     return $this->redirect(['index']);
 }
開發者ID:earlcherry,項目名稱:test-project,代碼行數:13,代碼來源:OrderController.php


注:本文中的app\models\Client::findOne方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。