Laravel Movie App - Refactoring to View Models - Part 6
HTML-код
- Опубликовано: 3 июл 2024
- We take a look at refactoring our code by simplifying our views and removing any logic from them. We make use of Spatie's View Model Package to extract any logic from the view into a View Model class.
Spatie Laravel View Models: github.com/spatie/laravel-vie...
GitHub Repo: github.com/drehimself/laravel...
TMDb API: www.themoviedb.org/documentat...
LINKS
My courses: codewithdre.com
Sign up for my newsletter: andremadarang.com/newsletter
My website: andremadarang.com
Twitter: / drehimself
GitHub: github.com/drehimself
CodePen: codepen.io/drehimself Наука
The ViewModelsare so powerful, I was able to refactor a lot further ( I also created Genre and Actor pages ) by using Traits.
Wow awesome. Cant wait to work an awesome good project like this another one
Thanks for watching!
Thanks for the content, in MovieViewModel the method flatten does not require, pluck('name') just enough.
Ty!
Amazing
I would love to see PHP Storm add click through to Components!
Awesome! Please shop / CMS / CRM in Laravel 7!
What will be the short syntax, I tried but it shows me that you have to update 7.4 in composer.json, can we use arrow function in map() .?
Good tutorial, but I really suffered with the complexity when within the MoviesViewModel in formatMovies function do a nested loop to get the genres, multiple mapWithKeys are made to get the genres for each movie genre.
I created a Genres route and updated my movie component to include the link. The tests now no longer pass. But because it is based on what it sees, and the Genres are part of the ViewModel I am not sure how to debug and correct the issues.
The output shows the links with the correct Genres, any tips, or tricks?
Hello, can you make a list of electron js?
hi please i want the name of the music at end of video?
Just some royalty-free music I bought on audio jungle. Forgot the name.
@@drehimself thank you
I read your reply to @felipe but I don't it exactly answers this question: can't view composer do what you did with Laravel view model?
Don't know if I'm missing something here. I am still a noob. But how does the formatMovies method in your MoviesViewModel know that the $movies parameter is the array of movies? Where did that come from? Can someone explain this to me?
didnt they just release that in laravel 7 as view components?
good
Hi, I was trying understand if Laravel view composers or a livewire component can do almost the same, didn't we? Or not? (it's my newbie doubt). Thanks for this amazing series.
I look at view composers as a way to share data across multiple views.
please make a spatie package tutorial
What package are you using for class import?
PHP Companion: github.com/erichard/SublimePHPCompanion
i'm getting this error Class 'App\Http\Controllers\MoviesViewModel' not found in the moviescontroller ?
Add this just below the namespace:
use Spatie\ViewModels\ViewModel;
how many tutorials totally?
How many parts do you need to complete it?
I have a few more already done. Not sure if I'm going to keep it going after that. We'll see.
All it needs now is a video encoder and player.... 😅
Haha