F
F
Fagi2019-03-20 16:29:03
PHP
Fagi, 2019-03-20 16:29:03

Is it possible to make redirects from models?

Or is it better to get the execution status from the model, and redirect it already in the controller?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FanatPHP, 2019-03-20
@Fagi

It is forbidden.
The model knows nothing about the calling interface.
There is a very simple empirical test to see if any code belongs to a model or a controller: implement the same functionality via a command line utility.
In this case, it will immediately become clear that the redirect on the command line - and therefore in the model - is nonsense. And any manipulations with the HTTP protocol must be performed in the only component that is responsible for working with the HTTP controller.

M
Maxim Timofeev, 2019-03-20
@webinar

it is better to get the execution status from the model, and redirect it already in the controller

Yes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question