A
A
Andrey Kornev2016-05-17 07:58:05
Laravel
Andrey Kornev, 2016-05-17 07:58:05

What is the best way to store files in Laravel?

I have been working with 1C-Bitrix for more than 5 years, and there all files attached anywhere (IB elements, IB sections, account photos, etc., etc.) are entered in a separate table. And in all other elements, just a link to the ID of the uploaded file.
Should I transfer this principle of working with files to Laravel (I must say I like this approach) or do it like it is written everywhere in totorials - just transfer the file to a folder and specify the file path in the database (I did this when I just started to study web development, and I must say this approach seems primitive to me).

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrzej Wielski, 2016-05-17
@webkornevand

It would be more correct to create a polymorphic relationship. Save the path to the image in the database, as well as the path to the thumbnail, linking it to a specific entity of a specific model.
If you want, I can describe in more detail with code examples.

M
Muhammad, 2016-05-17
@muhammad_97

Save the downloaded file in a folder, and enter only the path into the database

A
Andrey Kornev, 2016-05-17
@webkornevand

Gentlemen Andrzej Wielski and Muhammad , kindly explain to me the advantage of your approach of storing attached files over the system as in Bitrix. It’s just that I don’t understand the advantages of this approach from the height of experience with Bitris.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question