當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Currency::inRandomOrder方法代碼示例

本文整理匯總了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];
});
開發者ID:vlsoprun,項目名稱:store,代碼行數:31,代碼來源:ModelFactory.php


注:本文中的app\models\Currency::inRandomOrder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。