Listing and Creating Offices

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] [Music] [Music] um [Music] oh [Music] [Music] so [Music] [Music] foreign [Music] so hello everyone and welcome to the stream today we are going to continue building the application that we started in the last stream and this application is called ergodnc if you remember what it is all about if you don't remember i'm going to remind you in a bit but for those of you joining us for the first time in this series of streams we are building a laravel application from scratch it's not a tudor application not a blog application it's a fully featured laravel application that will allow us to use a lot of the components and a lot of the features of the laravel framework and let's let me take a look at the chat to know who is joining us today oh we have nunu from the laravel team thank you nunu for supporting me in this stream thank you for being with me nunu is a great colleague and he's a smart laravel developer hello everyone all right so let me adjust the camera angle just a little bit i think that's okay hello everyone hello hamed hello adries hi ray hello sheesham hello steve king hi everyone thank you for joining me today i think we are ready to go so let me share my screen and i will tell you all about this app that we are building so today we are building an app or in this series we are pending an application that's like air pnp but for renting offices for remote workers an office just like this room one with an ergonomic desk an ergonomic share that remote workers can rent to work in a quiet environment with good internet connection so this is the point of this app in the previous stream we prepared the database schema the migrations the model factories we prepared the model classes and we also started implementing the controller that will last the tags that can be attached to the offices the listings in the application we also started work working on the lasting end points that lasts all the offices in the system that people can browse to find whatever suits them to make reservations so we started working on that but we didn't complement implementing it so that's what we are going to start with today so let's take a look at the to-do list for today today we are going to continue working on the less offices endpoint we want to show only approved and visible records and we on we we want to allow people to filter the offices by a host to fill their offices by a specific user a user who made a reservation to an office he wants to check what offices he visited before or he made he made reservations on before we want to include the tags the images and the user or the host the user that the office belongs to the host of the office we want to include these entities and these collections with the response and we want to show the count of previous reservations along with each office so people know which reservations or which offices are hot and being reserved for a lot from a lot of people and we also want to imaginate this endpoint and we want to sort by distance so if people provide longitude and latitude we want to sort the results based on how close a specific office is to the location that they provided so this is something interested that we are going to do together and then after we finish that we are going to look into intro the count of previous reservations on each on the office and we are going to include the tags and images and user in the response as well and finally if the time allows we are going to work on creating the office endpoint and we have a rule that the host that creates a office should be authenticated and should have his email verified and also the approval status cannot be set in this endpoint because it's something that only admins can set and we will also work on attaching photos to an office so hosts can show people how the office looks like in order for people to find it interesting and make a reservation so that's what we are going to work on today let me take a look a quick look at the chat and then we can get started hello from philippines hi there i'm glad you like the quality of the webcam i spent a lot of time trying to configure it and i don't think it's perfect yet but i'm working on it getting there hello hamid hello steve king what's the difference between a user and the host a user is just you at airpnp you are looking for an office to make a reservation to and a host is one who owns an office or several offices that he rents to other people to use is there a github for the source code yes there is let me bring it here here we go if you had to yes if we had if you had to them say it ergodnc you can find the source code of the application we are building and i'd appreciate it if you guys report any issues that you see and make put requests to make the code faster to make it more readable to make it easier to maintain to add more tests whatever thing you think that should be added to the application may feel free to send pull requests and i will review them live in one of the streams so that's the source code all right let's i think we're good to go let's get started now we have let's extend this window and then we are going to start with the office controller we stopped last time at this stage where we only list all the offices in the system and we have a list a test for that so office test office controller test and this test just verifies that it's listing uh three or less thing all the offices in the system but we don't want that first we want to make sure that the end point is vaginated so we will start with that and to do that instead of calling the get method we are going to call the paginate method and let's say we want to display 20 [Applause] offices per response and with that let's see if this test will still pass so we will go to the terminal and php unit filter equals office controller test and we can see that it's passing ah let me do something first let me exit docker to make things faster and i'm gonna start valet because i have it stopped because before this stream i was recording a video for the uh welcome to laravel youtube channel where we uh welcome to laravel series on the youtube channel where we use laravels here to demonstrate all the features of laravel and i'm gonna switch to valet because i forgot that before the stream at least we know that the test passes let's take a look at the response here so we're going to do response dump i think yes response dump so if we run the test again we can see the response is different it's not just the data and returning all the listings in the system but it's also returning links for the first and last page in our case we only have a single page and there are meet the data about the imagination that we are doing so now we are sure that this endpoint is badginated so let's change the name of the tests actually let's close this here and i shared last time that the way i prefer to write tests is by using this syntax instead so it lists all offices in badginated way so that's what i'm going to call the test and then i'm going to copy the body of the test from here to there and that's all we need now we need to make sure that the json or this response contains a cert contains a desert or assert jason let's see we want to make sure that there is meta let's run this test no sir jason or assert json contains json fragment we can just do a cert data assert json meta here and make sure that it's not null that way we know that it's also providing some meta attributes and it's providing links as well that way we are sure that this endpoint is returning paginated results you may use a third json structure yeah i think i think that's the one i was looking for but we will stick with what we have for now and then we can refactor later now go back let's go back to the todo and we have the imagination done let's show only approved and visible records and to do that i'm gonna use the where method and what was the name of the database record a database attribute so we go there and we check the approval status so where approval status equal office and we find the status for approved approval approved here and we also want to make sure that where the hidden field is false to make sure that we only we are only returning records or offices that are not hidden now we want to test that and we will go to the office controller test and we will test that let's close the todo here office controller test and check the test here it only lists offices that are not hidden and approved so let's create three let's create three offices here by default inside the factory or each office created by the factory is going to be approved by default and not hidden so these three offices that will be created will be should be visible in the end point and let's create another office and this time the office is going to be hidden so it's hidden equals true and we will create another office with approval status spending and we shouldn't see any of these so office status office status pending approval bending all right so and we should let's remove this we make a call to the same endpoint assert okay and assert the count return it is only three these two shouldn't be returned in the payload so let's go to the terminal and run the test and we are good to go it's only returning offices that are approved and are not hidden let's go back to the todo and this is done now this one is easy to include tags images and users but let's first work on filtering by hosts and filtering by users gonna take a look at the chat a quick look at the chat to me to see if there are any questions that i need to answer so what do you think about this structure we'll call them something cool on something oh yeah you mean here instead of having office control instead of having two wares to have one where and provide an array with everything that we need i honestly prefer to have to array arrays because i think that's easier for me to read i group all the arrays under each other and if i want to remove something in the future i can just remove the line instead of having to worry about the structure of the array so it's my personal preference i'd imagine the approval status approved will be used fair pit in that context i always encourage the use of local scopes yeah i think you're right i think we're going to use local scopes inside the office model for the approval state and also for the hidden state to make sure that we are if we if we query we will only use the or we will only get the records that are not hidden but that's something for the future yeah maybe use factory states for approved and hidden yes we can use factory states as well we can refactor to that in the future but for now i'll just spike and then stabilize so this is the stage where i spike i just get things done and then stabilize and use uh things later and refactor the code and that's that's that's the way i work i think we're good to go let's continue we are going to the office controller and we will allow listing or filtering by hosts and filtering by users now i need your opinion on this guys if the user provided a host id to the request we shall return only offices that belong to this host but inside the table so the office table here the hosts the attribute that defines the host is called user id we can rename it to host id of course to t to say that this is the host of the office but having it at user id is easier for us to link that this attribute is linked to the user table in the database so from the database point of view it's better to call it user id because it's pointing to the users table but from the code point of view this is the host the terminology of this is the host not the user the user is someone who made the reservation on the office so the naming is a bit uh problematic for me i'm not sure what's the best but i will go for just using the host and query the user column uh when the host id is provided so for that i'm going to use the when method all types so i'm going to use the one method and i'm going to say when the request contains host id then filters this will accept an instance of builder so filter the results where user id equals request host id let me do this it's not okay so request host id so what we are saying here if the request contains a host id filter the results by user id that's what i think that's that's what that's the good i think that will work so let's take a look at the chat no questions all right let's continue now we need to make sure that this works so we will go to the test office controller test and we're going to add another test so test it filters by host id and we are going to create three offices and we are going to create a user factory create and oh i didn't so let me let me do that really quick fix the font size screencasts all right this should be better yes okay so we have three offices with different hosts and we created a host and we are going to create another office factory for this user and call the create method so we should have three offices with different hosts and an office that belongs to this host and we are going to make a request to this endpoint again and make sure that it's responding okay and the data return it should be only one office let's do this update the request and provide a host id equals dot host id now let's run the test and see if it will work and it works it only returned one record which is the record that belongs to the host id that we are filtering with all right and i think we should also verify the response that it's returning the office that we are expecting not only that uh that it's returning one record but it's the record that we do expect so i think for that we are going to use this asset equals office id and then we bring the response let's close this the response json data zero and the id should match the id of the office that we are expecting so let's run the test and it works that's all we need so now we can mark this as done in the total filter by hosts the next thing we're going to work on is filtering by users let's go to the controller and we need to filter by users we are going to use the one method again and this time we are going to expect a request square a query i or a query called user id and when this happens [Music] builder we should not fun okay builder we need to query all the offices that has a reservation that belongs to this user id and to do that we can use the newly added where relation method and the relation should be reservations the relation name because inside the office model the relation we are querying is the reservations relation so reservations and let's type in this builder look one builder just tweak can so we can get auto completion the where relation method expects the name of the relation the column the operator and the name so in that case we want to query the user id column on the reservations table and it should be equal to the request user id that was provided i think that should work let me take a quick look at the chat please explain more the win condition the win condition here accepts three arguments but in that case we are only using two the first one is the condition what we are saying here is that if this one this code this piece of code returned something that evaluates to true invoke disclosure so if the request contains a host id info disclosure and this closure is going to filter the results by the id of the user so that's basically what the win method does if this evaluates to true invoke that that's that's it that's as simple as this all right i think we're good no questions let's test that this works so we are going to go to the test office test office controller test and we are going to create a new test let's just copy this instead of having to recreate all this code it filters by user id and we are going to create three offices and we are only and we will create a user and we will create an office a single office this office should has or has for reservation how to create there's four with for the belongs to method and there was a way we so we can create has i think that has let's try that reservation factory all right i think that's it this should create an office that has a reservation right and this reservation should belong to a user id you see i'm not sure about this part factory oh i think yeah i think that this won't work all right let's try something else instead of the has we need to check how to create the factory with some that with create a factory of a model and along with it create several other models that belong to this one so i need i will need to research this and maybe refactor it on the next stream so now we have an office and we are going to create a reservation factory for this office and the reservation belongs to a user id which is the user we would expect i think we can also because here with an office and user i think we can also call for and provide the user so for here for users and then create so this should create a reservation that belongs to this office and belongs to this user and if we filter the results by user id we should only get the office a single office which is the office that has a reservation that belongs to this user so let's run this test to make sure that everything works and it works nice is there anything else that we need to uh check what if by mistake we made a mistake that will return offices that has reservations not only offices that had reservations to pillow that belong to the user so let's create another reservation for another office so this is just an office another offer a different office that has a reservation that belongs to a completely different user this shouldn't return this office in the response we only want this office to be returned this office shouldn't be returned because it belongs or it has a reservation that belongs to a user not the user that we are expecting so let's run the tests and it works it's only returning one office and it's the office that we are expecting i think that's all the assertions that we need for this test let me take a quick look at the chat [Music] the spati query builder package would be good for defining filters here swear by it on apis definitely i like this package it's a really wonderful package it will allow us to clean the code inside the controller this code instead of all this ones and all these wears we can use this package maybe we will refactor to using this package in a future stream but for now i'm just going to use raw queries to show people how to do things without packages and then we can refactor to packages sometime later now let's move on let's go to the to-do now we can filter by users include tags images and user let's check the office model there ha there are images and there there is the user but we don't have the tags relationship defined so let's do that function tags this one should return this belongs to many tag class i think that's all we need let's add the return type so we need to return the user or the host that this office belongs to the images that this post has and the tags that this post belongs to along with the response so let's do that office controller test and we're going to call the with method and provide the names or provide the relationships that we want to load in our case we want to load the images and we want to load the tags and we want to load the user as well let's run the tests to make sure everything is still working up and we are having a failure let's take a look at the exception wow so let's take a look at question base table review not found of a stack because we are defining the naming convention inside the office the naming convention we need to provide the name of the table because we are using a different name so office migration here the name of the table is offices tags not office tag let's try that and all is working again perfect now let's go to the office controller test and create a test it includes images tags and users so here we want to copy this no not this yes copy this and copy this as well or let's just create an office factory create and this office is going to have tags so we need is there a tag factory that we created yeah we have a tag factory so we need to create a tag factory uh this one doesn't have the relationship configured so let's do this reserve offices and this should return this belongs to many office class and then offices tax the name of the table let's verify yes offices tax so this should be all right let's go back to the test we are going to create a tag and for this office no that's not actually what we want we want to create a tag and we want to create a user so user equals user factory create and this office belongs to this user for user and we have a tag here and we have an image right we want to create an image we have an image factory we have an image factory how how do we how is the relationship between the office and the image office the php more many all right so we are going to just create an image image factory and what we are going to do is that we are going to attach the tags office tags right attach this tag and we are going to attach the image as well using a dash image i'm not sure if this will work let's see not executed but no exceptions so i think we're good let's take a look at the response dump response dump that's i think it's not running the test for some reason it's not running the test oh yeah because there is no test here so it doesn't know that this is a test right thank you for helping guys so here oh and we have an exception yeah because resource type doesn't have and because here it shouldn't be attached images the morph many how to attach to a morph many more fun or many how do you attach to this guys is there an attach method no so save yeah so save here this should work nope wait wait a second what we want to do here is to add a belongs to many a morph many relation we want to attach an image to an office how do you do that guys create is it create create and then what what should create expect attributes yeah ah right so it's just create we can we won't create a factory for this we won't create a fake so we want to create a record that has a path for an image just an imaginary image from the php unit tests and here we go thank you thank you for the help so yeah i don't know why i got confused about it maybe i got distracted a bit but that's actually how you do it you create an image that belongs to this office and now let's take a look at the response the data of the response includes the images and it includes the tags and it includes the user so it's all working great so response okay and we want to assert that the record let's do an assert not null this assert assert is array and we provide the response json data the first result in the response and the first result should has a tags attribute which is an array and a images attribute that is an array and a user attribute that has an id that matches a cert equals that matches the id of the of this user that we attach so let's run the tests and it's all green now we can uh check the number of records returned so assert count we expect only one image and we expect only one tag in the array so let's test that and it's all passes all right now this is done let me take a quick look at the chat when you use service or something like that that we see in larger projects i'm not sure what you mean if but if by service is that it's that you isolate the actions of a single of a service inside a class and then use this class when you communicate with this service yeah maybe maybe we will use that all right i don't think we have any questions here that i need to address so let's move next we have we want to show the count of previous reservations so let's go to the office controller and we will use the wiz count method and provide the reservations relationships so this should return the number of reservations on each of the offices but we not only want the number of reservations we want the number of uh active reservations ones that are not cancelled so let's to do that we want to provide a closure so function builder and i think the syntax for this is builder where let's take a look at the reservation table in the database it has status yes so status where status reservation let's find the status active equal one so we want to count all the reservations on each office that has status active which is one so let's go to the terminal make sure nothing is break is broken and here we go now we go to the test office controller test we create another test so test and this time it returns the number of active reservations what we want to do here is we call it this point endpoint assert okay this is this is what we will do and we are going to return we are going to create an office so office equals office factory create and we will attach several reservations to this office so we will create a reservation factory one uh for this office a reservation for this office all right and we want to set the create we want to set the status to reservation approved status approved status active i'm sorry and we want to create another one with status cancelled we expect to see the count returned in the response and we expect this count to p1 because the other reservation is cancelled it's not an active reservation and we only want to see active reservations so let's call this and dump let's run the test and we can see here it's returning reservations count and it's equal to one so our code works we expect the json to contain a reservations count here reservations count and it should be equal to one it shouldn't return it shouldn't count the other reservation so let's run the test all good let's run all tests all good let's save and we are good to go if we go to the to-do we are done with this now let's get back to the chat to see if we have any questions and i think we are good we don't have any questions thus four as attach and test or i missed something you mean the end office controller test here you mean this four yeah here we're saying that we are going to create a reservation for this office or belongs to this office and we are going to create it with the status this status provided here so for here saying saying that we are creating a model that belongs to this office we are good now let's work on this this is something interesting sort by distance if longitude and latitude are provided otherwise we want to sort all these records first so let's open the office controller and we need to sort by longitude and latitude if they are provided and otherwise we want to sort by the oldest firsts and to sort by lungs longitude and latitude i have this i found this answer on stack overflow here that it shows this query that will allow us to order by distance from a given point start point and or a a longitude give a longitude and to give a latitude and it's going to scan the records and order them by the distance from this point i see the answer is quite voted up and it was updated so i think it was revised by several people i think it's good enough maybe it will work we will see we will test now i have already used this answer great so i think it works not sure if it's the best answer it's the best query with the best performance if any of you guys watching this stream or is going to watch the play pack has any notes on how to make or if this query is the best query to order by distance or not and if we can on what indices that we should add to the table to make this query more performant if you have any insights on that on this please help that's really appreciated so let's let's use this query and to do it we need to yeah i formatted it a little bit here just to save time what we need to do is instead of ordering by latest we are going to use win again and what we need to say here if the request contains a latitude and the request contains a longitude both then this will receive an instance of builder then we need to run this query here the query will be here otherwise we are going to filter so builder we are going to filter by the oldest first so order by id ask all right so if this condition but if this condition is true if the user provided a latitude and a longitude we are going to sort by the distance here otherwise we are going to sort by the uh order of the uh of the records with the oldest record coming first because the oldest records it's more valuable in our system we need to present it to the users more instead of newer records that will be on the at the back of the list so let's work on that let me take a quick look at the chat hamid abraham says that he tested this answer this query and it works fine i've already used this answer all right so this should be oh okay let's use it now to provide the query inside the controller here i already don't try it don't like that the controller contains a lot of queries i don't like that i i like to keep the controller only dealing with input from the user and how to present output so typically we will validate the input somewhere here the filters that are provided and return the output all these things i don't think that they should belong to the controller but given that we don't have really many uh filters and many query conditions to add i think keeping it at the controller is fine for now we can later look into refactoring this if we want but for now we are just going to keep it in the controller but this we won't keep in the controller because it's a lot uh it's it's going to be a lot of noise inside the controller to have this query from this answer so what we are going to do is that we are going to create a scope on the office model and we will call this school nearest to maybe nearest we'll call it scoop nearest two and this scoop is going to have an instance of the builder the look one builder builder and let's close this for now and the second argument of the scope is the let's provide the latitude and the longitude that are coming from the request and then it should return an instance of builder here with the query that we want and in that case we want to include the distance and we want to order by it inside the scope and to do that let's call select row and get this neat formatting of the query that we just saw in the answer i just formatted it i did nothing more than just formatting it so we don't waste time formatting it and we want to provide the latitude and the longitude that are coming from the request to fill the query here and make it work and then at the end we are going to order by distance which this query adds to the select statement of the query of the main query and this this is it we are using the select row method to add another attribute to the query i'm not sure if attribute at the right word this attribute is called distance and it will evaluate this function and this function accepts a longitude and latitude i think this should be an array yes and this function or this query requires a latitude to be replaced here and a longitude to be replaced here and that's what we are going to provide here as the array of bindings and at the end we are going to order pi distance we need to make sure that this works so what we're gonna do is go to the office controller here and we will use the scope builder and call nearest two and provide the request latitude and the longitude coming from the request so eloquent is going to pass these values to the scope here and it should work let's make sure that nothing is proofing by just running the tests and all is working nothing is broken it's broken now we need to verify that this actually works and this is not going to be easy here is how we are going to test it let's create a test method sorry test and it orders by distance when coordinates are provided right and what we want to do with this test is create a couple of offices and use actual data from the map to verify that the distance or the the the order is correct this is going to take some time so let me just hide this for a moment maps.google.com i don't want to reveal my current location so instead of the default of google maps that chose egypt let's travel to portugal because members of the laravel team and the larval community just did a vacation in portugal recently and the photos are amazing and i'm envious of them so we are going to travel to portugal just to make sure that we catch up with the guys so if we are standing at the spawner let's copy the coordinates and go back to phpstorm and we are going to create an office office equals office factory create and we're going to provide the latitude that we just copied the longitude that we copied and we are going to call this office oh no no no that's not what we want we just want to keep the latitude and longitude of lesbonne here let's keep it here and we want to create offices outside legepona and compare the distance so let's see what's outside legepona what's the nearest city here this one that i cannot pronounce so let's copy its coordinates so here and here torres vedras i think all right so that's office and there's another office office number two and this one let's make it a bit far let's yeah travel here get the coordinates this like this and here and this one is called laria maybe yeah right so we have two offices so we have two offices and these offices are located in two different cities we know that this office is closed closer it's uh closer to our tourism so let's create the far office first so this office one which is the one that's further and this is the one that's closer and we want to send a query or send a request here and we are going to provide the longitude equals this one which represents the spawner and latitude this one or i'm so i think that's the lat first and then the long longitude all right so that's the request office controller test office controller here yeah that and long we are sending lat and long and let's take a look at the response response dump let's find the name of this test and then go to the terminal and run this test and see the response the response here returned two records one and it sorted them by the distance correctly so this one is closer than this one so the sword looks okay but the other attributes of the model are not there and i think that's because inside the scope we override the select which is by default select all so we should run select here we should add select here if we hit the test again and here we go all the attributes of the model are returned and there is the distance and it's sorting or it's sorting the results by the closest one which is the torus vedras city is closer to the spawner than the lyria city which is what we expect so the office controller test let's go back to the office controller test here and we want to set okay and we want to make sure that the first record here has a name of uh this one was closest so we expect it to come first and then the second one no i'm sorry i'm a bit distracted so the name should be this one and the name of the second record should be this one let's run the test and undefined array key name json data data zero let's see what's inside this our title it's not name it's title so title here and here let's run the test and it works okay and if we provide another request but without the longitude and latitude we expect to see different results we expect to see the sort not by distance but by what's older in the database which in this case should be the lyria so here should be lyria and here should be the other city and if we run the test again all works so now we know that the query that we got from a random answer on stack overflow on the internet is working let's store our work and go to the to-do and mark this as done let me take a quick look at the chat do you guys have any questions for me all right typically i like the name second office rather than office 2 what do you think you can use second office you can use office to whatever is good for you maybe you can assign each office to a country yeah we can do that but i don't want to do that now we can do that later i think we're good let's go back to php store here we go and the other endpoint is really easy so let's do it real quick office controller the other end point is the show endpoint function show and this one expects an office instance office and it should return an office resource make pass the office and we should return number of previous reservations so the office here should load count and we are going to just copy this from here so it returns the reservation the count of reservations that are active on the office and we should include load all these relations the images the tags and the users all right this should be all we need now let's go to the api.php routes file and create the route that will return the office and here we will call the show method office controller tests we add another test and this one should it shows the office and we will create an office equals office factory create and we are going to make a request copy you see guys i like copying rather than writing from the beginning because it makes uh typos less uh there is less chance for typos and i'm i'm king of typos i write tables a lot so i just prefer copying so offices dot office id so we should hit this end point response dump and let's run this test let's go to the terminal and run this test let's see what it returns and it's returning the office endpoint all right and it's returning the reservations count but we don't have any reservations it's returning the user and it loads the images and tags as well let's make sure that the test number of reservations so let's copy this from here all right and as for the tags we are going to use this here to make sure that we have tags and we have images let's check the response again now we load the tags we load the images all right and the reservation count is correct so this is all we need let's mark this as done and finally we want to write the assertions so for the uh reservations thing reservations preservation status approved all right so we want here to the response data right but it's not an array anymore it's returning only just a single record and as for the assertions let's copy these here and move them there and then adapt them remove all these and we should be good to go so let's run the test it's all good let's run all tests to make sure that nothing is broken and it's all good so we finished the last offices endpoint and we finished the show office endpoint i don't think there is time to work on the create office endpoint so we will move this to the next stream and let me take a quick look at the chat before i leave you do it might be a good idea to use laravel pipeline for this type of complex queries instead of using local scopes i not sure i understand what you mean by using the pipeline instead of local scopes if you can show me an example by opening a pull request to the repo that would be great how is the weather in egypt it's actually hot thank you for asking all right i think there are no questions for me we are done with the list offices endpoint and we are done with the show office endpoint there's something messing with the resource of the office because let me show you something before i go office controller test here let's see the response dump let's go to the terminal oops let's run this see the dump and you can see here that it's returning the user id in the response as well as the user object we don't want to return the user id because we are loading the user object already so it doesn't make sense to return the user id here so this is something that we want to take care of of course we can just leave it but i think it's a good idea to just hide it and always load the user id which is the host or the owner of the office whenever we want to with every response so this is something that we want to fix that's for the next stream and we will do that inside the office resource here we will hide this user id attribute if the user is loaded maybe we do that maybe we want we'll check in the next stream for now i think i think that's it for now guys i think that's uh we are all i plan to always make the streams only for one hour so people can go continue doing what they're doing instead of being stuck with me for hours building something uh i wanted to just start create hitting the create office endpoint but there is no time so this is something for the next stream which i will going to announce the schedule for in the upcoming few days i hope you learned something today and i will just take a quick look at the chat to make sure that i'm not missing any questions before i go can you explain the use of load while getting the office yeah i'm just because we have the office instance already from the database we need to load the count of the reservations and we need to load the images the tags and the user so that's why we use the we use the loadcount method and the load method to load relationships on an exists existing model instance that we already have do you build all your applications with abi first well i built applications in the way that i am supposed to build the application so i work at laravel if i get assigned an application that's api first i'm gonna build it api first if i am assigned an application that uses blade i'm you i'm going to use blade if it uses inertia.js i'm going to use inertia.js so it depends on the requirements of the projects my personal preference is building projects api first because that way you can first focus on the back end part and then worry about the front end part later or prefer a plea someone else will be working on the front end because i personally like the back end work more than the front end works so that's that's why i decided to build this application api first uh list endpoint and office endpoint what's the difference please this end point for the office is going to list a collection of offices where people can filter the office by the host by the user by many other filters and show endpoint is gone it's only going to return a single office by id so that's the difference between both both end points all right i think that's all i have for you today thank you guys for joining me today it was a great stream we'd really uh we were productive and this stream even though we didn't finish everything that we wanted to finish but that's that's the job we got things done and in the next stream we are going to work on creating offices and attaching images to offices and if there's enough time we are going to head the reservations endpoint which is also an interesting part of this application thank you i hope you learned something and see you in the next stream [Music] [Music]
Info
Channel: Laravel
Views: 2,722
Rating: 4.942029 out of 5
Keywords:
Id: utNTpNDnwz8
Channel Id: undefined
Length: 75min 3sec (4503 seconds)
Published: Mon Sep 13 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.