本文整理匯總了PHP中app\models\Currency::inRandomOrder方法的典型用法代碼示例。如果您正苦於以下問題:PHP Currency::inRandomOrder方法的具體用法?PHP Currency::inRandomOrder怎麽用?PHP Currency::inRandomOrder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\Currency
的用法示例。
在下文中一共展示了Currency::inRandomOrder方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: function
$file_name = 'currency-iso.xml';
$storage = Storage::disk('local');
if (!$storage->exists($file_name)) {
$storage->put($file_name, file_get_contents($url));
}
$xml = simplexml_load_string($storage->get($file_name));
$json = json_encode($xml);
$array = json_decode($json, true);
$currencies = $array['CcyTbl']['CcyNtry'];
}
$index = array_rand($currencies, 1);
return ['name' => $currencies[$index]['CcyNm'], 'code' => $currencies[$index]['Ccy'], 'number' => $currencies[$index]['CcyNbr'], 'unit' => $currencies[$index]['CcyMnrUnts'] === 'N.A.' ? 0 : $currencies[$index]['CcyMnrUnts']];
});
$factory->define(Product::class, function (Faker\Generator $faker) {
$content = $faker->paragraphs(random_int(1, 16), true);
$description = str_limit(trim(strip_tags(nl2br($content))), 156);
$name = $faker->name;
return ['name' => $name, 'description' => $description, 'content' => $content, 'slug' => str_slug($name), 'price' => random_int(1, 10000000), 'published_at' => Carbon::now(), 'category_id' => Category::inRandomOrder()->first()->id, 'currency_id' => Currency::inRandomOrder()->first()->id];
});
$factory->define(Category::class, function (Faker\Generator $faker) {
$content = $faker->paragraphs(random_int(1, 16), true);
$description = str_limit(trim(strip_tags(nl2br($content))), 156);
$name = $faker->word;
return ['name' => $name, 'description' => $description, 'content' => $content, 'slug' => str_slug($name), 'published_at' => Carbon::now()];
});
$factory->define(Attachment::class, function (Faker\Generator $faker) {
$url = 'https://source.unsplash.com/random';
$name = str_random(16) . '.jpg';
$property = app(\App\Services\ImageService::class)->make($url, $name);
return ['file' => $name, 'dick' => 'local', 'property' => $property];
});