Ejemplo n.º 1
0
 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();
 }
Ejemplo n.º 2
0
 /**
  * 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);
 }
Ejemplo n.º 3
0
 /**
  *  Process the workshop application
  * @param $workshop_id int
  * @param Request $request
  * @return \Illuminate\View\View
  */
 public function processApply($workshop_id, Request $request)
 {
     $this->validate($request, ['name' => 'required', 'email' => 'required|email', 'address' => 'required', 'phone' => 'required', 'age' => 'required']);
     $page_workshop = Workshop::findOrNew($workshop_id);
     if ($this->student->isRegistered($request->get('name'), $request->get('email'), $workshop_id)) {
         $student_class = $this->student->getByEmail($request->get('email'));
         $student = isset($student_class->name) ? $student_class->name : '';
         return $this->getView('lessonregistered', compact('page_workshop', 'student'));
     }
     Event::fire(new WorkshopEvent($request, $page_workshop));
     $student_class = $this->student->getByEmail($request->get('email'));
     $student = isset($student_class->name) ? $student_class->name : '';
     $this->title = 'Yogaground Apply complete';
     return $this->getView('lessondone', compact('page_workshop', 'student'));
 }
Ejemplo n.º 4
0
 /**
  * @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')]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     User::truncate();
     Staff::truncate();
     Student::truncate();
     StudentNumber::truncate();
     StaffNumber::truncate();
     $user = ['first_name' => 'Jose Antonio', 'last_name' => 'Sinadinse', 'fullname' => '', 'password' => \Hash::make('password'), 'email' => '*****@*****.**', 'address' => 'Pretoria', 'cellnumber' => '000000000', 'user_type_id' => 1, 'state_id' => 1];
     if (StaffNumber::all()->count() == 0) {
         $stfnum = StaffNumber::create(["number" => 2000, "date" => date("Y-m-d")]);
     } else {
         $lateststfnum = StaffNumber::all()->last();
         $stfnum = StaffNumber::create(["number" => $lateststfnum->number + 1, "date" => date("Y-m-d")]);
     }
     $staff = Staff::create(['staff_number' => $stfnum->number]);
     $user = $staff->user()->create($user);
     $user->addPermission('admin');
     for ($i = 3; $i < 20; $i++) {
         $user = ['first_name' => 'Name' . $i, 'last_name' => 'Surname' . $i, 'fullname' => '', 'password' => \Hash::make('aleluia'), 'email' => 'josebarros' . $i . '@hotmail.com', 'address' => 'Pretoria', 'cellnumber' => '00000000' . $i, 'user_type_id' => 3, 'state_id' => 1];
         if (StudentNumber::all()->count() == 0) {
             $stdnum = StudentNumber::create(["number" => 200000000, "date" => date("Y-m-d")]);
         } else {
             $lateststdnum = StudentNumber::all()->last();
             $stdnum = StudentNumber::create(["number" => $lateststdnum->number + 1, "date" => date("Y-m-d")]);
         }
         $student = Student::create(['student_number' => $stdnum->number, "university_id" => 1, "faculty_id" => '', "department_id" => '', "course_id" => '']);
         $user = $student->user()->create($user);
         $user->addPermission('student');
     }
 }
Ejemplo n.º 6
0
 /**
  * @param $id
  * @return \yii\web\Response
  * @throws NotFoundHttpException
  * @throws \yii\db\Exception
  */
 public function actionPreregister($id)
 {
     $model = $this->findModel($id);
     $user = User::find()->where("id=" . Yii::$app->user->id)->one();
     $user_id = $user->id;
     $student = Student::find()->where("user_id=" . $user_id)->one();
     $student_id = $student->id;
     $vacancy = ProjectVacancy::find()->where("project_id=" . $id)->one();
     $vacancyValue = $vacancy->vacancy;
     if ($existe = StudentProfile::find()->where(['project_id' => $id, 'degree_id' => $student->degree_id])->one()) {
         if (Registration::find()->where(['student_id' => $student_id])->one()) {
             Yii::$app->getSession()->setFlash('danger', 'Ya te has pre-registrado a un proyecto');
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             if ($vacancyValue > 0) {
                 $newRegistration = new Registration();
                 $newRegistration->project_id = $id;
                 $newRegistration->student_id = $student_id;
                 $newRegistration->student_status = "preregistered";
                 $newRegistration->save();
                 Yii::$app->db->createCommand()->update('project_vacancy', ['vacancy' => $vacancy->vacancy - 1], 'project_id=' . $id)->execute();
                 Yii::$app->getSession()->setFlash('success', 'Te has pre-registrado al proyecto');
                 return $this->redirect(['view', 'id' => $model->id]);
             } else {
                 Yii::$app->getSession()->setFlash('danger', 'No hay cupo para este proyecto. Escoge otro.');
                 return $this->redirect(['view', 'id' => $model->id]);
             }
         }
     } else {
         Yii::$app->getSession()->setFlash('danger', 'No cuentas con el perfil solicitado');
         return $this->redirect(['view', 'id' => $model->id]);
     }
 }
