本文整理汇总了PHP中app\models\Student类的典型用法代码示例。如果您正苦于以下问题:PHP Student类的具体用法?PHP Student怎么用?PHP Student使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Student类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: 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);
}
示例3: 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')]);
}
}
示例4: run
/**
* 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' => 'toniobarros@hotmail.com', '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');
}
}
示例5: actionPreregister
/**
* @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]);
}
}
示例6: run
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']);
}
示例7: store
/**
* 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");
}
示例8: getHome
public function getHome()
{
// $students = Student::getStudents();
$students = Student::getStudentsCheckedIn();
$notices = Notice::getNotices();
// print_r($notices);
return view('home', ["students" => $students], ["notices" => $notices]);
}
示例9: actionView
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]);
}
示例10: fire
/**
* 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!');
}
示例11: create
/**
* 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"));
}
示例12: 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]);
}
示例13: deleteStudent
public function deleteStudent()
{
$stud_id = Input::get('stud_id');
$User = Student::find($stud_id);
if (!$User->delete()) {
return 0;
} else {
return 1;
}
}
示例14: generateStudents
/**
*
*/
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'));
}
示例15: actionFilter2
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]);
}