Laravel: Multi-Step Validation with DB Transactions

preview_player
Показать описание
A practical example of validation that comes in multiple steps, all wrapped in a database transaction.

- - - - -
Support the channel by checking out my products:

- - - - -
Other places to follow:
Рекомендации по теме
Комментарии
Автор

The code sample contains a subtle but common error around time code 01:45. This often happens when people use try blocks in various languages, not just in PHP. The call to DB::beginTransaction() should be outside the try block, since the rollback in the catch should only happen if the transaction was begun successfully. If beginTransaction() fails internally, it should clean up itself. If DB::beginTransaction() fails inside the try block, then there will be a cascade of errors when the rollback in the catch also fails because the transaction wasn't started.

theceilidhboy
Автор

I use transactions. I don't really understand why he creates the server outside the transaction and is forced to delete the server->provider in catch. I don't want to be quarrelsome, it's honest curiosity...

IlPandax
Автор

This package is not working on windows machines. always failed to connect to the server with ssh. it showed up failed to load shi key.

fftfaisal
Автор

hello, just asking, is it possible to pass the array in a controller to a JavaScript file in laravel? I need the data to be use in my JavaScript I don't know what to do and also, how can i connect my JavaScript file to an html file in laravel, i tried the asset() but it seem to not work

lusoclement
Автор

Thanks for sharing! Wanted to ask if you have seen a dynamic FormRequest injection or something along those lines; e.g. controller store action depending on request data, should able to resolve to the correct FormRequest because the request data is dynamic and requires different validation for each “type”. Maybe you have some ideas, this could be a really great video.

ricards
Автор

Maybe I missed it, but the thumbnail said "WHY?!" for the multiple validations in this flow, but the why was never addressed in any fashion from what I could tell in the video.

Can you explain a bit more here? Like, I don't see any real reason to throw an error on provider validation after the server has already been constructed when the data is there?

erichansen
Автор

I use the transaction outside the try, that is to say before using the try statement, I see that you use it inside the try statement, what is the correct way? thank you very much your videos are of great value.

andresoler
Автор

Why you don't use conditional validation rule like 'require_if'? About validation inside of services, etc, in my opinion the best approach is to create a Request Validation.

VitaliyRotari
Автор

Can you make a video about connecting laravel to vue by aancrum spa on different domain using ngrix

ratebfaysalbarakat
Автор

I think this is a weird video, it's a great explanation of something we should never use, so ???

HelenaDuGraus