/** * makes a user a hacker by default and gives them an application */ public function postSignupActions($roles = ["hacker"]) { foreach ($roles as $role) { $this->attachRole(Role::where('name', $role)->first()); if ($role == "hacker") { $app = new Application(); $app->user_id = $this->id; $app->save(); } } $this->generateUniqueIdentifier(); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(ApplicationRequest $request) { $data = $request->all(); if (isset($data['OralExamInvitationId']) && $data['OralExamInvitationId'] == '') { unset($data['OralExamInvitationId']); } $application = new Application(); $application->fromArray($data); $application->save(); flash()->success("ADDED"); session(['attribute' => \Lang::get('general.APPLICATION')]); return redirect($this->main_page); }
/** * 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->aApplication !== null) { if ($this->aApplication->isModified() || $this->aApplication->isNew()) { $affectedRows += $this->aApplication->save($con); } $this->setApplication($this->aApplication); } 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; }
/** * Display a listing of the resource. * * @return Response */ public function index(Request $request) { $storage_path = storage_path(); $sms_request = $request->all(); $phone_number = $sms_request['sender']; $description = json_encode($sms_request); $student = StudentQuery::retrieveByPhoneNumber($phone_number); if (is_null($student)) { $msg_text = 'Niste registrovani. Kontaktirajte administratora PMF-a.'; //$this->sendSms($phone_number, $msg_text, $description); exit; } if ($sms_request['sms_prefix'] !== 'PRIJAVA_ISPITA') { $msg_text = "Nepostojeca komanda! Za prijavu ispita poslati: ‘PRIJAVA_ISPITA <šifra_predmeta> <ispitni_rok>'"; $this->sendSms($phone_number, $msg_text, $description); exit; } $fullsms = explode(" ", $sms_request['fullsms']); $subject_code = isset($fullsms[1]) ? $fullsms[1] : null; $period_name = isset($fullsms[2]) ? $fullsms[2] : null; if (!isset($subject_code) && !isset($period_name)) { $msg_text = 'Doslo je do greske, proverite unete podatke.'; $this->sendSms($phone_number, $msg_text, $description); exit; } $subject = SubjectQuery::retrieveByCode($subject_code); if (is_null($subject)) { $msg_text = 'Nepostojeca šifra predmeta.'; $this->sendSms($phone_number, $msg_text, $description); exit; } $period = $this->getPeriodIdByName($period_name); if (is_null($period)) { $msg_text = 'Ispitni rok ne postoji'; $this->sendSms($phone_number, $msg_text, $description); exit; } $school_year_id = $this->getSchoolYearIdByDate(); $periodSchoolYear = PeriodSchoolYearQuery::create()->findPk([$period->getId(), $school_year_id]); if (is_null($periodSchoolYear)) { $msg_text = 'Ispitni rok ne postoji'; $this->sendSms($phone_number, $msg_text, $description); exit; } $studyProgram = StudyProgramQuery::create()->findPk([$subject->getId(), $student->getCourseId()]); if (is_null($studyProgram)) { $msg_text = 'Ovaj predmet nije u vašem studijskom programu.'; $this->sendSms($phone_number, $msg_text, $description); exit; } $msg_text = $this->allowedToApply($student->getId(), $subject, $period->getId(), $school_year_id); if ($msg_text !== null) { $this->sendSms($phone_number, $msg_text, $description); exit; } $application = new Application(); $application->setStudentId($student->getId()); $application->setSubjectId($subject->getId()); $application->setPeriodId(8); $application->setSchoolYearId(8); $application->setApplicationDate(date('Y-m-d')); $application->save(); $msg_text = 'Uspesno ste prijavili ispit.'; $this->sendSms($phone_number, $msg_text, $description, $application->getId()); exit; }
function denyApplication(Application $application, Request $request) { // Check if current user has permission $this->authorize('approve-application'); $application->status = 'rejected'; $application->judge_status = 'finalized'; $application->save(); // Send notification to judges and applicant event(new ApplicationChanged($application)); $request->session()->flash('success', 'This application has been denied.'); return redirect('/applications'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { if ($request->isMethod('post')) { $this->validate($request, ['type' => 'required', 'kcxh' => 'required|size:12']); $inputs = $request->all(); $course = Mjcourse::whereNd(session('year'))->whereXq(session('term'))->whereKcxh($inputs['kcxh'])->whereZsjj(session('season'))->firstOrFail(); $application = new Application(); $application->xh = Auth::user()->xh; $application->xm = Auth::user()->profile->xm; $application->nd = $course->nd; $application->xq = $course->xq; $application->kcxh = $course->kcxh; $application->kch = Helper::getCno($course->kcxh); $application->pt = $course->pt; $application->xz = $course->xz; $application->kkxy = $course->kkxy; $application->xf = $course->plan->zxf; $application->sf = '0'; $application->sh = '0'; $application->xksj = Carbon::now(); switch ($inputs['type']) { case 'other': $application->xklx = '0'; break; case 'retake': $application->xklx = '1'; $application->ynd = $inputs['ynd']; $application->yxq = $inputs['yxq']; $application->ykcxh = $inputs['ykcxh']; $application->yxf = $inputs['yxf']; break; default: $application->xklx = '0'; break; } if ($application->save()) { return redirect('application')->withStatus('课程申请成功'); } else { return back()->withInput()->withStatus('选课申请提交失败'); } } }