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.
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, ]);
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")
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,
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
good content and not boring. this is GOLD
Appreciate it!
Great video. I think I'm going to follow the whole tutorial. It's step by step and easy to understand.
Great to hear!
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.
Great point!
Awesome video. Clean!!
Hey, hey - living up to the Clean Code Studio name!
I think u are one of the most underrated channels on youtube ... great video man, u got my sub for sure
A trick : you can watch series on kaldroStream. I've been using it for watching all kinds of movies these days.
@Xavier Graysen Yea, have been watching on kaldroStream for months myself :D
@Xavier Graysen yea, I've been using kaldrostream for months myself :)
@Xavier Graysen yea, been watching on kaldrostream for months myself :D
@Xavier Graysen yup, have been using Kaldrostream for since december myself :)
How do you do one to one relationships with Factories?
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,
]);
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")
Thanks
For sure for sure!
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,
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