当前位置: 首页>>代码示例>>PHP>>正文


PHP Course::save方法代码示例

本文整理汇总了PHP中app\models\Course::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Course::save方法的具体用法?PHP Course::save怎么用?PHP Course::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Course的用法示例。


在下文中一共展示了Course::save方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCreate

 /**
  * Creates a new Course model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Course();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:janwillemm,项目名称:sa-matcher,代码行数:14,代码来源:CourseController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CourseRequest $request)
 {
     $data = $request->all();
     unset($data['Id']);
     $course = new Course();
     $course->fromArray($data);
     $course->save();
     flash()->success("ADDED");
     session(['attribute' => \Lang::get('general.COURSE')]);
     return redirect($this->main_page);
 }
开发者ID:nstojanovickg,项目名称:diplomski,代码行数:16,代码来源:CourseController.php

示例3: store

 /**
  * @param Request $request
  * @param Course $course
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(Request $request, Course $course)
 {
     $regex = '/^(?=.+)(?:[1-9]\\d*|0)?(?:\\.\\d+)?$/';
     $validator = Validator::make($request->all(), ['name' => 'required|string|max:255', 'course_purchase' => ['required', 'regex:' . $regex]]);
     if ($validator->fails()) {
         return redirect()->route('admin.course.create')->withErrors($validator->errors())->withInput();
     }
     $currency = new Currency();
     $currency->name = $request->name;
     $currency->save();
     $course->currency()->associate($currency);
     $course->fill($request->all());
     $course->save();
     return redirect()->route('admin.course.index');
 }
开发者ID:lyovkin,项目名称:elcoinbank,代码行数:20,代码来源:AdminCourseController.php

示例4: actionSave

 public function actionSave()
 {
     if (!empty($_POST['course'][Course::PK])) {
         $item = Course::findByPK($_POST['course'][Course::PK]);
     } else {
         $item = new Course();
     }
     $item->fill($_POST['course']);
     $item->save();
     if ($item->wasNew() && !empty($_POST['lessonsCount'])) {
         $lessonsCount = (int) $_POST['lessonsCount'];
         for ($i = 1; $i <= $lessonsCount; $i++) {
             $lesson = new Lesson();
             $lesson->num = $i;
             $lesson->title = 'Урок ' . $i;
             $lesson->course = $item;
             $lesson->save();
         }
     }
     $this->redirect('/admin/courses');
 }
开发者ID:pr-of-it,项目名称:profit,代码行数:21,代码来源:Courses.php

示例5: addOperation

 public function addOperation()
 {
     if ($this->currency_id != '1') {
         $course = new Course();
         if (!$course->checkCourse($this->currency_id)) {
             $course->currency_id = $this->currency_id;
             $currency = Currency::findOne($this->currency_id);
             $course->course = $course->getCourse($currency->iso);
             if (!$course->save()) {
                 throw new ErrorException('Курс не обновлен' . var_dump($course));
             }
         }
     }
     $operation = new Operation();
     $operation->user_id = Yii::$app->getUser()->id;
     $operation->category_id = $this->category_id === '' ? 1 : $this->category_id;
     $operation->currency_id = $this->currency_id === '' ? 1 : $this->currency_id;
     $operation->summ = $this->operation_type == 'income' ? $this->summ * 100 : $this->summ * -100;
     $operation->description = $this->description;
     return $operation->save() ? $operation : null;
 }
开发者ID:Nhassa,项目名称:budget,代码行数:21,代码来源:OperationForm.php

示例6: doSave

 /**
  * 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      ConnectionInterface $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(ConnectionInterface $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 corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aCourse !== null) {
             if ($this->aCourse->isModified() || $this->aCourse->isNew()) {
                 $affectedRows += $this->aCourse->save($con);
             }
             $this->setCourse($this->aCourse);
         }
         if ($this->aSchoolYear !== null) {
             if ($this->aSchoolYear->isModified() || $this->aSchoolYear->isNew()) {
                 $affectedRows += $this->aSchoolYear->save($con);
             }
             $this->setSchoolYear($this->aSchoolYear);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
                 $affectedRows += 1;
             } else {
                 $affectedRows += $this->doUpdate($con);
             }
             $this->resetModified();
         }
         if ($this->adminUsersScheduledForDeletion !== null) {
             if (!$this->adminUsersScheduledForDeletion->isEmpty()) {
                 \App\Models\AdminUserQuery::create()->filterByPrimaryKeys($this->adminUsersScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->adminUsersScheduledForDeletion = null;
             }
         }
         if ($this->collAdminUsers !== null) {
             foreach ($this->collAdminUsers as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->applicationsScheduledForDeletion !== null) {
             if (!$this->applicationsScheduledForDeletion->isEmpty()) {
                 \App\Models\ApplicationQuery::create()->filterByPrimaryKeys($this->applicationsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->applicationsScheduledForDeletion = null;
             }
         }
         if ($this->collApplications !== null) {
             foreach ($this->collApplications as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
开发者ID:nstojanovickg,项目名称:diplomski,代码行数:73,代码来源:Student.php

示例7: addSlug

 /**
  * Add a slug to the course.
  *
  * @param Course $course
  * @param $slug
  * @return Course
  */
 public function addSlug(Course $course, $slug)
 {
     \DB::transaction(function () use($course, $slug) {
         $course->slug = $slug;
         $course->save();
     });
     return $course;
 }
