本文整理汇总了PHP中app\Category::Create方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::Create方法的具体用法?PHP Category::Create怎么用?PHP Category::Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Category
的用法示例。
在下文中一共展示了Category::Create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$categorys = array('Technology', 'Science', 'Education', 'Entertainment & Arts');
$description = array('The application of scientific knowledge for practical purposes, especially in industry.', 'The intellectual and practical activity encompassing the systematic study of the structure and behaviour of the physical and natural world through observation and experiment.', 'The process of receiving or giving systematic instruction, especially at a school or university.', 'The action of providing or being provided with amusement or enjoyment.');
for ($i = 0; $i < count($categorys); $i++) {
Category::Create(['title' => $categorys[$i], 'description' => $description[$i]]);
}
}
示例2: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
// $this->call('UserTableSeeder');
//Member::Create(['username' => 'louis', 'password'=>'pw','secretquestion'=>'Where is your birth place?','secretanswer'=>'Hong Kong']);
Member::Create(['username' => 'admin',
'password'=>'admin',
'secretquestion'=>'Where is your birth place?',
'secretanswer'=>'Hong Kong']);
/*Category::Create ([
'name' => 'Nature'
]);
Category::Create ([
'name' => 'Architecture'
]);
Category::Create ([
'name' => 'People'
]);
Category::Create ([
'name' => 'Tech'
]);
Category::Create ([
'name' => 'Animals'
]);
$faker = Faker::create();
for ($i=0; $i<100; $i++){
$title = '';
$detail = $faker->realText(450,2);
$hadstock = true;
$slug = $title;
$publisher = $faker->name();
$company = $faker->company();
$price = 0.0 + Rand(1,60000) / 100;
$cid = 0;
$imgsrc = 'http://placeimg.com/268/249/'.'nature'.'/'.Rand(1,100);
switch (Rand(0,4)){
case 0:
$cid = 1;
$imgsrc = 'http://placeimg.com/268/249/'.'nature'.'/'.Rand(1,100);
break;
case 1:
$cid = 2;
$imgsrc = 'http://placeimg.com/268/249/'.'arch'.'/'.Rand(1,100);
break;
case 2:
$cid = 3;
$imgsrc = 'http://placeimg.com/268/249/'.'people'.'/'.Rand(1,100);
break;
case 3:
$cid = 4;
$imgsrc = 'http://placeimg.com/268/249/'.'tech'.'/'.Rand(1,100);
break;
case 4:
$cid = 5;
$imgsrc = 'http://placeimg.com/268/249/'.'animals'.'/'.Rand(1,100);
break;
}
$maxTitle = Rand(1,5);
for ($j=0;$j < $maxTitle; $j++){
$temp = '';
switch (Rand(0,6)){
case 0:
$temp = $faker->cityPrefix();
break;
case 1:
$temp = $faker->streetSuffix();
break;
case 2:
$temp = $faker->citySuffix();
break;
case 3:
$temp = $faker->word();
break;
case 4:
$temp = $faker->century();
break;
case 5:
$temp = $faker->lastName();
break;
case 6:
$temp = $faker->stateAbbr();
break;
}
$title .=' '. $temp;
}
$newProduct = Product::Create ([
'cid' => $cid,
'title' => ucwords($title),
'imgsrc' => $imgsrc,
'detail' => $detail,
'hadstock' => $hadstock,
'publisher' => ucwords($publisher),
'company' => ucwords($company),
//.........这里部分代码省略.........