/** * Store a newly created Education in storage. * * @param int $facultyId * @param EducationRequest $request * @return Response */ public function store($facultyId, EducationRequest $request) { $faculty = Faculty::find($facultyId); $education = new Education(['name_of_degree' => $request->name_of_degree, 'institute' => $request->institute, 'year' => $request->year, 'remarks' => e($this->htmlEditor->parseHtml($request->remarks))]); $faculty->education()->save($education); Flash::success('Faculty education added successfully'); return redirect("/admin/faculty/{$facultyId}"); }
/** * Show the form for editing the specified Publication. * * @param int $facultyId * @param int $id * @return Response */ public function edit($facultyId, $id) { $publication = Publication::with(['faculty', 'researchArea'])->find($id); $facultyName = Faculty::find($facultyId)->name; $researchAreaList = ResearchArea::lists('name', 'id')->all(); $typeList = ['journal' => 'Journal', 'conference' => 'Conference']; return view('admin.faculty.publication.edit', compact('facultyId', 'facultyName', 'researchAreaList', 'typeList', 'publication')); }
private function linkToFaculty(Project $project, array $input) { if (isset($input['faculty'])) { $id = $input['faculty']['id']; $faculty = Faculty::find($id); $project->faculty()->associate($faculty)->save(); } return $project; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Faculty::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['fac_ID' => $this->fac_ID]); $query->andFilterWhere(['like', 'fac_Name', $this->fac_Name])->andFilterWhere(['like', 'fac_Code', $this->fac_Code]); return $dataProvider; }
public function doEdit(Request $request, $id) { $project_input = $request->get('project'); $project = Project::find($id); if (!$project) { return redirect('backend/admin/project'); } $project->fill($project_input); $project->faculty()->associate(Faculty::find($project_input['faculty']['id'])); if ($project_input['status']['id'] != "") { $project->status()->associate(ProjectStatus::find($project_input['status']['id'])); } else { $project->status()->associate(ProjectStatus::where('key', '=', 'draft')->first()); } $project->save(); return redirect('/backend/project'); }
echo $form->field($user, 'email')->textInput(); ?> <?php echo $form->field($model, 'phone')->textInput(['maxlength' => true]); ?> <?php if (Yii::$app->user->can('projectManager')) { echo $form->field($rol, 'organization')->textInput(); } else { if (Yii::$app->user->can('socialServiceManager')) { echo $form->field($rol, 'faculty_id')->dropDownList(ArrayHelper::map(Faculty::find()->all(), 'id', 'name')); } else { if (Yii::$app->user->can('student')) { echo $form->field($rol, 'faculty_id')->dropDownList(ArrayHelper::map(Faculty::find()->all(), 'id', 'name')); echo $form->field($rol, 'degree_id')->dropDownList(ArrayHelper::map(Degree::find()->all(), 'id', 'name')); echo $form->field($rol, 'current_semester')->textInput(); echo $form->field($rol, 'enrollment_id')->textInput(); } } } ?> </div> </div> <div class="form-group"> <?php
public function delete($id) { return [Faculty::find($id)->delete()]; }
public function doDelete($id) { Faculty::find($id)->delete(); return redirect('/backend/faculty'); }
/** * Remove the specified Faculty from storage. * * @param int $id * @return Response */ public function destroy($id) { $faculty = Faculty::find($id); if (file_exists(public_path("uploads/faculty/faculty_{$faculty->id}.jpg"))) { @unlink(public_path("uploads/faculty/faculty_{$faculty->id}.jpg")); } //delete education $faculty->education()->delete(); //delete publication foreach ($faculty->publication as $publication) { $publication->researchArea()->sync([]); } $faculty->publication()->delete(); //delete faculty $faculty->delete(); Flash::success('Faculty deleted successfully.'); return redirect('/admin/faculty'); }
private function linkToFaculty(User $user, array $input) { if (isset($input['faculty'])) { $id = $input['faculty']['id']; if ($oldFac = $user->faculty()->first()) { /* @var Faculty $oldFac */ $oldFac->users()->detach($user->id); } $faculty = Faculty::find($id); $faculty->users()->attach($user->id); } else { if ($oldFac = $user->faculty()->first()) { /* @var Faculty $oldFac */ $oldFac->users()->detach($user->id); } } return $user; }