“Image Faker Laravel 8” Réponses codées

Image Faker Laravel

use Faker\Generator as Faker; 
$factory->define(Product::class, function (Faker $faker) {
    return [

        'amount' => $faker->randomFloat(2, 0, 10000),
        'image' => $faker->image('public/storage/images',640,480, null, false),

    ];
});
Long Leopard

Image Faker Laravel 8

$factory->define(App\User::class, function (Faker\Generator $faker) {
    static $password;

    $filepath = storage_path('avatars');

    if(!File::exists($filepath)){
        File::makeDirectory($filepath);
    }

    return [
        'name' => $faker->name,
        'email' => $faker->unique()->safeEmail,
        'password' => $password ?: $password = bcrypt('secret'),
        'remember_token' => str_random(10),
        'avatar' => $faker->image($filepath,400, 300)
    ];
Careful Copperhead

Réponses similaires à “Image Faker Laravel 8”

Questions similaires à “Image Faker Laravel 8”

Plus de réponses similaires à “Image Faker Laravel 8” dans PHP

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code