本文整理汇总了PHP中Review::setAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Review::setAttributes方法的具体用法?PHP Review::setAttributes怎么用?PHP Review::setAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Review
的用法示例。
在下文中一共展示了Review::setAttributes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreateInvalid
/**
* Tests the create review action with invalid input.
*/
public function testCreateInvalid()
{
$note = $this->notes('note1');
$student = $this->students('student1');
// Empty content
$review = new Review();
$review->setAttributes(array('content' => null));
$this->assertFalse($note->addReview($review, $student->id));
}
示例2: actionReviewAdd
public function actionReviewAdd($response_id)
{
if (Yii::app()->user->isGuest) {
throw new CHttpException(403);
}
$Response = Response::model()->findByPK($response_id);
if (is_null($Response)) {
throw new CHttpException(403);
}
$profile = Yii::app()->user->getProfile();
$Company = $profile->company;
if ($Company->isBlocked()) {
$this->render('reviewaddblock', ['Response' => $Response, 'CompanyPartner' => null]);
return;
}
$CompanyPartnerId = null;
if ($Company->id == $Response->from_company_id) {
$CompanyPartnerId = $Response->to_company_id;
} else {
if ($Company->id == $Response->to_company_id) {
$CompanyPartnerId = $Response->from_company_id;
} else {
// компания не принадлежит к этой сделке
throw new CHttpException(403);
}
}
$CompanyPartner = Company::model()->findByPk($CompanyPartnerId);
if ($CompanyPartner->isBlocked()) {
$this->render('reviewaddblock', ['Response' => $Response, 'CompanyPartner' => $CompanyPartner]);
return;
}
if (!$Response->isCompaniesReadyForReviews()) {
Yii::log("actionReviewAdd companies NOT ready for review", "info");
throw new CHttpException(403);
}
$Review = Review::model()->findByAttributes(['response_id' => $response_id, 'from_company_id' => $Company->id]);
if (is_null($Review)) {
$Review = new Review();
}
//$Response = Response::model()->findByPk($response_id);
if (isset($_POST['Review'])) {
$Review->setAttributes($_POST['Review'], false);
$Review->from_company_id = $Company->id;
if ($Response->to_company->id == $Company->id) {
$CompanyTo = $Response->from_company;
} else {
$CompanyTo = $Response->to_company;
}
$Review->to_company_id = $CompanyTo->id;
$Review->response_id = $Response->response_id;
if ($Review->validate()) {
$Review->save();
if (isset($_POST['photos'])) {
$Review->setPhoto($_POST['photos']);
}
$Review->setscenario('valid_photo');
if ($Review->validate()) {
//$this->redirect('/cabinet/deal/'.$Response->response_id);
$this->redirect('/response/' . $Response->response_id);
}
}
}
$mainAssets = Yii::app()->getTheme()->getAssetsUrl();
Yii::app()->getClientScript()->registerCssFile($mainAssets . '/css/review.css');
$this->render('reviewadd', ['Review' => $Review, 'Response' => $Response]);
}