Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

More Eloquent Packages You Can Explore

Premium
3:46

The Full Lesson is Only for Premium Members

Want to access all of our courses? (29 h 14 min)

You also get:

54 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

P
Prodromos ✓ Link copied!

Hey Povilas, Great course but I have a question. Yesterday I learn about sql/MySQL store procedures. My question, procedures are helpful? You have use them? We need to use them? Why laravel don't support something like this? If yes then can you give an example how to use them.

Thanks Prodromos

PK
Povilas Korop ✓ Link copied!

In my experience, I almost never used them. I did when one project involved Microsoft SQL Server with a lot of logic of calculations inside the database.

The downside of stored procedures is then your logic is not in the code, you can't easily change it by commiting code to the repository, much harder to make changes. But, if you have some specific calculations, they are probably done faster on DB level, in some cases. So for some large projects it may make sense to move some features to stored procedures.

S
Sophist ✓ Link copied!

I thought that a real-life example might illustrate the point that Povilas has made.

Two decades ago I was responsible for fixing a broken SQL/VB6 system. The software house who had developed this system were literally incompetent. They didn't use transactions to store parent and child records atomically - instead they stored a parent record, then queried the database for the maximum auto-increment id and then created child records using that key - and of course it worked fine in a single user testing, but in a multi-user system where parent records were sometimes created simultaneously, child records started getting mixed up. Then they used a 16bit integer to hold the foreign key and couldn't work out why the system broke when the table reached 32767 records. D'oh!!

So we decided to have the system rewritten and enhanced and I specified a fuzzy search mechanism to find and prioritise data in what you might call a Venn diagram search. Objects in the database consisted of a parent item and zero or more child items, and you could search based on a different set of items and identify objects which had some commonality, ordering the results by the degree of commonality. There were also a few rules to exclude objects from the search results where items were in the object and not the search or vice versa, which complicated it a bit. Anyway, this could not be achieved using a straight-forward single SQL statement, and the data transfer of interim results would have been huge, so the only performant way to achieve this was using stored procedures and interim temporary tables, and whilst debugging these was challenging, they worked brilliantly and the users loved both the functionality and the speed.

Sadly I learned that a decade or so later they replaced the system again, and although the stored-procedure algorithms had been well documented, they failed to replicate how the old system worked and delivered a much simpler search engine which was far less effective.

B
Brammah ✓ Link copied!

Greetings Povilas, I have a question, while usingSpatie Media Library Package, adding photos is okay, but I have tried researching on how to edit photos using the same and I haven't found any. Do you have a link to an article or a YouTube video that could help me out?

Thanks

PK
Povilas Korop ✓ Link copied!

What is exactly the problem? You have a form when you upload a file, and then you delete the old file and upload a new one instead. What is the actual error you're getting here or what have you tried?

B
Brammah ✓ Link copied!

When I first upload a file, it is successfully uploading and what have you. During update, I can preview the initially uploaded file but when I click to update, I still have to select a new photo regardless.

I
Iyasu ✓ Link copied!

Thanks Korop, a great tutorial

D
Denis ✓ Link copied!

Thank you very much for so great content!