Ejemplo n.º 7
0
 public function run()
 {
     DB::table('students')->delete();
     Student::create(['student_id' => 'M21132111002', 'batch' => '25', 'department' => 'CSE', 'user_id' => '2']);
     Student::create(['student_id' => 'M21132111009', 'batch' => '27', 'department' => 'BBA', 'user_id' => '3']);
     Student::create(['student_id' => 'M21132111003', 'batch' => '26', 'department' => 'English', 'user_id' => '4']);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(StudentsRequest $request)
 {
     $user = ['first_name' => $request->input('first_name'), 'last_name' => $request->input('last_name'), 'fullname' => '', 'password' => '0000', 'email' => $request->input('email'), 'address' => $request->input('address'), 'cellnumber' => $request->input('cellnumber'), 'user_type_id' => $request->input('user_type_id'), 'state_id' => 1];
     $student = Student::create(['student_number' => '00000']);
     $user = $student->user()->create($user);
     $user->makeEmployee('student');
     return redirect("/students");
 }
Ejemplo n.º 9
0
 public function getHome()
 {
     // $students = Student::getStudents();
     $students = Student::getStudentsCheckedIn();
     $notices = Notice::getNotices();
     // print_r($notices);
     return view('home', ["students" => $students], ["notices" => $notices]);
 }
Ejemplo n.º 10
0
 public function actionView($id = null)
 {
     if (!$id) {
         return $this->render('/site/error', ['name' => 'Bad request', 'message' => 'id is not defined']);
     }
     $dataProvider = Student::find()->where(['id' => (int) $id]);
     return $this->render('view', ['dataProvider' => $dataProvider]);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     foreach (Student::all() as $student) {
         $picture = file_get_contents('http://local-sig.utt.fr/Pub/trombi/individu/' . $student->student_id . '.jpg');
         file_put_contents(public_path() . '/uploads/students-trombi/' . $student->student_id . '.jpg', $picture);
     }
     $this->info('Done!');
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     $users_list = Student::lists("student_number", "id");
     if (Auth::user()->isStudent()) {
         $users_list = [Auth::user()->id => Auth::user()->student->student_number];
     }
     $companies_list = Company::lists("name", "id");
     return view("pages.sos_requests.create", compact("users_list", "companies_list"));
 }
Ejemplo n.º 13
0
 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]);
 }
Ejemplo n.º 14
0
 public function deleteStudent()
 {
     $stud_id = Input::get('stud_id');
     $User = Student::find($stud_id);
     if (!$User->delete()) {
         return 0;
     } else {
         return 1;
     }
 }
Ejemplo n.º 15
0
 /**
  *
  */
 private function generateStudents()
 {
     $levels = array(Student::LEVEL_A1, Student::LEVEL_A2, Student::LEVEL_B1, Student::LEVEL_B2, Student::LEVEL_C1, Student::LEVEL_C2);
     $oldestMktime = mktime(0, 0, 0, 0, 0, date('Y') - $this->getConfig('student_max_age'));
     $newestMktime = mktime(0, 0, 0, 0, 0, date('Y') - $this->getConfig('student_min_age'));
     $prepareItemData = function ($itemNum) use($oldestMktime, $newestMktime, $levels) {
         return ['Student Name ' . $itemNum, "test{$itemNum}@email.com", date('Y-m-d', rand($oldestMktime, $newestMktime)), $levels[rand(0, count($levels) - 1)]];
     };
     $this->loadByPortion($prepareItemData, Student::tableName(), ['name', 'email', 'birthday', 'level'], $this->getConfig('students_num'));
 }