开发者ID:bohap,项目名称:online-study,代码行数:15,代码来源:CourseRepository.php

示例8: save

 /**
  * Save a model with it's relations.
  *
  * @param $data
  * @param null $id
  *
  * @return static
  */
 public static function save($data, $id = null)
 {
     if ($id) {
         $employee = Employee::findOrFail($id);
         $employee->fill($data);
     } else {
         $employee = Employee::create($data);
     }
     Address::whereEmployeeId($employee->id)->delete();
     // flush
     Course::whereEmployeeId($employee->id)->delete();
     foreach (array_get($data, 'address', []) as $key => $d) {
         if (empty($d['city']) && empty($d['street']) && empty($d['number'])) {
             continue;
         }
         $address = new Address($d);
         $address->employee_id = $employee->id;
         $address->save();
     }
     foreach (array_get($data, 'course', []) as $key => $d) {
         if (empty($d['title']) && empty($d['start']) && empty($d['end'])) {
             continue;
         }
         $course = new Course($d);
         $course->employee_id = $employee->id;
         $course->save();
     }
     $employee->save();
     return $employee;
 }
开发者ID:Stichoza,项目名称:motorhead-tegetarius,代码行数:38,代码来源:EmployeeRepository.php

示例9: doSave

 /**
  * 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      ConnectionInterface $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(ConnectionInterface $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 corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aCourse !== null) {
             if ($this->aCourse->isModified() || $this->aCourse->isNew()) {
                 $affectedRows += $this->aCourse->save($con);
             }
             $this->setCourse($this->aCourse);
         }
         if ($this->aProfessor !== null) {
             if ($this->aProfessor->isModified() || $this->aProfessor->isNew()) {
                 $affectedRows += $this->aProfessor->save($con);
             }
             $this->setProfessor($this->aProfessor);
         }
         if ($this->aSubject !== null) {
             if ($this->aSubject->isModified() || $this->aSubject->isNew()) {
                 $affectedRows += $this->aSubject->save($con);
             }
             $this->setSubject($this->aSubject);
         }
         if ($this->aSchoolYear !== null) {
             if ($this->aSchoolYear->isModified() || $this->aSchoolYear->isNew()) {
                 $affectedRows += $this->aSchoolYear->save($con);
             }
             $this->setSchoolYear($this->aSchoolYear);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
                 $affectedRows += 1;
             } else {
                 $affectedRows += $this->doUpdate($con);
             }
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
开发者ID:nstojanovickg,项目名称:diplomski,代码行数:59,代码来源:Engagement.php

示例10: saveMatkul

 /**
  * Normally we try taken form data with Request Controller but in this case we are using Facade
  * Todo: Add Validator (Critical, after all core business function is implemented)
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function saveMatkul(Request $request)
 {
     $input = $request->all();
     $validator = $this->course_validator($input);
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     $course = new Course();
     $course->Kode_Matkul = $input['Kode_Matkul'];
     $course->Nama_Matkul = $input['Nama_Matkul'];
     $course->SKS = $input['SKS'];
     $course->prodi_id = $input['prodi_id'];
     $course->day = $input['day'];
     $course->id_ruang = $input['id_ruang'];
     $course->time = $input['time'];
     $course->Kode_Dosen = $input['Kode_Dosen'];
     $semester = Kalender::getRunningSemester();
     $course->id_semester = $semester->id;
     $course->course_start_day = $input['course_start_day'];
     $course->save();
     return $this->viewCourseByLecturer();
 }
开发者ID:mekas,项目名称:absenv2,代码行数:27,代码来源:MatkulController.php


注:本文中的app\models\Course::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。