本文整理匯總了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');
}
}