本文整理汇总了PHP中app\models\Log类的典型用法代码示例。如果您正苦于以下问题:PHP Log类的具体用法?PHP Log怎么用?PHP Log使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Log类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newLog
public static function newLog($type, $msg)
{
$log = new Log();
$log->type = $type;
$log->msg = $msg;
$log->created_time = time();
return $log->save();
}
示例2: actionMessage
public function actionMessage()
{
$model = new Log();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect($model->goal->url(['#' => 'log']));
} else {
throw new ErrorException('Cannot add message');
}
}
示例3: updateLog
public function updateLog()
{
$model = Log::findOne($this->id);
if (!$model) {
$model = new Log();
$model->source_id = $this->id;
}
$model->updated = date("Y-m-d H:i:s");
return $model->save();
}
示例4: afterSave
public function afterSave($insert, $changedAttributes)
{
parent::afterSave($insert, $changedAttributes);
$this->calculateItemsLeft($changedAttributes);
$log = new Log();
if ($insert) {
$log->saveDatabaseOperation('create', $this->tableName(), $this->id);
} else {
$log->saveDatabaseOperation('update', $this->tableName(), $this->id);
}
}
示例5: post_edit_log_event
public function post_edit_log_event(Request $request, Log $log, LogEvent $log_event, Admin $admin)
{
$validation_rules = $log->getValidationRules();
$validation_messages = $admin->getValidationMessagesEditUser();
$this->validate($request, $validation_rules, $validation_messages);
$log_event = $log_event->find($request->log_event_id);
$log_event->name = $request->name;
$arr_request = array();
$arr_request['name'] = $request->name;
$log_event->save();
$log_event_id = $log_event->id;
$data = $log->getDataArray($arr_request, Auth::id(), $log_event_id, $this->arr_logged_in_user);
return view('log/edit_log_event_results')->with('data', $data);
}
示例6: actionIndex
/**
* @return string
*/
public function actionIndex()
{
$low_stock_items = Item::find()->where('quantity >= 1 AND quantity <= 10')->all();
$empty_stock_items = Item::find()->where('quantity = 0')->all();
$logs = Log::find()->orderBy('created_at DESC')->limit(10)->all();
return $this->render('index', ['low_stock_items' => $low_stock_items, 'empty_stock_items' => $empty_stock_items, 'logs' => $logs]);
}
示例7: boot
public static function boot()
{
parent::boot();
static::creating(function ($model) {
$model->effectivefrom = date('Y-m-d', strtotime($model->effectivefrom));
$model->effectiveto = date('Y-m-d', strtotime($model->effectiveto));
$model->createdby = Auth::user()->id;
$model->createddate = date("Y-m-d H:i:s");
$model->modifiedby = Auth::user()->id;
$model->modifieddate = date("Y-m-d H:i:s");
});
static::created(function ($model) {
Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
});
static::updating(function ($model) {
$model->effectivefrom = date('Y-m-d', strtotime($model->effectivefrom));
$model->effectiveto = date('Y-m-d', strtotime($model->effectiveto));
$model->modifiedby = Auth::user()->id;
$model->modifieddate = date("Y-m-d H:i:s");
});
static::updated(function ($model) {
Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
});
static::deleted(function ($model) {
Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
});
}
示例8: boot
public static function boot()
{
parent::boot();
static::creating(function ($model) {
if ($model->carsubmodelid == 0) {
CommissionExtraCar::where('commissionextraid', $model->commissionextraid)->where('carmodelid', $model->carmodelid)->delete();
}
$model->createdby = Auth::user()->id;
$model->createddate = date("Y-m-d H:i:s");
$model->modifiedby = Auth::user()->id;
$model->modifieddate = date("Y-m-d H:i:s");
});
static::created(function ($model) {
Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
});
static::updating(function ($model) {
if ($model->carsubmodelid == 0) {
CommissionExtraCar::where('id', '!=', $model->id)->where('commissionextraid', $model->commissionextraid)->where('carmodelid', $model->carmodelid)->delete();
}
$model->modifiedby = Auth::user()->id;
$model->modifieddate = date("Y-m-d H:i:s");
});
static::updated(function ($model) {
Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
});
static::deleted(function ($model) {
Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
});
}
示例9: boot
public static function boot()
{
parent::boot();
static::creating(function ($model) {
$carpreemption = CarPreemption::find($model->carpreemptionid);
$model->provinceid = $carpreemption->provinceid;
$model->branchid = $carpreemption->branchid;
$model->createdby = Auth::user()->id;
$model->createddate = date("Y-m-d H:i:s");
$model->modifiedby = Auth::user()->id;
$model->modifieddate = date("Y-m-d H:i:s");
});
static::created(function ($model) {
Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
$carpreemption = CarPreemption::find($model->carpreemptionid);
$carpreemption->status = 2;
$carpreemption->save();
});
static::updating(function ($model) {
$carpreemption = CarPreemption::find($model->carpreemptionid);
$model->provinceid = $carpreemption->provinceid;
$model->branchid = $carpreemption->branchid;
$model->modifiedby = Auth::user()->id;
$model->modifieddate = date("Y-m-d H:i:s");
});
static::updated(function ($model) {
Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
});
static::deleted(function ($model) {
Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
$carpreemption = CarPreemption::find($model->carpreemptionid);
$carpreemption->status = 0;
$carpreemption->save();
});
}
示例10: boot
public static function boot()
{
parent::boot();
static::creating(function ($model) {
$carpayment = CarPayment::find($model->carpaymentid);
$model->provinceid = $carpayment->provinceid;
$model->branchid = $carpayment->branchid;
$model->createdby = Auth::user()->id;
$model->createddate = date("Y-m-d H:i:s");
$model->modifiedby = Auth::user()->id;
$model->modifieddate = date("Y-m-d H:i:s");
});
static::created(function ($model) {
Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Add', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
});
static::updating(function ($model) {
$carpayment = CarPayment::find($model->carpaymentid);
$model->provinceid = $carpayment->provinceid;
$model->branchid = $carpayment->branchid;
$model->accountingDetailReceiveAndPays()->delete();
$model->modifiedby = Auth::user()->id;
$model->modifieddate = date("Y-m-d H:i:s");
});
static::updated(function ($model) {
Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Update', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
});
static::deleting(function ($model) {
$model->accountingDetailReceiveAndPays()->delete();
});
static::deleted(function ($model) {
Log::create(['employeeid' => Auth::user()->id, 'operation' => 'Delete', 'date' => date("Y-m-d H:i:s"), 'model' => class_basename(get_class($model)), 'detail' => $model->toJson()]);
});
}
示例11: findModel
/**
* Finds the Log model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Log the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Log::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
示例12: calculateSum
public static function calculateSum()
{
/** @var Collection $lastSuccessCollection */
$lastSuccessCollection = Collection::find()->where(['is_fulfilled' => true])->orderBy(['date' => SORT_DESC])->limit(1)->one();
if (is_null($lastSuccessCollection)) {
return Log::calculateSum();
}
return Log::calculateSum($lastSuccessCollection->date);
}
示例13: actionUpdate
/**
* Updates an existing Equipment model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param string $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
$model->room_id = $model->location->room_id;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
//Las siguientes líneas de código almacenan en la tabla Log información de acerca de las actualizaciones en los equipos
$modelLog = new Log();
$modelLog->user_id = Yii::$app->user->id;
$modelLog->date = new \yii\db\Expression('NOW()');
$modelLog->log_type_id = 3;
$modelLog->equipment_id = $model->id;
$modelLog->location_id = $model->location_id;
$modelLog->equipment_status_id = $model->equipment_status_id;
$modelLog->save();
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', ['model' => $model]);
}
}
示例14: getTestCatIdByName
/**
* Given the test category name we return the test category ID
*
* @param $testcategory - the name of the test category
*/
public static function getTestCatIdByName($testCategory)
{
try {
$testCatId = TestCategory::where('name', 'like', $testCategory)->firstOrFail();
return $testCatId->id;
} catch (ModelNotFoundException $e) {
Log::error("The test category ` {$testCategory} ` does not exist: " . $e->getMessage());
//TODO: send email?
return null;
}
}
示例15: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Log::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id, 'equipment_id' => $this->equipment_id, 'user_id' => $this->user_id, 'status_id' => $this->status_id, 'date' => $this->date, 'room_id' => $this->room_id, 'log_type_id' => $this->log_type_id]);
$query->andFilterWhere(['like', 'location', $this->location]);
return $dataProvider;
}