本文整理汇总了PHP中app\models\Student::truncate方法的典型用法代码示例。如果您正苦于以下问题:PHP Student::truncate方法的具体用法?PHP Student::truncate怎么用?PHP Student::truncate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Student
的用法示例。
在下文中一共展示了Student::truncate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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');
}
}