/** * 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'); } }
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"); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(UsersRequest $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]; if ($request->input("user_type_id") === "1") { $student = Staff::create(['staff_number' => '00000']); $user = $student->user()->create($user); $user->makeEmployee('admin'); } else { if ($request->input("user_type_id") === "2") { $student = Staff::create(['staff_number' => '00000']); $user = $student->user()->create($user); $user->makeEmployee('lecturer'); } else { $student = Student::create(['student_number' => '00000']); $user = $student->user()->create($user); $user->makeEmployee('student'); } } return redirect("/users"); }
/** * Add contact to wordpress newsletter * @param ContactEvent $event * @param $newsletter string * @param $name string * @param $email string */ private function saveUser(ContactEvent $event, $newsletter, $name, $email) { if ($newsletter != 'newsletter') { return; } $this->name_split($name); $this->addEmailToList($email, $name); if (Student::isStudent($name, $email)) { return; } $newsletter_class = Student::create($event->getRequest()->all()); $newsletter_class->status = 'C'; $newsletter_class->save(); }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { return DB::transaction(function () use($data) { $data['status'] = "WAITING_APPROVAL"; $data['password'] = bcrypt($data['password']); $user = new User(); $user = User::create($data); if (isset($data['avatar'])) { $imageName = time() . '.' . $data['avatar']->getClientOriginalExtension(); $location = 'uploads/avatar/' . str_slug($user->name) . '/'; $data['avatar']->move($location, $imageName); $user->avatar = url($location . $imageName); } else { if ($data['gender'] == "F") { $user->avatar = url('uploads/avatar/defaultLady.jpg'); } else { $user->avatar = url('uploads/avatar/defaultMale.jpg'); } } $user->save(); $data['user_id'] = $user->id; switch ($data['UsertypeName']) { case 'Student': Student::create($data); break; case 'Parent': ParentModel::create($data); break; case 'Staff': Staff::create($data); break; default: Foundation::create($data); break; } return $user; }); }
protected function create(array $data) { $user = User::create(['name' => $data['name'], 'username' => $data['username'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'role' => 'student']); Student::create(['user_id' => $user->id]); return $user; }
/** * Create a new user instance after a valid registration. * * @param array $data * @return Student */ protected function create(array $data) { return Student::create(['firstname' => $data['firstname'], 'lastname' => $data['lastname'], 'gender' => $data['gender'], 'group' => $data['group'], 'phone' => $data['phone'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]); }
/** * Stores Student into database * * @param array $input * * @return Student */ public function store($input) { return Student::create($input); }
public function store(StudentRequest $request) { Student::create($request->all()); }