I'm currently working on my final project for school and I'm using Laravel for my backend system. With Laravel I'm using React and mostly working with API's on the Laravel side and this is the first time I'm fully trying to use the Laravel documentation as a guideline for how to set up my controllers, models, migrations, routes and all the basic functionality. I used to just use ChatGPT and I noticed that a lot of the time ChatGPT's problem solving is outdated (obviously I know that my version of ChatGPT doesn't know about Laravel 11) and my problem is that I see all these cool default functionalities like email verification and all these cool security features which Laravel gives us the chance to use, but I've noticed that a lot of these solutions that Laravel brings forward in the documentation primarily work only with the use of Blade. This isn't a problem, obviously the documentation should also have Blade functionality explained but the problem is that these solutions aren't talked about in the context of API's. It would be really nice if there was a section of how to use these practical functionalities in the context of API's. Maybe there already is and I'm missing something and if that's the case I would really appreciate it if someone could drop me a link to these API resources. Obviously I'm aware there are all kinds of guides on Laracasts but a lot of them are locked behind a pay-wall and I'm as broke as students come so I'm feeling kind of sad about this situation I'm in.
Sorry if I'm absolutely oblivious to some source of information about Laravel's API's and I'm here just spewing nonsense.
They still work with apis. You just have to handle the response yourself. The error bag from the validation still comes through. Not sure what you are using to make requests to the server, but if you are using axios, catch the error and look at the response to see how the error messages are structured and then do what you want with them.
Inertia will take care of this for you, which you can use with react.
@Ben Taylor I mostly use Postman to make requests to my Laravel API's to test them. At first I used Laravel Breeze API only for my whole authentication system but I ran into some problems with CSRF. I ran the axios command to set the CSRF/XSRF token in the header of my requests but it still returned the same error. Then I scrapped the whole Breeze idea and started making my Auth system myself, everything was fine till I started working on the Email verification functionality where I ran into problems such as the verification.verify GET route that Laravel defines in their Email verification section automatically redirecting to my login route which was a POST request. Then I had to make the email verification functionality manually :(. I was also looking at Inertia, but it seemed like quite a lot to take in and sadly I don't have much time for this project, but if You or anyone could tell me how complicated moving my project to Inertia would be, it would be greatly appreciated. I have around a month to finish my project - do you think that's a reasonable time to implement Inertia seeing that I haven't worked with it before?
There are some decent youtube videos on laravel and passport or sanctum.
Edit:
Generally if you have an API, the user of the api designs their own frontend, not you.
You give instructions on the api usage, how data is returned.
Tokens are used for abilities, but the user (organization) of the api has their own
"who can access the api" setup as well.