当前位置: 首页>>代码示例>>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;未经允许,请勿转载。