Ejemplo n.º 16
0
 public function actionFilter2()
 {
     $teachers = [];
     $students = [];
     $teachers = Teacher::findBySql("\n            select t.name, t.id from (\n                select st2.teacher_id st2, st3.teacher_id st3, count(st3.student_id) cnt from teacher_student st2\n                    left join teacher_student st3 on st3.student_id = st2.student_id and st2.teacher_id != st3.teacher_id\n                    where st3.teacher_id is not null group by st3.teacher_id, st2.teacher_id\n                    ) res \n                    left join teacher t on t.id=st2\n                    left join teacher t2 on t2.id=st3\n                    order by cnt DESC limit 2\n        ")->all();
     if (count($teachers) == 2) {
         $students = Student::findBySql("\n                select * from teacher_student st\n                left join student t on t.id = st.student_id \n                left join teacher_student st2 on st2.teacher_id = :teacher1 and st2.student_id = st.student_id\n                where st.teacher_id = :teacher2 and st2.teacher_id is not null\n            ", [':teacher1' => $teachers[0]->id, ':teacher2' => $teachers[1]->id])->all();
     }
     return $this->render('filter2', ['teachers' => $teachers, 'students' => $students]);
 }
Ejemplo n.º 17
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Session::has('student_id') === false) {
         return Redirect::route('oauth.auth');
     }
     $student = Student::find(Session::get('student_id'));
     if ($student) {
         View::share('student', $student);
     }
     return $next($request);
 }
 public function __construct()
 {
     $this->middleware('auth');
     $user_types = UserType::lists("name", "id");
     $states = State::lists("name", "id");
     $users_count = User::with("state")->latest()->get()->count();
     $universities_count = University::latest()->get()->count();
     $sos_count = SosModel::latest()->get()->count();
     $students_count = Student::latest()->get()->count();
     $companies_count = Company::latest()->get()->count();
     \View::share(compact("users_count", "universities_count", "sos_count", "states", "user_types", "students_count", "companies_count"));
 }
Ejemplo n.º 19
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = StudentModel::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(['id' => $this->id, 'name' => $this->name]);
     return $dataProvider;
 }
Ejemplo n.º 20
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Student::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(['id' => $this->id, 'user_id' => $this->user_id, 'faculty_id' => $this->faculty_id, 'current_semester' => $this->current_semester]);
     return $dataProvider;
 }
Ejemplo n.º 21
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Student::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(['id' => $this->id, 'classid' => $this->classid, 'created_dt' => $this->created_dt]);
     $query->andFilterWhere(['like', 'course_id', $this->course_id])->andFilterWhere(['like', 'stucode', $this->stucode])->andFilterWhere(['like', 'fname', $this->fname])->andFilterWhere(['like', 'lname', $this->lname])->andFilterWhere(['like', 'faculity', $this->faculity])->andFilterWhere(['like', 'major', $this->major])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'score', $this->score])->andFilterWhere(['like', 'past', $this->past])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
Ejemplo n.º 22
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Student::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(['st_id' => $this->st_id, 'st_active' => $this->st_active]);
     $query->andFilterWhere(['like', 'st_fname', $this->st_fname])->andFilterWhere(['like', 'st_lname', $this->st_lname])->andFilterWhere(['like', 'st_address', $this->st_address])->andFilterWhere(['like', 'st_postcode', $this->st_postcode])->andFilterWhere(['like', 'st_mobile', $this->st_mobile])->andFilterWhere(['like', 'st_phone', $this->st_phone])->andFilterWhere(['like', 'st_email', $this->st_email])->andFilterWhere(['like', 'st_disp_id', $this->st_disp_id]);
     return $dataProvider;
 }
Ejemplo n.º 23
0
 public function actionProfile($params = [])
 {
     if (Student::isAuthorized()) {
         $student = new Student();
         $student->loadModelFromDb(['email' => $_COOKIE['email']]);
         if (isset($_POST) && !empty($_POST)) {
             // TODO: validate user input
             // TODO: replace 'on' value in $_POST["local"]
             $student->fetchSchema();
             foreach ($_POST as $key => $attribute) {
                 if ($student->{$key} !== $attribute) {
                     $student->modifiedAttributes[$key] = $attribute;
                 }
             }
             if (!empty($student->modifiedAttributes)) {
                 $student->update();
             }
         }
         $this->render('profile.php', ['student' => $student]);
     } else {
         Router::error('403');
     }
 }
