M
M
MVP_Master2021-01-22 19:51:43
Laravel
MVP_Master, 2021-01-22 19:51:43

How to make the product disabled and the program thinks that the page does not exist?

If a product or any blog entry or the like delete, then when you try to go there, an error will occur.

But what if we programmatically disabled the product (by changing the value of the published field to 0 ) the program gave out that there is no such product if we enter the url corresponding to this product in the address bar? I haven't come across such a solution.

through routes I catch and address where it is necessary. and then how to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jazzus, 2021-01-22
@jazzus

Global Scopes with ->where('active', true) will solve the problem with such products in all requests (catalog, searches, 404 on show, etc.) in 1 minute) There will be something like self-made soft delete. The only thing in queries where all products (including inactive) will be needed will be to remember the scope and add withoutGlobalScope.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question