本文整理汇总了PHP中app\models\Student::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Student::save方法的具体用法?PHP Student::save怎么用?PHP Student::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Student
的用法示例。
在下文中一共展示了Student::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new Student model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$student = new Student();
$user = new User();
$person = new Person();
if (Yii::$app->request->post()) {
$params = Yii::$app->request->post();
$person->load($params);
$user->load($params);
$user->password_hash = Yii::$app->getSecurity()->generatePasswordHash($params['User']['password_hash']);
$student->load($params);
if ($person->validate() && $user->validate() && $student->validate()) {
$person->save(false);
$user->person_id = $person->id;
$user->register();
$student->user_id = $user->id;
$student->save();
Yii::$app->session->setFlash('success', 'Se envío un correo de confirmación. Por favor verifique su correo electrónico');
return $this->refresh();
} else {
Yii::$app->session->setFlash('danger', 'Ocurrió ff un error al guardar. Vuelve a intentar');
return $this->refresh();
}
} else {
return $this->render('create', ['student' => $student, 'user' => $user, 'person' => $person]);
}
}
示例2: saveStudenInfo
public function saveStudenInfo()
{
if (!empty(Input::get('studId'))) {
$studInfo = Student::find(Input::get('studId'));
} else {
$studInfo = new Student();
}
$studInfo['stud_num'] = Input::get('studNo');
$studInfo['fname'] = Input::get('fname');
$studInfo['lname'] = Input::get('lname');
$studInfo['address'] = Input::get('address');
$studInfo['zip'] = Input::get('zip');
$studInfo['city'] = Input::get('drpCity');
$studInfo['state'] = Input::get('drpState');
$studInfo['phone'] = Input::get('pnumber');
$studInfo['mobile'] = Input::get('mnumber');
$studInfo['email'] = Input::get('email');
$studInfo['year_lvl'] = Input::get('drpYearLvl');
$studInfo['section'] = Input::get('drpSection');
if ($studInfo->save()) {
return 1;
} else {
return 2;
}
}
示例3: actionCreate
/**
* Creates a new Student model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Student();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例4: postThemmoi
function postThemmoi(Request $request)
{
$model = new Student();
$model->first_name = $request->txtfirst_name;
$model->middle_name = $request->txtmiddle_name;
$model->last_name = $request->txtlast_name;
$model->address = $request->txtaddress;
$model->identity = $request->txtidentity;
$model->phone = $request->txtphone;
$model->birthday = $request->txtbirthday;
$model->save();
$file = $request->file('txtimage');
$file_name = $model['id'] . "-" . time() . "-" . $file->getClientOriginalName();
$model->image = $file_name;
$file->move('../resources/upload/hocsinh/', $file_name);
$model->save();
return redirect()->route('student');
}
示例5: postStudentModal
function postStudentModal(Request $request, Student $student)
{
$student->user->email = $request->get('email');
$student->user->save();
$student->programme = $request->get('programme');
$student->active = $request->get('active');
$student->group_id = $request->get('group_id') ?: null;
$student->remark = $request->get('remark');
$student->save();
}
示例6: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(StudentRequest $request)
{
$data = $request->all();
$student = new Student();
$student->fromArray($data);
$student->save();
flash()->success("ADDED");
session(['attribute' => \Lang::get('general.STUDENT')]);
return redirect($this->main_page);
}
示例7: actionCreate
public function actionCreate()
{
$model = new Student();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$model->birthday = date('Y-m-d', strtotime($model->birthday));
if ($model->save()) {
return $this->redirect(Url::to(['/student/view', 'id' => $model->id]));
}
}
return $this->render('create', ['model' => $model]);
}
示例8: saveUser
/**
* @param $name
* @param $email
* @param $request
* @param $workshop
*/
private function saveUser($name, $email, $request, $workshop)
{
$user = new Student();
if (!Student::isStudent($name, $email)) {
$user->fill($request);
$user->status = 'C';
$user->profile = $this->getUserProfileString($request);
$user->save();
} else {
$user = $user->getByEmailAndName($name, $email);
}
if (!$user->isRegistered($name, $email, $workshop->id)) {
$user->workshops()->attach($workshop->id, ['sign_date' => date('Y-m-d H:i:s')]);
}
}
示例9: actionRegister
public function actionRegister($co = null, $cl = null)
{
$model = new Student();
if ($model->load(Yii::$app->request->post())) {
$model->course_id = $co;
$model->classid = $cl;
$model->created_dt = date('Y-m-d H:i:s');
$model->save();
return $this->redirect(['success']);
//return $this->redirect(['view', 'id' => $model->id]);
} else {
if (!empty($co)) {
$courselist = Course::findOne($co);
}
return $this->render('register', ['model' => $model, 'courselist' => $courselist]);
}
}
示例10: actionRegistration
public function actionRegistration($role = '')
{
if (!\Yii::$app->user->isGuest) {
$this->redirect(\Yii::$app->user->getReturnUrl());
}
if ($role == '') {
return $this->render('registration');
}
$model = new User();
$role_model = new Company();
$model->role = User::ROLE_COMPANY;
if ($role != 'company') {
//Student registration
$role = 'student';
$role_model = new Student();
$model->role = User::ROLE_STUDENT;
}
if ($model->load(Yii::$app->request->post()) && $role_model->load(Yii::$app->request->post()) && $model->register()) {
if ($role == 'student') {
$role_model->idUser = $model->id;
if ($role_model->save()) {
return $this->render('registration_student_success', ['model' => $model]);
}
} else {
$role_model->idUser = $model->id;
//Upload logo
if (isset($_FILES['Company']) && $_FILES['Company']['name']['logo_path'] != "") {
if (!in_array($_FILES['Company']['type']['logo_path'], $this->image_array)) {
$role_model->addError('logo_path', 'Доступные расширения для файла: jpg, gif, png.');
} else {
$rnd = rand(0, 9999);
$uploadedFile = UploadedFile::getInstance($role_model, 'logo_path');
$fileName = 'files/' . $rnd . '_' . $uploadedFile->name;
$role_model->logo_path = $fileName;
$uploadedFile->saveAs($fileName);
}
}
if ($role_model->save()) {
return $this->render('registration_company_success', ['model' => $model]);
}
}
}
return $this->render('registration_' . $role, ['model' => $model, 'role_model' => $role_model]);
}
示例11: save
public function save()
{
echo "SAVE function from studentController.php is working";
$student = new Student();
$studentName = Request::input('studentName');
$email = Request::input('email');
$studentRank = Request::input('studentRank');
$studentPhone = Request::input('studentPhone');
$img1 = Request::input('img1');
$img2 = Request::input('img2');
$img3 = Request::input('img3');
$img4 = Request::input('img4');
$img5 = Request::input('img5');
print_r($studentName);
$student->studentName = $studentName;
$student->studentRank = $studentRank;
$student->studentPhone = $studentPhone;
$student->email = $email;
$student->save();
print_r($studentPhone);
return redirect("/students");
}
示例12: addSubmit
/**
* When search form from add is submited
*
* @return Response
*/
public function addSubmit($login)
{
// If the user is new, import some values from the API response.
$json = EtuUTT::call('/api/public/users/' . $login)['data'];
$student = Student::find($json['studentId']);
if ($student === null) {
$student = new Student(['student_id' => $json['studentId'], 'first_name' => $json['firstName'], 'last_name' => $json['lastName'], 'surname' => $json['surname'], 'email' => $json['email'], 'facebook' => $json['facebook'], 'branch' => $json['branch'], 'level' => $json['level'], 'ce' => 1, 'team_id' => EtuUTT::student()->team_id]);
$student->save();
// Error here a ignored, we just keep user without a picture if we cannot download it
$picture = @file_get_contents('http://local-sig.utt.fr/Pub/trombi/individu/' . $json['studentId'] . '.jpg');
@file_put_contents(public_path() . '/uploads/students-trombi/' . $json['studentId'] . '.jpg', $picture);
} elseif ($student->team) {
return $this->error('Cet étudiant fait déjà partie d\'une équipe. Il faut qu\'il la quitte avant de pouvoir être ajouté à une nouvelle équipe.');
} else {
$student->team_id = EtuUTT::student()->team_id;
$student->ce = 1;
$student->save();
}
$team = EtuUTT::student()->team;
$team->validated = false;
$team->save();
return redirect(route('dashboard.ce.myteam'))->withSuccess($json['fullName'] . ' a bien été ajouté à votre équipe. Il faut maintenant qu\'il se connecte au site d\'intégration pour valider sa participation.');
}
示例13: actionCreate
/**
* Creates a new Student model.
* If creation is successful, the browser will be redirected to the either
* the index or the create page to add another.
* @return mixed
*/
public function actionCreate()
{
$transaction = Yii::$app->db->beginTransaction();
// Get the user's school and the current date.
$schoolId = Yii::$app->user->schoolId;
$today = date('Y-m-d');
$student = new Student();
$student->contract_school_id = $schoolId;
$student->start_date = $today;
if ($student->load(Yii::$app->request->post()) && $student->save()) {
// Affiliate the new student with the same school as the user
$role = Role::find()->where(['like', 'name', 'student'])->one();
$affiliation = new Affiliation();
if ($affiliation->load(Yii::$app->request->post())) {
$affiliation->student_id = $student->id;
$affiliation->school_id = $schoolId;
$affiliation->role_id = $role->id;
$affiliation->date = $today;
$affiliation->save();
}
/* Get the phone # that was posted along with the new student,
* and assign it to the student via the newly-created ID.
*/
$phone = new StudentPhone();
if ($phone->load(Yii::$app->request->post())) {
$phone->student_id = $student->id;
$phone->save();
}
if ($affiliation->isSaved && $phone->isSaved) {
$transaction->commit();
$url = Html::a($student->name, ['update', 'id' => $student->id]);
Yii::$app->session->setFlash('success', 'Student added: ' . $url);
if (Yii::$app->request->post('then-add') !== null) {
return $this->redirect(['create']);
} elseif (Yii::$app->request->post('then-edit') !== null) {
return $this->redirect(['update', 'id' => $student->id]);
} else {
return $this->redirect(['index']);
}
} else {
$transaction->rollBack();
$msg = 'Unable to create student: ';
//!!! find a better way to extract the model errors
$msg .= serialize($affiliation->errors);
$msg .= serialize($phone->errors);
Yii::$app->session->setFlash('error', $msg);
}
}
return $this->render('create', ['model' => $student]);
}
示例14: actionSignupstudent
public function actionSignupstudent()
{
$name = $_POST['name'];
$id = $_POST['id'];
$email = $_POST['email'];
$pass = $_POST['pass'];
$model = new Student();
$model->name = $name;
$model->id = $id;
$model->email = $email;
$model->password = $pass;
$status = array();
if ($model->save()) {
$status["status"] = "ok";
$status["name"] = $name;
$status["email"] = $email;
$status["id"] = $id;
} else {
$status["status"] = "failed";
}
return json_encode($status);
}
示例15: 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->aProfessor !== null) {
if ($this->aProfessor->isModified() || $this->aProfessor->isNew()) {
$affectedRows += $this->aProfessor->save($con);
}
$this->setProfessor($this->aProfessor);
}
if ($this->aStudent !== null) {
if ($this->aStudent->isModified() || $this->aStudent->isNew()) {
$affectedRows += $this->aStudent->save($con);
}
$this->setStudent($this->aStudent);
}
if ($this->aTranslationLanguage !== null) {
if ($this->aTranslationLanguage->isModified() || $this->aTranslationLanguage->isNew()) {
$affectedRows += $this->aTranslationLanguage->save($con);
}
$this->setTranslationLanguage($this->aTranslationLanguage);
}
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
$this->doInsert($con);
$affectedRows += 1;
} else {
$affectedRows += $this->doUpdate($con);
}
$this->resetModified();
}
if ($this->adminUserCredentialsScheduledForDeletion !== null) {
if (!$this->adminUserCredentialsScheduledForDeletion->isEmpty()) {
\App\Models\AdminUserCredentialQuery::create()->filterByPrimaryKeys($this->adminUserCredentialsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
$this->adminUserCredentialsScheduledForDeletion = null;
}
}
if ($this->collAdminUserCredentials !== null) {
foreach ($this->collAdminUserCredentials as $referrerFK) {
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
}