Model Factories | Laravel For Beginners | Learn Laravel

  Рет қаралды 25,777

Code With Dary

Code With Dary

Күн бұрын

This video will show you how to setup model factories to create dummy data in Laravel - Learn one of the most popular PHP frameworks for its advanced features, templating engine, fast commands and security.
📚 New Udemy Course
If you're looking to level up your Laravel skills, my new course "Udemy Migirations, Seeders, Factories, Query Builder, Eloquent & Relationships" is the perfect opportunity. Learn the essential tools and techniques for building robust and scalable web applications with Laravel: www.udemy.com/course/masterin...
📲 Let’s plan a meeting
Plan a (paid) 1-hour meeting on Calendly to do portfolio reviews, code reviews resume reviews or a coaching session for Laravel. Please read the description before booking: calendly.com/codewithdary
💌 Newsletter
Sign up for my free weekly email newsletter: www.newsletter.codewithdary.com
🔥 Resources
- PHP Hosting (10% DISCOUNT): www.hostinger.com/codewithdary
- TikTok: / codewithdary
- Instagram: / codewithdary
- Twitter: / codewithdary
- Blog: blog.codewithdary.com/
- Newsletter: newsletter.codewithdary.com/
- Patreon: www.patreon.com/user?u=30307830
- GitHub: github.com/codewithdary
Want to learn more?
- Courses: / @codewithdary
📋 Table of Content
00:00 - Insert data into the database
02:33 - Userfactory
03:42 - Creating our own factory class
06:11 - PHP Artisan Tinker
#laravel #laravel8 #php #factory

