Hello everyone I wanted to comment here but quickly on a question that was asked to me here which is when we are using Laravel Inertia Remember that Laravel Inertia in case you dont understand the context is a way that we have in Laravel the preferred way to use Vue directly with Laravel that is without the need to use a Rest API for communication In other words from Laravel instead of returning a file in Blade which is the usual thing we return a component in Vue and this is thanks to using Laravel Inertia therefore all the parameter passing that we always do is used or received through a prop in Vue
I can show you quickly here since I have a project here Laravel Inertia this for example is the detail Note that in the prop part we receive what is the general contact ID and if we come here to the controller Note that what it sends is the general contact ID and we pass it directly through here without needing to be consulting a restapi to fill it out understand or it doesnt matter if its a prod or or it doesnt matter if its a variable defined here in the Data section it doesnt matter the important thing is to have that data so a very common query is if you want to make a request to get I dont know what because in the end it hasnt finished answering me But you want to make a request in the traditional way that would be developing an application with a restapi so here is the issue that we have to keep in mind
Usually when we use inertia there is no need to be making requests goodbye understand again suppose we are here Building a list component like the one you are seeing on the screen we dont have to make a query through axios to build it we could do it but it is not necessary because for some reason we are using Inertia that again offers us that direct communication
So it is a very common doubt because here we have when we are developing with Laravel and Vue in this case using inertia we have to change a little bit the mentality that we always have when we create a restapi that again we have larabel we create the resapi then from View we start to make connections through axios like crazy to get that Data in this case it would not be necessary and this is also important because notice that for the query part when we are sending data to inertia there is no need to use acos or fesch or anything like that but rather inertia incorporates a mechanism that in this case is using the forms that allows such communication but the answer that we have
router.post('/users', form)
Its pretty poor to put it in some way since we dont really have a response like we had in Axios with a list of information with form errors or anything like that and thats fine its more than fine because again when using the Arabic Inertia we are attracting ourselves in a few words first of implementing the Restapi with everything that this implies and second of making Axios requests like crazy from the component in Vue
We have to learn to use what would be the characteristics that each technology offers us in this case the inertia that is for the previously commented we already have a direct communication between what would be laravel with Vue So it is wrong to make requests in acos we are using Laravel inertia well it is not bad but surely there is a better solution for example instead of requesting that data simply make a redirection and pass that data through the predir mechanism that we have which is from here in inertia make a redirection or directly paint the component in Vue and pass the data and thus we avoid making an axios request from
The other point I wanted to address is that it is better to use inertia or directly create a Rest API. I tell you that it all depends, basically the only thing you have to keep in mind, according to my judgment, obviously all this is my opinion is whether the application you want is going to migrate to another technology in the end, be it for example a desktop application, understood as for Mac, Linux or Windows, or directly a mobile application, which is the most usual, a web application is created and also a mobile application if that is the case and only in that case I would recommend that you create a REST API instead of using Laravel Inertia since the time it is going to save you is enormous. Here, for example, I show you something that I did in my Academy application, this application is developed in Laravel and in this case it is Vue, therefore the communication that I did is using a REST API, not directly inertia, which is why when I migrated this project, the Academy part to an application in Vue, I saved a lot of time, I would say at least 40% of the work:
I also added the blog part which I dont have here since its the traditional application I tell you in just one month a month dedicating about two or three hours a day or maybe less at most
I consider that it is a fairly fast time for what the application is which is not a very small application either since they do several things including online shopping So in this case if I had used Laravel Inertia I would have had more work because on the one hand I would have had to create the traditional application here which is what you are seeing here on the screen it could basically be built perfectly but apart from that when I wanted to migrate it to Flutter in this case to be consumed through an API I would have had to create on the one hand the API On the other hand also the entire structure that I could already easily replicate here and apart from that I could also see how I had created the component in View to replicate it here on a screen I would have had to do all that additional work which would have cost me quite a bit and apart from that the application would have had a kind of redundancy since on the one hand I was going to have the application here in Vue with Inertia and on the other hand I was also going to have all that replicated all those methods replicated for the RestAPI so in these cases I would consider that it is better to create a RestAPI instead of using it the arel inertia for the rest if you are not interested in creating a layer well one that is consumed through an application in this case like Flutter would not make sense I would say that it is better that you directly do the communication between the arabel and inertia so nothing more to say if you have any questions you can leave it commented there and we will see each other in another video
- Andrés Cruz
Develop with Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter
I agree to receive announcements of interest about this Blog.
!Courses from!
10$
On Udemy
There are 2d 05:18!
!Courses from!
4$
In Academy
View courses!Books from!
1$
See the books