本文整理汇总了PHP中app\models\Student::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Student::create方法的具体用法?PHP Student::create怎么用?PHP Student::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Student
的用法示例。
在下文中一共展示了Student::create方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
}
示例2: 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']);
}
示例3: 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");
}
示例4: store
/**
* 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");
}
示例5: saveUser
/**
* 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();
}
示例6: create
/**
* 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;
});
}
示例7: create
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;
}
示例8: create
/**
* 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'])]);
}
示例9: store
/**
* Stores Student into database
*
* @param array $input
*
* @return Student
*/
public function store($input)
{
return Student::create($input);
}
示例10: store
public function store(StudentRequest $request)
{
Student::create($request->all());
}