Пікірлер: 53
@codewithdary
@codewithdary 2 жыл бұрын
LETS CONNECT THROUGH INSTAGRAM. www.Instagram.com/codewithdary
@tallitvak5325
@tallitvak5325 3 жыл бұрын
Thank you so much! you're so inspiring with not just going and using the functions we got from the framework, but to actually look them! I managed to deconstruct the Str::random function by myself, all thanks to you! I've never thought I'd go to source code and try understand what is going on there. You're are even more then a teacher, You're a mentor!
@codewithdary
@codewithdary 3 жыл бұрын
Yessir! Learning Laravel is relatively easy, understanding everything in Laravel is something else.
@melogian0816
@melogian0816 3 жыл бұрын
@ 6:00 PostFactory.php line 16. You don't need to add the entire path to the Post Model. You already declared a "use App\Model\Post" to resolve to that particular namespace. In this case "Post::class;" works fine.
@RafaleJCW
@RafaleJCW 3 жыл бұрын
Exactly
@codewithdary
@codewithdary 3 жыл бұрын
Thanks buddy :)
@CODINGVENTURE
@CODINGVENTURE 2 жыл бұрын
Damn, I’ve gone through so many tutorials but your tutorials are so good
@codewithdary
@codewithdary 2 жыл бұрын
Thank you so much buddy :)
@techjavaid6177
@techjavaid6177 3 жыл бұрын
I'm so lucky to find your channel.. You're a gem man...love your explanation... Awesome Tut's
@codewithdary
@codewithdary 3 жыл бұрын
Hi Naik, I really appreciate your kind words, guys like you are the ones that push me to create more!
@OnlyJavascript
@OnlyJavascript 3 жыл бұрын
@@codewithdary we love you Dary.
@nacerkraa9258
@nacerkraa9258 Жыл бұрын
Thank you so much you save my time
@codewithdary
@codewithdary Жыл бұрын
Happy to help Nacer :)
@blessed-favored
@blessed-favored 2 жыл бұрын
Loved it.
@codewithdary
@codewithdary 2 жыл бұрын
Thank you Harizon!
@josuebarros-desenvolvedorw2490
@josuebarros-desenvolvedorw2490 3 жыл бұрын
Wonderful course! Will you teach us more advanced concepts like: Livewire, Jetstream, Sanctum, Passport, InertiaJS and AlpineJS?
@codewithdary
@codewithdary 3 жыл бұрын
That's the plan!
@sulaimanmisri9570
@sulaimanmisri9570 3 жыл бұрын
In my case, when I use $model = \App\Models\Post::class, it will make the tinker error. So I just leave the path and use the default, which is Post::class; Then everything is run smoothly
@codewithdary
@codewithdary 3 жыл бұрын
Thanks for sharing Sulaiman!!
@relaxingmusicandsceneryfor5816
@relaxingmusicandsceneryfor5816 3 жыл бұрын
Hi Dary, Thanks a lot for the tutorials How do it on windows ? 1:49 Im trying to highlight and click ctrl and left click but it doesnt work.
@codewithdary
@codewithdary 3 жыл бұрын
Edit your settings.json (Hit F1, type Settings then Open Default Settings (JSON)) and adapt your configuration : Use : "editor.multiCursorModifier": "alt", To have Option+click as command to go to definition.
@relaxingmusicandsceneryfor5816
@relaxingmusicandsceneryfor5816 3 жыл бұрын
​ @Code With Dary hi dary, it's already set on default settings (json). any idea why it's still not working ? i am using windows. when i try to highlight for example the factory and hold alt+ left click nothing happens.
@mrs1mplee07
@mrs1mplee07 9 ай бұрын
When I use >>\App\Models\Post::factory(2)->create(); The system notifies that Error Class 'Database\Factories\Post' not found. What's wrong ??
@codewithdary
@codewithdary 9 ай бұрын
If you have recently created the PostFactory class or made any changes to it, make sure to run the following command to regenerate the autoloader: composer dump-autoload
@samnangmethiny2405
@samnangmethiny2405 4 ай бұрын
how do i click on Factory to see its properties? I use window, I tried hovering and click ctrl but it did not work
@brokersaddatv
@brokersaddatv 3 жыл бұрын
Hi. Can we install phpmyadmin and use it with laravel ?
@pandapushok
@pandapushok 3 жыл бұрын
Yes, you can use XAMPP or OpenServer or any other environment to run your DB. Just make sure to set up your .env DB configuration accordingly.
@KHKH-wy4yj
@KHKH-wy4yj 3 жыл бұрын
Thank you, Dary, It is really helpful for those who are beginners or refresher. It will be more interesting if you could add some advanced stuff also like [ 'multi auth', 'localisation', 'server driven app' ] with laravel
@codewithdary
@codewithdary 3 жыл бұрын
We will get there! :)
@kito2266
@kito2266 2 жыл бұрын
can we do logic in factory or seeder?
@codewithdary
@codewithdary 2 жыл бұрын
Well technically no, depends on what you understand as logic?
2 жыл бұрын
can you helep me : Trait 'Illuminate\Database\Eloquent\Factories\HasFactory' not found
@codewithdary
@codewithdary 2 жыл бұрын
not found meaning that class or trait is not in your project. can you check it in vendor folder with path Laravel > Framework > src > Illuminate > Database > Eloquent > Factories ? if in those folder you not have that Trait class, try to composer dump-autoload or maybe you need re-install your Laravel project.
@Rodrigo-nx4fg
@Rodrigo-nx4fg Жыл бұрын
Instead of: \App\Models\Post::factory()->count(2)->create(); You can type: \App\Models\Post::factory(2)->create();
@codewithdary
@codewithdary Жыл бұрын
Thank you for sharing :)
@josuebarros-desenvolvedorw2490
@josuebarros-desenvolvedorw2490 3 жыл бұрын
How can I get deployed to show my client before finishing up? Some clients are very anxious, and want to follow the development steps
@OnlyJavascript
@OnlyJavascript 3 жыл бұрын
It's all about in-depth Laravel tuts itself. Anything more will be planned accordingly by our guru ji.
@codewithdary
@codewithdary 3 жыл бұрын
I'll show you at the end of this course how we could deploy Laravel projects. Any recommendations of hosting sites? I think I might go with Bluehost.
@josuebarros-desenvolvedorw2490
@josuebarros-desenvolvedorw2490 3 жыл бұрын
@@codewithdary hmmm. Here in Brazil, Hostinger is very famous... I also heard a lot of Siteground, did you try it yet?
@OnlyJavascript
@OnlyJavascript 3 жыл бұрын
@@codewithdary trust me...namecheap is really good and cheap.
@aviwemusa6109
@aviwemusa6109 3 жыл бұрын
How to write this factory seeder on Laravel 8? public function run() { factory(Opportunity::class, 300)->create()->each(function ($opportunity){ $opportunity->detail()->save(factory(OpportunityDetail::class)->make()); }); }
@vinhvo4816
@vinhvo4816 3 жыл бұрын
Why i can't find factory in laravel?
@codewithdary
@codewithdary 3 жыл бұрын
I don't know? Difficult to help without the error :)
@rajabhishek2936
@rajabhishek2936 3 жыл бұрын
Awosem
@codewithdary
@codewithdary 3 жыл бұрын
:D
@rajeshbudhathoki7888
@rajeshbudhathoki7888 3 жыл бұрын
'title' => $this->faker->title(), generates titles such as Dr, Miss, Mr., Prof. If you don't want any duplication on the post, amend the following lines: 'title' => $this->faker->sentence(),
@codewithdary
@codewithdary 3 жыл бұрын
Thanks for sharing Rajesh! :)
@rajeshbudhathoki7888
@rajeshbudhathoki7888 3 жыл бұрын
@@codewithdary You are welcome ☺️ Thanks for the amazing course! 🙏
@codewithdary
@codewithdary 3 жыл бұрын
Thank you for watching Rajesh!
Query Builder | Laravel For Beginners | Learn Laravel
17:09
Code With Dary
Рет қаралды 24 М.
🤔Какой Орган самый длинный ? #shorts
00:42
WHO LAUGHS LAST LAUGHS BEST 😎 #comedy
00:18
HaHaWhat
Рет қаралды 20 МЛН
Introduction To Eloquent | Laravel For Beginners | Learn Laravel
45:20
Laravel Controller Code: Move to Model, Service, Action or Job?
12:51
Laravel Daily
Рет қаралды 104 М.
5 Laravel Relationship Tips That You Might Not Know About
8:21
How Ai Is About To Transform The World’s Economy
19:19
Andrei Jikh
Рет қаралды 21 М.