Seeding In Laravel: Explained

Поделиться
HTML-код
  • Опубликовано: 28 сен 2024
  • 🚀 Laravel Seeding Explained! Master the art of populating your database with dummy data effortlessly. 🌱 Learn the basics, create seed classes, run seeders, and explore advanced techniques. Perfect for beginners and seasoned developers alike! 🔗 Dive in with our tutorial now! #laravel #webdevelopment #CodesEasy
    ########## For Doubts (ask it here) ################
    Discord: / discord
    Whatsapp group: whatsappgroup....
    ############################################
    ########## For Business Queries ##########
    Contact us for any business queries:
    Email: info@codeseasy.com
    Phone number: +918281536333
    WhatsApp: whatsapp.codes...
    ####################################
    Find us on Social Media:
    Website: www.codeseasy.com
    Telegram: t.me/CodesEasy...
    Facebook: / codeseasy
    Instagram: / codeseasy
    Twitter: / codeseasyblog

Комментарии • 3

  • @atuoisrael
    @atuoisrael 4 месяца назад +2

    Good job dude

  • @huynhkhaphi9191
    @huynhkhaphi9191 5 месяцев назад +1

    class ProductFactory extends Factory {
    ...
    public function definition() {
    return [
    'name' => $this->faker->name,
    'qty' => $this->faker->numberBetween(1, 100), // Adjust the range as needed
    'price' => $this->faker->randomFloat(2, 1, 100), // Adjust the range as needed
    'description' => $this->faker->paragraph,
    'created_at' => $this->faker->dateTimeBetween('-1 year', 'now'),
    'updated_at' => $this->faker->dateTimeBetween('-1 year', 'now'),
    ];
    }
    ...
    }
    class ProductSeeder extends Seeder
    {
    ...
    public function run() {
    $numberOfProducts = 10;
    Product::factory()->count($numberOfProducts)->create();
    // *this will work for Laravel 11.0*
    }
    }