Ejemplo n.º 24
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Student::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(['id' => $this->id, 'dob' => $this->dob]);
     $query->andFilterWhere(['like', 'studentNum', $this->studentNum])->andFilterWhere(['like', 'firstName', $this->firstName])->andFilterWhere(['like', 'surname', $this->surname])->andFilterWhere(['like', 'email', $this->email]);
     return $dataProvider;
 }
Ejemplo n.º 25
0
 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postRegister(Request $request)
 {
     $validator = $this->validator($request->all());
     $post = $request->all();
     $value = $post['regNo'];
     $determiner = Student::where('studentNo', $value)->pluck('studentNo');
     $determiner1 = Management::where('id', $value)->pluck('id');
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     } elseif ($determiner == null && $determiner1 == null) {
         return 'The registration number (' . $value . ') that you have entered does not exist in our database';
     }
     Auth::login($this->create($request->all()));
     return redirect($this->redirectPath());
 }
Ejemplo n.º 26
0
 public function search($input)
 {
     $query = Student::query();
     $columns = Schema::getColumnListing('students');
     $attributes = array();
     foreach ($columns as $attribute) {
         if (isset($input[$attribute]) and !empty($input[$attribute])) {
             $query->where($attribute, $input[$attribute]);
             $attributes[$attribute] = $input[$attribute];
         } else {
             $attributes[$attribute] = null;
         }
     }
     return [$query->get(), $attributes];
 }
 /**
  * Updates an existing StudentPhone model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $studentId = $model->student_id;
     $student = Student::findOne($studentId);
     if (!user()->can('updateStudent', ['student' => $student])) {
         setError('Access denied.');
         return $this->redirect(['/student/view', 'id' => $studentId], 403);
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['student' => $student, 'model' => $model]);
     }
 }
Ejemplo n.º 28
0
 public function search($params)
 {
     $query = Student::find()->joinWith('affiliations.handAnchor.day')->joinWith('affiliations.handAnchor.frequency')->joinWith('affiliations.school')->joinWith('phones')->joinWith('division')->joinWith('promotions.rank')->groupBy('student.id')->where(['affiliation.school_id' => user()->schoolId]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     // load the search form data and validate
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     // we only get here if there are filter params in the GET
     //dump($params);
     //dump('active=', $this->active);
     // adjust the query by adding the filters
     $query->andFilterWhere(['dob' => $this->dob, 'spar_auth' => $this->spar_auth, 'grapple_auth' => $this->grapple_auth, 'belt_size' => $this->belt_size, 'gi_size' => $this->gi_size]);
     $query->andFilterWhere(['student.active' => $this->active])->andFilterWhere(['like', 'prefix', $this->prefix])->andFilterWhere(['like', 'gender', $this->gender])->andFilterWhere(['like', 'fname', $this->fname])->andFilterWhere(['like', 'mname', $this->mname])->andFilterWhere(['like', 'lname', $this->lname])->andFilterWhere(['like', 'kai_number', $this->kai_number])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'notes', $this->notes])->andFilterWhere(['like', 'day.name', $this['handAnchor.name']])->andFilterWhere(['like', 'student_phone.number', $this->bestPhoneNumber])->andFilterWhere(['like', 'division.name', $this->division_id]);
     return $dataProvider;
 }
Ejemplo n.º 29
0
 public function postEdit($id)
 {
     $student = Student::get($id);
     $student->studentName = Request::input('studentName');
     $student->studentRank = Request::input('studentRank');
     $student->studentPhone = Request::input('studentPhone');
     $student->email = Request::input('email');
     $student->img1 = Request::input('img1');
     $student->img2 = Request::input('img2');
     $student->img3 = Request::input('img3');
     $student->img4 = Request::input('img4');
     $student->img5 = Request::input('img5');
     $student->save();
     // print_r($student);
     return redirect("/students");
 }
Ejemplo n.º 30
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Student::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 100], 'sort' => ['defaultOrder' => ['name' => SORT_ASC]]]);
     $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(['id' => $this->id, 'birth_dt' => $this->birth_dt]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'level', $this->level]);
     return $dataProvider;
 }