本文整理汇总了PHP中Rating::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Rating::save方法的具体用法?PHP Rating::save怎么用?PHP Rating::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rating
的用法示例。
在下文中一共展示了Rating::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rate
public function rate()
{
if ($this->check()) {
$rating = Rating::find("tag", self::TAG)->find("valueType", self::VALUE_TYPE)->find("value", self::VALUE);
$rating = $rating->find("entityId", $this->entityId)->find("entityType", $this->entityType)->find("userId", $this->userId);
$rating = $rating->first();
if ($rating == null) {
$rating = new Rating();
$rating->tag = self::TAG;
$rating->valueType = self::VALUE_TYPE;
$rating->value = self::VALUE;
$rating->host = $this->host;
$rating->entityId = $this->entityId;
$rating->entityType = $this->entityType;
$rating->userId = $this->userId;
$rating->timestamp = date('Y-m-d H:i:s');
$rating->save();
if (isset($rating->id) && $rating->id) {
$this->updatePlusCounter();
return true;
}
}
}
return false;
}
示例2: save
public function save()
{
if (!isset($this->timestamp) || $this->timestamp == '') {
$this->timestamp = date('Y-m-d H:i:s');
}
return parent::save();
}
示例3: addRate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function addRate($rating_score, $bus_Id)
{
$rateMod = new Rating();
$rateMod->rating_score = $rating_score;
$rateMod->product_id = $bus_Id;
$rateMod->rating_type = 1;
if ($rateMod->save()) {
return $rateMod->rating_id;
}
return 0;
}
示例4: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Rating();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Rating'])) {
$model->attributes = $_POST['Rating'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例5: store
/**
* Store a newly created rating in storage.
*
* @return Response
*/
public function store()
{
$validator = Validator::make($data = Input::all(), Rating::$rules);
if ($validator->fails()) {
dd($validator->messages());
return Redirect::back()->withErrors($validator)->withInput();
}
$rating = new Rating();
$rating->stars = Input::get('stars');
$rating->comment = Input::get('comment');
$rating->recommended = Input::get('recommended');
$rating->parking_lot_id = Input::get('parking_lot_id');
$rating->user_id = Auth::user()->id;
$rating->save();
return Redirect::route('ratings.index');
}
示例6: actionCreate
public function actionCreate()
{
if (!isset($_POST['Rating'])) {
$this->badRequest();
}
$rating = Rating::model()->findByAttributes(array('user_id' => Yii::app()->user->id, 'object_id' => $_POST['Rating']['object_id'], 'model_id' => $_POST['Rating']['model_id']));
if (!$rating) {
$rating = new Rating();
}
$rating->attributes = $_POST['Rating'];
if ($rating->save()) {
$rating = Rating::getValue($rating->model_id, $rating->object_id);
echo Rating::getHtml($rating);
} else {
echo CJSON::encode(array('errors' => $rating->errors_flat_array));
}
}
示例7: executeRate
public function executeRate()
{
$params = explode('.', $this->getRequestParameter('object_id'));
$type = $params[0];
$object_id = $params[1];
$value = $this->getRequestParameter('value');
$rating = null;
if ($type == Rating::APPLICATION) {
$object = Doctrine::getTable('Application')->find($object_id);
$q = new Doctrine_Query();
$rating = $q->select('r.*')->from('Rating r')->where('application_id = ? and user_id = ?', array($object_id, $this->getUser()->getId()))->fetchOne();
if (!$rating) {
$rating = new Rating();
$rating->setUserId($this->getUser()->getId());
$rating->setApplicationId($object_id);
}
} elseif ($type == Rating::MODULE) {
$object = Doctrine::getTable('Madule')->find($object_id);
$q = new Doctrine_Query();
$rating = $q->select('r.*')->from('Rating r')->where('madule_id = ? and user_id = ?', array($object_id, $this->getUser()->getId()))->fetchOne();
if (!$rating) {
$rating = new Rating();
$rating->setUserId($this->getUser()->getId());
$rating->setMaduleId($object_id);
}
} elseif ($type == Rating::THEME) {
$object = Doctrine::getTable('Theme')->find($object_id);
$q = new Doctrine_Query();
$rating = $q->select('r.*')->from('Rating r')->where('theme_id = ? and user_id = ?', array($object_id, $this->getUser()->getId()))->fetchOne();
if (!$rating) {
$rating = new Rating();
$rating->setUserId($this->getUser()->getId());
$rating->setThemeId($object_id);
}
}
$this->forward404Unless($value <= 5);
$this->forward404Unless($value >= 1);
if ($rating) {
$rating->setValue($value);
$rating->save();
$this->my_rating = $value;
$this->rating = $object->getRating();
}
}
示例8: run
public function run()
{
$faker = Faker::create();
$parking_lot = ParkingLot::all()->random();
$user = User::firstOrFail();
foreach (range(1, 10) as $index) {
$rating = new Rating();
$rating->stars = $faker->numberBetween($min = 1, $max = 5);
$rating->comment = 'Great Parking Lot';
$rating->recommended = $faker->boolean;
$rating->parking_lot_id = $parking_lot->id;
$rating->user_id = $user->id;
$rating->save();
$parking_lot = ParkingLot::all()->random();
$rating2 = new Rating();
$rating2->stars = $faker->numberBetween($min = 1, $max = 5);
$rating2->comment = 'Excellent Service';
$rating2->recommended = $faker->boolean;
$rating2->parking_lot_id = $parking_lot->id;
$rating2->user_id = $user->id;
$rating2->save();
$parking_lot = ParkingLot::all()->random();
$rating3 = new Rating();
$rating3->stars = $faker->numberBetween($min = 1, $max = 5);
$rating3->comment = 'Average Parking Lot';
$rating3->recommended = $faker->boolean;
$rating3->parking_lot_id = $parking_lot->id;
$rating3->user_id = $user->id;
$rating3->save();
$parking_lot = ParkingLot::all()->random();
$rating4 = new Rating();
$rating4->stars = $faker->numberBetween($min = 1, $max = 5);
$rating4->comment = 'Bad Customer Service';
$rating4->recommended = $faker->boolean;
$rating4->parking_lot_id = $parking_lot->id;
$rating4->user_id = $user->id;
$rating4->save();
}
}
示例9: actionAddcandidate
public function actionAddcandidate()
{
if (!isset(Yii::app()->user->userProfileID)) {
$this->redirect('/user/login');
}
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
$candidateModel = new Candidate();
$performanceModel = new Performance();
$ratingModel = new Rating();
$planningModel = new Planning();
if (isset($_POST['Candidate'])) {
$candidateModel->attributes = $_POST['Candidate'];
$candidateModel->IsActive = 1;
//$candidateModel->UserProfileID = Yii::app()->user->userProfileID;
$candidateModel->CompanyID = Yii::app()->user->companyID;
if ($candidateModel->validate()) {
if ($candidateModel->save()) {
$currentYear = date('Y');
// insert new record
$performanceModel->CandidateID = $candidateModel->CandidateID;
$performanceModel->PerformanceYear = $currentYear;
$ratingModel->CandidateID = $candidateModel->CandidateID;
$ratingModel->RatingYear = $currentYear;
$planningModel->CandidateID = $candidateModel->CandidateID;
$planningModel->PlanningYear = $currentYear;
$planningModel->CurrentPositionLevel = $_POST['Candidate']['CompanyPositionID'];
if ($_POST['Candidate']['CompanyPositionID'] == 5) {
$planningModel->NextStepPositionLevel = 5;
$planningModel->LongTermPositionLevel = 5;
} else {
$planningModel->NextStepPositionLevel = $_POST['Candidate']['CompanyPositionID'];
$planningModel->LongTermPositionLevel = $_POST['Candidate']['CompanyPositionID'];
}
$performanceModel->save();
$ratingModel->save();
$planningModel->save();
$this->redirect(Yii::app()->createUrl('company/candidates'));
}
}
}
$criteria3 = new CDbCriteria();
$criteria3->condition = 'companyID = :companyID';
$criteria3->params = array(':companyID' => Yii::app()->user->companyID);
$criteria3->order = 'Email';
$userManagers = UserProfile::model()->findAllByAttributes(array(), $criteria3);
$managersArray = array();
foreach ($userManagers as $UserManager) {
$managersArray[$UserManager->UserProfileID] = $UserManager->Email;
}
$managerArray = $managersArray;
$companyPositions = Helper::getCompanyPositions(Yii::app()->user->companyID);
$this->render('candidate-form', array('candidateModel' => $candidateModel, 'planningModel' => $planningModel, 'companyPositionSelect' => $companyPositions, 'managerArray' => $managerArray));
}
示例10: saveDatabase
public function saveDatabase()
{
$buyer1 = Input::get('buyer');
$seller = Input::get('seller');
$review = Input::get('review');
$urls = Input::get('urls');
$rating_num = Input::get('rating');
$rating = new Rating();
//$rating->rating_id = 2;
$rating->seller = $seller;
$rating->buyer = $buyer1;
$rating->review = $review;
$rating->rating_number = $rating_num;
$rating->save();
return Redirect::away("http://localhost/authentication/secure/dashboard/modules/problem_sharing/donors");
// return Response::json(array('status'=>'done'));
}
开发者ID:umarhussain15,项目名称:web_semester_project_integration_repo_Jan16,代码行数:17,代码来源:HomeController.php
示例11: rate
/**
* Rate
*/
public function rate($data)
{
App::uses('Rating', 'Ratings.Model');
// load Ratings Model
$Rating = new Rating();
//create Object $Rating
return $Rating->save($data);
//return data and save
}
示例12: update
function update($item_id, $rating_value)
{
if (!AMP_SYSTEM_UNIQUE_VISITOR_ID) {
return false;
}
$session = AMP_SYSTEM_UNIQUE_VISITOR_ID;
$articles_rated = AMP_lookup('article_ids_rated_by_session', $session);
if (!isset($articles_rated[$item_id])) {
return ArticleRating::create($item_id, $rating_value);
}
$rating_id = $articles_rated[$item_id];
$rating = new Rating(AMP_Registry::getDbcon(), $rating_id);
if (!$rating->hasData()) {
return false;
}
$rating->mergeData(array('rating' => $rating_value, 'updated_at' => date('Y-m-d h:i:s')));
$result = $rating->save();
AMP_lookup_clear_cached('article_ids_rated_by_session', $session);
AMP_lookup_clear_cached('article_ratings_by_session', $session);
AMP_lookup_clear_cached('article_ratings');
AMP_lookup_clear_cached('article_ratings_last_week');
AMP_lookup_clear_cached('article_ratings_last_month');
return $result;
}
示例13: actionSetMark
/**
* Set mark for the good by user
* @param $good_id
* @param $rate mark (1-5)
*/
public function actionSetMark($good_id, $rate)
{
if (Yii::app()->user->isGuest) {
echo 'you are not registered user';
return;
}
$user = Yii::app()->user->id;
$rating = Rating::model()->with(array('good', 'good.marksCount'))->findByAttributes(array('good_id' => $good_id, 'user_id' => $user));
if (empty($rating)) {
if ($rate == 'undefined') {
return;
}
$rating = new Rating();
$rating->good_id = $good_id;
$rating->user_id = $user;
$rating->value = $rate;
if ($rating->save()) {
$good = $rating->good;
$good->rating = round($good->rating + ($rate * 100 - $good->rating) / ($good->marksCount + 1));
$good->save();
echo 'success';
} else {
echo 'fail saving';
}
} else {
if ($rating->value != $rate) {
if ($rate == 'undefined') {
echo 'rate deleted';
$rating->delete();
return;
}
$old_mark = $rating->value;
$rating->value = $rate;
if ($rating->save()) {
$good = $rating->good;
$good->rating = round($good->rating + ($rate * 100 - $old_mark * 100) / $good->marksCount);
$good->save();
echo 'success';
} else {
echo 'fail saving';
}
} else {
echo 'no need to change';
}
}
}
示例14: setUpRating
public function setUpRating()
{
$rating = new Rating();
$rating->id = 1;
$rating->user_id = $this->_user_id;
$rating->wine_unique_id = '1_2009';
$rating->rate = '3.5';
$rating->comment_count = '8';
$rating->like_count = '6';
$rating->save();
$rating = new Rating();
$rating->id = 2;
$rating->user_id = '3620a42d-fcbb-45eb-b3a5-36cada1b77b7';
$rating->wine_unique_id = '1_2009';
$rating->rate = '2';
$rating->comment_count = '18';
$rating->like_count = '7';
$rating->save();
$rating = new Rating();
$rating->id = 3;
$rating->user_id = '1803a4fd-0e90-45ae-ad75-d8d3d2448d5e';
$rating->wine_unique_id = '1_2009';
$rating->rate = '5';
$rating->comment_count = '3';
$rating->like_count = '4';
$rating->save();
}
示例15: actionCreate
public function actionCreate()
{
// check permissions
// if (!Yii::app()->user->checkAccess('manageUser')) {
// Helper::authException();
// }
// models
$UserLogin = new UserLogin();
$UserProfile = new UserProfile();
$criteria3 = new CDbCriteria();
$criteria3->condition = '(companyID = :companyID AND IsActive=1)';
$criteria3->params = array(':companyID' => Yii::app()->user->companyID);
$criteria3->order = 'Email';
$userManagers = UserProfile::model()->with('userLogin')->findAllByAttributes(array(), $criteria3);
$managersArray = array();
$managersArray[0] = "Please Select...";
foreach ($userManagers as $UserManager) {
//if ($UserManager->ManagerEmail == '') {
//$managersArray[$UserManager->Email] = $UserManager->Email;
$managersArray[$UserManager->Email] = $UserManager->Email;
//} elseif (Helper::hasRole('lacekAdministrator')) {
// $rolesArray[$UserRole->UserRoleID] = $UserRole->RoleDesc;
// }
}
// add default (empty value) to front of array
$managerArray = $managersArray;
// role array for select
$userRoles = UserRole::model()->findAll();
$rolesArray = array();
foreach ($userRoles as $UserRole) {
if ($UserRole->RoleType != 'lacekAdministrator') {
$rolesArray[$UserRole->UserRoleID] = $UserRole->RoleDesc;
} elseif (Helper::hasRole('lacekAdministrator')) {
$rolesArray[$UserRole->UserRoleID] = $UserRole->RoleDesc;
}
}
// add default (empty value) to front of array
$rolesArray = $rolesArray;
// form processing
if (isset($_POST['UserLogin'], $_POST['UserProfile'])) {
// redirect to the dashboard if 'Cancel' button clicked
if (isset($_POST['button-cancel'])) {
$this->redirect($this->createUrl('user/dashboard'));
}
// set UserLogin attributes and scenario
$UserLogin->attributes = $_POST['UserLogin'];
$UserLogin->IsPasswordReset = 1;
// force password reset on first login
$UserLogin->IsActive = 1;
$UserLogin->scenario = 'create';
$UserLogin->UserRoleID = 1;
// set UserProfile attributes
$UserProfile->attributes = $_POST['UserProfile'];
$UserProfile->CompanyID = Yii::app()->user->companyID;
$UserProfile->Email = $UserLogin->LoginEmail;
// validate form submission
$valid = $UserLogin->validate();
$valid = $UserProfile->validate() && $valid;
if ($valid) {
// save UserLogin
if (!$UserLogin->save(false)) {
throw new CHttpException(400, 'Error when trying to create user.');
}
// save UserProfile
$UserProfile->UserLoginID = $UserLogin->UserLoginID;
// set newly generated EventID
if (!$UserProfile->save(false)) {
throw new CHttpException(400, 'Error when trying to create user.');
}
if ($UserProfile->ManagerEmail) {
$UserProfilex = UserProfile::model()->findByAttributes(array('Email' => $UserProfile->ManagerEmail));
$candidateModel = new Candidate();
$candidateModel->CompanyID = $UserProfile->CompanyID;
$candidateModel->EmployeeID = $UserProfile->EmployeeID;
$candidateModel->FirstName = $UserProfile->FirstName;
$candidateModel->MiddleName = $UserProfile->MiddleName;
$candidateModel->LastName = $UserProfile->LastName;
$candidateModel->Title = $UserProfile->Title;
$candidateModel->Email = $UserProfile->Email;
$candidateModel->CompanyPositionID = 1;
$candidateModel->HireDate = date("Y-m-d");
$candidateModel->PositionDate = date("Y-m-d");
$candidateModel->IsActive = 1;
$candidateModel->UserProfileID = $UserProfilex->UserProfileID;
//$candidateModel->UserProfileId=2;
//print_r($candidateModel);
// die($UserProfilex->UserProfileID);
// if ($candidateModel->validate()) {
// if ($candidateModel->save()) {
$candidateModel->save();
$performanceModel = new Performance();
$ratingModel = new Rating();
$planningModel = new Planning();
$currentYear = date('Y');
// insert new record
$performanceModel->CandidateID = $candidateModel->CandidateID;
$performanceModel->PerformanceYear = $currentYear;
$ratingModel->CandidateID = $candidateModel->CandidateID;
$ratingModel->RatingYear = $currentYear;
$planningModel->CandidateID = $candidateModel->CandidateID;
//.........这里部分代码省略.........