/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Grade();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Grade'])) {
         $model->attributes = $_POST['Grade'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id_grade));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #2
0
 /**
  * @before _secure, _school
  */
 public function add()
 {
     $this->setSEO(array("title" => "School | Add Grades"));
     $view = $this->getActionView();
     if (RequestMethods::post("action") == "addGrades") {
         $title = RequestMethods::post("title");
         $description = RequestMethods::post("description");
         foreach ($title as $key => $value) {
             $grade = new \Grade(array("title" => Markup::checkValue($value), "description" => Markup::checkValue($description[$key]), "organization_id" => $this->organization->id));
             $grade->save();
         }
         $view->set("success", 'Classes added successfully! See <a href="/grades/manage">Manage Classes</a>');
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['gpa' => 'required', 'course_id' => 'required', 'semester_id' => 'required', 'student_id' => 'required', 'faculty_id' => 'required', 'section' => 'required', 'credits' => 'required']);
     if ($validator->fails()) {
         return json_encode($validator->errors());
     } else {
         $grade = new Grade();
         foreach ($request->all() as $key => $value) {
             $grade->{$key} = $value;
         }
         $grade->save();
         return json_encode($grade);
     }
 }
Example #4
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aGrade !== null) {
             if ($this->aGrade->isModified() || $this->aGrade->isNew()) {
                 $affectedRows += $this->aGrade->save($con);
             }
             $this->setGrade($this->aGrade);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = PeriodoPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = PeriodoPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += PeriodoPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         if ($this->collGradeunits !== null) {
             foreach ($this->collGradeunits as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }