[Laravel 7 Lesson 12] Factories & Seeders (Seed database with faker data)

Поделиться
HTML-код
  • Опубликовано: 23 ноя 2024

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

  • @yongkitanumiharjo8523
    @yongkitanumiharjo8523 4 года назад +1

    good content and not boring. this is GOLD

  • @fadhilinjagi1090
    @fadhilinjagi1090 4 года назад +2

    Great video. I think I'm going to follow the whole tutorial. It's step by step and easy to understand.

  • @mojtabavahdati7648
    @mojtabavahdati7648 4 года назад +1

    I've liked this video because it's obvious that the author has put his precious time for making this video as much enjoyable as possible, but please notice that Laravel seeders can run query builders as well, they're not limited to use factories. That can be quite useful when the data we're seeding is not completely random to be created using the Faker. Thank you anyways.

  • @AmirulIslam-gg2fn
    @AmirulIslam-gg2fn 4 года назад +1

    Awesome video. Clean!!

    • @CleanCodeStudio
      @CleanCodeStudio  3 года назад

      Hey, hey - living up to the Clean Code Studio name!

  • @ahmedsobhy6174
    @ahmedsobhy6174 4 года назад +1

    I think u are one of the most underrated channels on youtube ... great video man, u got my sub for sure

    • @xaviergraysen1298
      @xaviergraysen1298 3 года назад

      A trick : you can watch series on kaldroStream. I've been using it for watching all kinds of movies these days.

    • @hamzajaxx2230
      @hamzajaxx2230 3 года назад

      @Xavier Graysen Yea, have been watching on kaldroStream for months myself :D

    • @musaking5991
      @musaking5991 3 года назад

      @Xavier Graysen yea, I've been using kaldrostream for months myself :)

    • @ronanmaison6361
      @ronanmaison6361 3 года назад

      @Xavier Graysen yea, been watching on kaldrostream for months myself :D

    • @kaisonzeke6757
      @kaisonzeke6757 3 года назад

      @Xavier Graysen yup, have been using Kaldrostream for since december myself :)

  • @justtestingmycurrentskills747
    @justtestingmycurrentskills747 4 года назад +2

    How do you do one to one relationships with Factories?

    • @CleanCodeStudio
      @CleanCodeStudio  4 года назад +5

      Great question. Define a factory for the related model, and use a call back function (Example Below)
      // Define a user factory
      $factory->define(Post::class, fn (Faker $faker) => [
      'title' => $faker->title,
      'content' => $faker->content,
      'user_id' => fn () => factory(User::class)->create()->id,
      ]);

  • @BhupendraTool
    @BhupendraTool 4 года назад

    my tinker is working but when i try seeder it shows ( throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e)
    my model name is Todos ,
    Illuminate\Contracts\Container\BindingResolutionException
    Target class [TodosSeeder] does not exist.
    at C:\laragon\www\udemy\vendor\laravel\framework\src\Illuminate\Container\Container.php:807
    803|
    804| try {
    805| $reflector = new ReflectionClass($concrete);
    806| } catch (ReflectionException $e) {
    > 807| throw new BindingResolutionException("Target class [$concrete] does not exists") C:\laragon\www\udemy\vendor\laravel\framework\src\Illuminate\Container\Container.php:805
    ReflectionException::("Class TodosSeeder does not exist")
    2 C:\laragon\www\udemy\vendor\laravel\framework\src\Illuminate\Container\Container.php:805
    ReflectionClass::__construct("TodosSeeder")

  • @RoshanLakmalTinTin
    @RoshanLakmalTinTin 4 года назад +1

    Thanks

  • @arlingholguin
    @arlingholguin 3 года назад

    Como agrego un campo faker de una fecha yyyy-mm-dd hh:mm:ss con la condición que sea en el mismo mes que se crea. Tengo esto pero no me genera el formato y por otro lado me genera un fecha muy distante.
    'start' => $this->faker->DateTime,
    'end' => $this->faker->DateTime,

  • @pabloinberlin
    @pabloinberlin 3 года назад

    I recommend having a look at how CakePHP deals with fixtures using factories:
    ruclips.net/video/PNA1Ck2-nVc/видео.html
    github.com/vierge-noire/cakephp-fixture-factories