Laravel Movie App - Adding Actors - Part 7

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up guys welcome back and in this video I like to add actors to our application lots to do here so let's go ahead and get started so the first thing I want to do is add the index page for actors so if you go back to the PMDB website you'll see they have a section here for people and it's probably better to call it people because it also has other people with in movies like directors but I guess I'll just stick the actors so this page has an index of popular actors and it has pagination as well so let's go ahead and create that so first thing I wanna do is make a new controller of HP RS in make controller let's call it actors controller if you won't call the people controller and let's make it resourceful okay it's go into that actually just go into our routes file first and it's worked from there so I want these two routes but now for actors so let me just duplicate that and it's called this actors actors controller and this one will be actor slash actor and so the actors controllers show and it's renamed this to the actors okay so let's go ahead and go into the actors controller and start with the index return view actors index and I think in my views yes alright here I have them in the main views directory so I want a new one for movies and one for actors so let's make one for movies and it's moved those in there and I'm gonna make one for actors as well so let me just move this in there and let's go into our movies controller and make sure to update that as well so it should be movies index and same for the show down here will be show and you just run the tests to make sure that works in still works so let's go ahead and get started with our actors index index top blade PHP and I'm just gonna steal what I have here for now in movies copy that paste that in and it's changed so I will need popular actors so I don't need this section for now playing movies and say actors here popular actors popular actors and here is where our actors go and we don't need a blade component since it's only in one place so I'll just stick the grid in here so I'm just gonna make a div with an actor class and it's put March on top of eight and the first one will be the image and that's the link as well so let's do this and sister dimension here and I just pasted it in an image tag with a hard-coded image and with some classes here that have the transition on the hover so let's see if this looks okay better browser and let me actually link this first so let's go back to our main blade and for actors let's say route after stop index okay fresh and let's look like this okay cool and it's also add the actor name and like in tmdb there is some information about the movies or the TV shows they are known for so let's add that so right underneath here it's making a div empty to be a link let's give it a class of text large hover text for a 300 like we did for the other links and this would be the actor names Robert Downey jr. and here is where the known for movies will go it's just text so we'll do they have text small truncate so I want truncate so it doesn't go on multiple lines I just have dot dot dot and text gray 400 400 and say Ironman Avengers Avengers infinity war okay and let's see how this looks okay looking good and like I said it trunks it truncates it here because I just wanted to be one line and let me just duplicate this just to see if it's correct and then we'll start making it dynamic okay so it looks good to me okay so get rid of that and we can start working on grabbing the information from the API so actors controller and here we can grab the information so let me just go to my movies controller and grab something like this so popular movies but now it's gonna be popular actors so popular actors and the endpoint for that if you go into the docks it is called people I believe so people and there's one for popular so it's just person slash popular and if you look in my rest client I believe I have that here for actors index ends person popular and there are the results so there's twenty results and there's also five hundred pages which makes for ten thousand results and there's pagination here as well which we will also take a look at so let's go ahead and do that person popular so I said a movie popular its person popular and let's go ahead and pass this information to our view model because we're gonna make be making some transformations as well new actors view model which will make in a second and I'm passing in the popular actors okay let's go ahead and make that view model PHP artisan make view model and that's actors view model okay and it's import this now that's created okay and let's go to that view model so actors view model okay and let's go ahead and make that field so instructor and it's popular actors popular actors okay let's make this public and let's go ahead and make a public method for popular actors so we can transform it if we need to and we do so popular actors and this is return this for now return popular actors these popular actors okay and it's go back to our controller and it's passed this in the view model so view model okay so see if our controller or if our page still works and we have to import the HTTP facade okay okay go slow works so let's go ahead and start looping over these popular actors that we're getting so back to our show blade or sorry our index played not the movies the actors let's go ahead and start looping over them right here so for each popular actors as actor let's move this in there okay and let me just collect and dump this so we can see what we're doing like I did before just let's collect this and just dump it and we'll transform it in a second to prepare the data for our views okay there you see twenty actors being populated in their view and you can also see the information for each actor here so we can put the name because we don't need to transform that so let's go back to our show or our index and here we can do actor name and say that and I will go back to my view model and I'll start transforming the data here so similar to how we mapped over our movies or popular movies so let's take a look at what we did there so movies view model and we'll just sort of copy what we did there so it's in this format movies and I'm just gonna map over the actors and then merge them with the transform data we want so let's do that okay let's paste that in and we don't need this and this is gonna be popular actors there's popular actors and it's gonna be actor okay this will be actor as well and start with this one so this will be profile path instead of poster path profile bath and this will be profile path as well hey so the width is gonna be with 235 and height 235 underscore face and I got this by just inspecting these so let me go back here these I just inspected this and I looked at the image info and here you can see I kind of sworn that was 235 when I was doing it anyways you see the format there and this should work it might change based on my resolution and my resolution when the recording is different from when I'm working normally that should work let's just remove these and for the only I just want name ID profile path for now and see if this works so back to our app and go back to actors here on the find movie this should be actor and I'll go back to my index blade here and instead of this the hard-coded version I am going to use an actor profile path supposed to actor profile path okay let's see if this works back here refresh and it does seem to work cool and it seems to be a broken link for some of the actors that don't have a profile image so what we can do is just provide a placeholder when we need one so back to our view model so we have to check here so let's do a ternary here so actor profile path okay and specific on its own line and to make a question mark here and that should be when there is one and when there isn't one we can put a placeholder here so I'm just gonna paste this in so it's this service UI Abbott are calm and we give it a size four to 35 and that's just a square and we give it the actor's name and what this will do is generate an avatar based on the actors initials so see this works and there we go you see the initials here oh and just put a margin bottom on this popular actors section vector index or I can put a py on the entire thing okay cool okay now for the known for section here if you look at the dump did I remove the dump so yeah so my computer crashed if you don't see continuity here I had to restart my computer and start again so if I just dump this there you see the dumps up here and you can see I did include the known force outside that known for okay there we go see the known force for each actor you can see that it's an array and you'll see that we have a media type of movie here but sometimes this will be TV as well and if it's movie like it is here you'll see a title field here but if it's TV there's no title field it's gonna be a name field so let me show you what I mean so let's just do for a movie now so let's add a section here for known for which will overwrite the current one and we'll just transform it the way we want it let's do collect after no and for and we're just gonna grab the title because that's the only thing we're interested in so let's do pluck title and from here we can just implode to get our comma-separated list so it's implode okay so let's try this and you'll see what I'm trying to say here so I refresh and we have to use that in our view so instead of this we can do actor known for known for okay and now if i refresh you'll see that some of them do work so for example Vin Diesel is mostly in movies so you see his works but these people are a mix of movies and TV so it's not working and this guy is only TV so it's not working at all so what we have to do is do the same thing but for movies or sorry for TV shows we want to grab the name field because it's a name field for people in TV so we want to sort of combine these two different collections and there is a combined method on the collection but that's not the method we want the method we want is the Union method so if you remember your Venn diagrams let's make use of that method so before I plug the title here I'm just gonna grab the ones where the media type is TV because this one has titles so media type TV ok and let me get rid of this implode for now we'll add it after we add the Union and gonna copy this whole thing because we're gonna Union it with all the TV stuff so Union like this Union and then I start a new line I'm gonna close it here and here is where I'll put the implode so let's put that back yes but for the other collection let me paste that in and the media types gonna be sorry this one should be movies or movie and this one should be TV but the thing we're trying to pluck is called name now and that will add both so let's see if I did this right and I did there you see everything showing up regardless if it's TV or movies cool ok now let's add pagination so I'm just gonna add simple pagination with a previous and next but as you see here they have the paged or the numbered pagination I don't think that's necessary so let's go ahead and add a next in a previous button here so let's work on that first so that would be in my index after here I mean just spell this right it's add a section here this was gonna be flex justify between it's at a margin top of 16 or something and it's to say previous and next see if this looks okay okay so since we're not using models in our laravel app we have to make use of the API is pagination and it does support pagination you see here we have a page variable and they total pages and to pass in at the page we just have to do question mark page equals and then whatever so let's go ahead and do that so I'm gonna go to my routes file and make a new route here that supports pagination so this the one will be similar to this one but now it will have support for pagination and the format I'm going to do is page slash page and you can make it a query string if you want but I'll just leave it like this and I'm gonna make this page variable optional with a question mark and this is gonna go to the same controller and I won't give this a name because there's already an actor star index name and now we can accept that in our actors controller and we can give it a default value of 1 and in our end point we can append the page here let's do a dot page sorry it should be question mark page equals okay and let's pass in the page to the view model so we can make use of it there let's go to our actors view model let's accept a page here okay page let's make this public and let's go ahead and make two methods here one for previous and one for next so previous no params and let's just return if this top page is greater than one and we want to get this page minus one and if it's not then we'll just return now and it's do the same for next I'm just going to duplicate this and change it for next and 500 it's the greatest page we can do and I probably put this in a global variable somewhere because it's like a magic number but for now we'll just keep it and this will be plus one okay and back to our index view let's go ahead and add that sorry right now we can add links here page slash previous that's if it exists so let's wrap this in a if suppose you say if previous okay and put that in there and still the same for next let's moves up next next and next okay see if I did this correctly okay we are on page 1 by default and the Flex is now well it works but since there's no item there there's nothing on the left but this is say for work so does work goes to page 2 but there is no page 2 so I think I have the URL wrong I should be actors page 2 so back here should be actors in these ones after space hey stripes can go back to this page fresh and next and there we go we get the next page of actors and previously go back to one and one should still work and of course that doesn't work so I think there should be a leading slash let me fix that okay let's try again to refresh previous goes to one and it's the correct URL goes to three cool okay so everything's working and to fix this Flex thing we just have to give it an empty element so we can just do yes we can do it for both here actually it should be in here it has an else case so else there's an empty div is fine go and let's test the last case that'll be 500 and there should only be previous awesome so let me go back to the main actors page and this to me is pretty useless there is 500 pages that we can scroll through or that we can paginate through and that's too many so what I want to do is add infinite scroll here and the user can just keep scrolling until they want to so I'm gonna make use of infinite roll this infinite scroll package which is pretty easy to use and since we have pagination in place already it can integrate easily into our application so let's go ahead and add it so before I add it let me make a script section in our template so down here let me just add yield scripts and then in our index where we want to use it we can just add a new section here called scripts okay and it's in that section and their JavaScript can go in here so let's add a script and it's add this import okay and let's initialize it with vanilla JavaScript so I'm gonna copy this and paste it in here and let me just read that this and the query selector we want to make it work on is our grid here so let's add that and the path is the path we want in our pagination so in our case it's gonna be slash actors slash page and here is where the number goes or the page and I mainly have to wrap that in double curlies but this is JavaScript so we have to escape it with the @ sign and we want to append too if you go up here this is thing we want to pin to or the thing that's repeating so let's add that and history false I'm gonna remove and I'll show you what that does so let's go back here and see if this works that's all the config we need if I did everything correctly so if I keep scrolling you'll see that it loads to the next page and you'll see up here that the URL is changing that's what history false is if you don't want this to happen then you can add this back but I'm okay with it showing up and now that we have this we no longer need the previous and next pagination so we can get rid of that in our template I'll just comment it out in case you guys want to use it so just leave that in it was commented out okay and if you go into the options in the documentation and you click on status you'll see how to add a status indicator or a loading spinner as the new entries are loading so you can see there there's a quick one happening and the option we want to use is this status option and we'll just give it a class and here depending on the class name you'll see if it's loading or the end of content or an error so let's add this to our JavaScript it's right here it's add status and let's add this section as well so I'm gonna add this right here and I'm gonna make a few changes so let me just add a margin here and this is for errors so let me just put error in here and for the loading state instead of just the text loading I want to use a loading spinner and if you remember the livewire video we added a spinner using a table entailment plug-in and it's gonna paste that in and we still have this class because as to know if it's loading and then I just added the spinner class which is from a detail when plug-in that were using and I just made it a bit bigger and I need to add this non-breaking space for it to show up so let's go ahead and see if this works so back to our app let me just go back to page one actually I'm gonna have to open dev tools and throttle because it might be too quick so let's say fast 3G and let's see if we can see that loading indicator here and there it is it's not centered but I thought I made it centered but you can see it on the left there cool and we have to make it centered I have to add flex justify:center this has to be this has to be a container of this infinite scroll because this is position absolutely so let's try it again if I scroll down there it is in the middle awesome and let me just take care of the other case where it's at the end so right now we're getting an error and I guess you can just change this error to end of content that'll work too or if you want to give it the correct way we have to go back to our controller or actors controller and just put one more line here and just abort if and the condition we want to abort on is if the page is greater than 500 because there's only 500 pages and the status code is 204 which is no content and I think that should inform the plug-in that that's the end of content so this should now be end of content so let's try again for 500 there we go end of content awesome okay let's continue and now we can start working on the single actor page so let's go into our sublime and let's go into our routes and I already added it here so let's go into our controller and it's start in the show method and its return view actor start show okay let's make that in here showed up blade a PHP and let's grab the one from movies and work with that one so let's grab this and it's just delete to everything we don't need so I want to keep this this is the title with the stuff underneath the title this is the overview and we can get rid of this and this is a model which you don't need and for the movie cast I'm gonna keep this but this is where I'm gonna put the credits so credits here say movie credits or actually it should say credits because this is gonna include TV and movies and this is just gonna be a list so we don't need this and this is just a model which we don't need okay and credits okay so this is what we're working with let's just replace this with hard-coded stuff and we'll remove what we don't need or add what we do need and I don't think I need this okay and let's put some alarm text in here say 40 and this is the actor name so say well Smith and this should be good this is the image and I'm just gonna paste in an image here and this should be all hard-coded now so let's go back to our index played and it had the link there for clicking on an actor and that's gonna be the image here and the link here so let's to route actor star show and the parameter is actor ID so after ID okay and we also have to add this in our movies show so if you go into a movie we want actors to link here too so let's do that so that would be in movies show so if we scroll down here to the cast right here we can do it here and here oops and again let's to route actors show and the parameter is cast ID okay see if this works and now this should link to the actor page and it does cool so I'm gonna base this design on what they have on this page here so let's go into an actor here say this guy and we just zoom out a bit and I am going to put the birthday information and how old this person is right underneath the titles all right here so let's do that so back to our other show the actor show so I'm going to replace this star SVG with a birthday cake SVG okay and this is gonna be their birthday February 20th 19 whatever and I'm gonna put their age in here so I'll be 36 years old 37 actually you want to be correct and the next thing is their place of birth so let me just put Toronto Canada here and then we don't need this stuff anymore okay cool let's put a margin left on this or a bigger margin here okay and underneath here is where I want their social links so if you look here it's pretty much the same thing so let's add those so that would be underneath here so let's add an unordered list let's make a flex items Center let's go to margin top let's give it an Li and this will be a link to each of these socials so let's do one and I'll paste the rest in so this one will be Facebook let's give it a title so the user can hover over it they want and here is where the SVG will go to paste that in and let's see how that looks okay so that's good and I'm gonna paste the rest in okay so I pasted the rest in and we'll add this depending on if they exist or not for this particular actor and the next thing I want to add is they are known for movies so if you look here again you'll see a section here with they're known for movies or TV shows so let's add that so let's go underneath their description right here so let's do h4 class equals fonts and be bold let's put a margin top and this is gonna be known for and here is where our great little goal so great great calls one and we just add the rest of these so small and above great calls to large great calls five and cap eight and you can tweak this as you like and for each item it's gonna give them March on top so you don't even need that because there's only actually we do if it wraps depending on the size of the device and to say sometime it's gonna paste in the image it's just hard coded and as always there is a transition on it and the title here so let's see how this looks there should be five columns in there to this well we have to add five to have five columns so let's add four more two three four and then we'll loop over this in a second actually even more okay cool and then underneath here is where I went the credits to go and this corresponds to this stuff here so I don't really have a design for this it's just a list so let me just paste that in quickly so we can start grabbing the info from the API so it's just an unordered list and that's basically it and you'll see the date or the year the movie was released the name of the movie and the character that they play so oops wrong one so there you see it say it would be nice to design this a bit better for example I like what they do here and make it sort of look like a table and they separate the years with this horizontal rule but I didn't go that far in this example here and it's just a list okay so let's start making this dynamic so to get single actor information we just have to go to people slash person ID so let's go ahead and do that so let's go to our actors controller and it's grabbed the information from the API here so let's copy what we have in the movies controller for show okay so let's grab this info back to our actors and it's change this to actor and this is actor slash ID and we don't need all this stuff here and let's go ahead and make a view model for the actor so view model equals new actor view model and it's passing the actor and it's passing the view model here and let's make that view model as well so act or singular view model okay okay let's go to that view model aft or view model and let's go ahead and add you constructor property so act or okay and this will be public let's go ahead and make a method act or nothing and it's returned this actor actually let's collect it because I want to dump everything it's collected okay and let's see if our review still works if you model not found that's sure to import that okay okay still works so let's grab the name so I think we are on Will Smith right now so that won't change but it's go ahead and add it so let's go to our show and for Will Smith and this will be act or name see my dump here resource could not be found there should be people okay sorry it's person person ID okay so there's the information and we have a name so let's start with that back to our show so it should be act or name okay and that's not going to change but now it's pulling from the API and now let's grab the birthday and the place of birth which is within here so birthday let's also add the biography and place of birth okay let's add those and we'll change this in a sec let's just dump it out here at tor birthday and down here let's add the biography at or biography and lose the other one place of birth so outside that right here act or ace of birth okay so you just works okay but now we can start transforming our data so let's start with the birthday so back to our view model and we can merge here to merge and it's give it an array right here okay and it's transformed our birthday and this will be carbon parse this act or birthday and it's formatted like we formatted the other dates so M D Y let's make sure to import carbon okay and that should change it see if this works sorry there should be a comma okay and that is now in a new format and let's get the age here because every time I look for an actor I want to know their age without doing any math and carbon actually ships with an age field and all you have to give it is their birthday so say age and let me just grab this and instead of formatting we can just do age and I didn't know that until I did this it's good to know and now you'll see oops we have to use that so right here we can say after age and that should show the age of the current actor were on I see Will Smith is 51 years old okay now let's add the profile picture so back here it's over right the profile path and that's gonna be so sometimes there is no profile image so we have to check and do a ternary so this act or profile path so 3 is 1 then let me just grab one from the movies view model or movie view model so let me just grab this let's paste that in so it's gonna be this actor this is gonna be profile path and width I want is 300 and the rest is the same and we don't need this okay and if it doesn't exist let's just give it a placeholder so just my placeholder service that I'm using for the other part I used it before somewhere forgot where I used it but this is fine for a placeholder okay and now let's use that in our show for the image so actor profile path right here Act or profile path okay and see if this works should be an image of Will Smith no sorry no comma here okay there we go cool so now let's get the social information and that's not part of this request so let's go ahead and see where we can get that we go to external IDs you'll see this has information about their social so the endpoint is slash external IDs so let's grab that so back to our controller let's just duplicate this and some be social and it's just tack on external IDs here and it's also passed that into our view model social and while I'm here for this stuff so for the known for and for the credits we need another end point for that too and that end point is either movie credits TV credits or combined credits so I'm gonna do combined credits for now because I want the credit stuff to include TV as well so let's go ahead and add this end point as well so let's name it credits and that is slash combined credits ok and it's past that in as well okay and back to our view model let's add those two ok so I added those and now let's make a method for social okay and it's just returned let's collect it here so we can dump it as we've been doing this social and let me just call the merge here now just make it empty for now and it's a dump okay and now we should see social as well when we refresh this and their social right there cool okay so as you can see Will Smith has actually this website comes from the first request and the other two or the other three come from this social endpoint so let's do the website first so the website is what is it homepage just once to add that so back to our view so where's our homepage here right here so we have to check if it exists because sometimes it doesn't exist so let's do if act or homepage and is it the entire URL it is cool so let me just copy this and then we can put it in here and just indent this and we can do actor homepage in here okay and let's see if this links correctly okay and it does and it's do the same for the other two or the other socials but now we have to do that do that in the view model because it's not a full URL and I just want to pass it in so I'm gonna do one and I'll just paste the rest in supposed to Twitter here so Twitter is gonna be against a ternary and check if it exists and it's called Twitter ID okay and if it does exist then we'll add on the actual Twitter URL twitter.com slash and we can tack on this social Twitter ID okay but if it's not and just do no and I'm gonna do the same for Instagram and Facebook and it's gonna paste it in okay so I pasted that in let's work on our views here it's the same thing as the website so it's the home page it's just do one and then I'll paste at the restaurant let's just do Twitter here and it's the same thing like I said so yes if it's not actor now it's social Twitter then we can just I'll put that here and it's and we F here and see if this works and I don't think well Smith as Twitter he does not so it does work and I'm gonna add the other two as well okay so I added Instagram and Facebook let's see if this works and now you can see Will Smith's social links here cool okay now let's work on known for movies so this section right here and I want this to include movies and TV shows but since we don't have TV shows hit and it's gonna filter it down to movies but these credits will have TV shows as well so back to our view model let's go ahead and add a function here for known movies known for say titles known for titles because eventually this is going to include movies and TV shows so let's just do this for now so cast titles equals collect and we're passing V credits in from the end point I'll just dump this and just return it here cast titles okay and see what we get see if you get an extra end point here and we do so you see this has information for cast and crew and for this no movies I only want information for the cast because this is what contains the movies and I want to sort this by popularity as you see here there's a number for popularity because I want the most popular 5 to show up here so let's do that so let's collect this actually I want to get the cast here because that's all we interested in okay and we can collect this and I just want movies like I said we're movie type a media type is movies or movie movie okay and like I said I want to sort by the most popular so sort by descending and I wanna start by the popularity key and I only need 5 supposed to take 5 and let's just dump this to see what we're getting okay and then we refresh here and as you see there's only five here and they should be the 5 most popular movies because we filtered by movies so as you can see bad boys for life is the most popular based on this number here and the rest should work too okay so let's go ahead and transform what we need so I need a map here let me put this on its online some map here function movie and it's at this okay and here is where I want to transform the information so return collect movie merch like we've been doing here's where you can merge the information for each movie so we want poster path and I'm just gonna paste this into say some time again we're checking if it exists and if it does it is this image it's with 185 because it's pretty small and if not just put a placeholder in there and the other field that we need is in the title and I'm using is set here because sometimes the title doesn't exist I think when I was doing the demo project I was including TV shows and movies so I needed to use is set to check if this index existed because for TV shows movie title does not exist it's called name in TV shows but let's just leave it for now and if there is no title it's called untitled but I think this should be always this case because I filtered by movies here but I'll just leave it to what I have here actually I'm gonna rename this back to movies it makes more sense to me because right now we're just now we're just using movies for now maybe I'll rename it after we add TV shows so cast movies and this is cast movies as well okay so now we can loop over this known for movies so let's see if it works first so I have to add a semicolon here okay and it does work cool so we have a poster path and we have our title here okay so let's go ahead and start looping over this in our view let's go back to show and it's got it known for okay and we can delete these other ones only the first one so it's late all of these okay and now for each say known for movies as movie let's go ahead and move this up okay and let's replace this with the title so movie title okay for the image let's go ahead and replace this with movie poster path and for the link so for these two we just need the ID so we can do route movies dot show and the parameter is movie ID okay and hopefully I did everything correctly there we go cool that looks like it works and if I click on one of them this should go to the movie and it does cool so the last thing to do is this credits here so let's quickly do that so back to our view model so I'm gonna copy this because it starts off like this as well let's rename it to credits and we just want the cast or if you want you can add the crew for example if Will Smith directed a movie it would show I mean won't show now because now we're just doing cast so we're only showing movies and TV shows he acted in so now we want everything so we're gonna remove this where and we're gonna remove these sort and the take as well cuz we want everything so I'm gonna put this on this line here and actually we do want to sort it but we want to sort it after everything here so sort by descending release date and we're going to transform the release date in a second so let's go ahead and do that so let's start with the release date actually so still release date and I'm gonna make a variable here called a release date and we'll do that in a second and I'm gonna start pasting code because this video is getting really long so for release year again I have to check if it's set and if it is just format it by the year because I only want to output in the release year for title again I'm gonna put a variable here called title and for character again I'll paste it in and we serve to check if it's set because sometimes it's not set and if I don't check it and it will result in an error so for a release date again I'm gonna paste in some code and the reason it's a variable is because there are three cases and I can't just make a ternary here so I'm gonna paste it in and the three cases are if there is a release date then use that but for TV shows it's a first air date and release date doesn't exist so we're gonna use that as a release date and if there's nothing then just put an empty string and the same goes for the title here so it's paste that in and an arene dentist and that should do it if I did everything correctly now we just have to use this in the view so they just see if this works first or if it shows up in a dump okay we have syntax error okay there's an extra closing brace here I don't need this one the closer to class okay okay so it does work see what we get here so we still get everything because we want to list everything and this seems like it is working cool and I didn't do the only method like I showed you in the last video where you just want to output the fields that were using but maybe I'll all that to the final code but I'm not gonna edit here because this videos getting long so now all we have to do is use this information in here so let's quickly do that so back to our show down here so let's get rid of all of this and let's do a for each let's say credits as credit let's put this in here so this will be the release year credit release year so let's do that okay and then the next thing is the title so let's replace this with credit title title okay and the services as credit character if there is one credit character okay and back to my view model for a sec I'm using the release date here so it gets transformed here and then I'm sorting by the release date so let's see if this works okay and looks like it that was cool and let me look for fresh prints here just to see if it's outputting TV shows as well and it is cool and there's some issues with sorting here as you see some stuff gets sorted down here but I'm not too concerned about that this looks pretty good and if you just click around to different actors just see if this works correctly it still works awesome and I've also written tests which I'll go over now quickly so only three new tests that I've written and as you see this is the demo project I have because when I make videos I have a demo project and then I do it again while I'm recording so we have our actors test and probably we name is to view actors tests in the final code but it's pretty much the same as what I did for testing movies again I have a fake popular actors endpoint and then I'm just asserting against those fake actors that I have so if I run this test it passes and I didn't get rid of the dump you can see the dump there the next test I have is just to test that pagination works so I have another set of actors and it's called fake popular actors page to see if this works and it does cool and then the other test I have is for the single actor page and again I faked the three end points that we hit and then I just assert against that information and that passes do and I'll make sure to add this in this code for this project so there you have it guys where you added an actor's index page that lists all the popular actors with infinite scroll and we've also added information for single actors and it lists all their popular movies and their credits here say our app is starting to look like a real application with useful information please like comment and subscribe if you haven't already done so thanks for watching guys see you in the next one Kate thanks bye [Music]
Info
Channel: Andre Madarang
Views: 8,937
Rating: undefined out of 5
Keywords: laravel movies, laravel tmdb, tmdb api, tmdb api tutorial, laravel http client, laravel tailwind css, andre madarang, drehimself, laravel infinite scroll, infinite scroll
Id: AMaJx1dwYlE
Channel Id: undefined
Length: 63min 38sec (3818 seconds)
Published: Thu Apr 09 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.