Answer the question
In order to leave comments, you need to log in
What PHP Write Styles Are There?
Hello!
I write on Laravel, I don’t like that it is constantly necessary to create 2 functions 1 for displaying the view 2 for the logic itself, for example, for processing the form, I currently do it in 1, I check the function if GET comes, then I give the view, if POST comes, I process the data, but I’m like this recording method is not very like if other recording styles? If yes, which ones and preferably with examples
public function register(Request $request)
{
if ($request->isMethod('GET')) {
return view('frontend.user.registration');
// тут отдаю вьюху view
}
if ($request->isMethod('POST')) {
// тут обрабатываю сам запрос
}
}
Answer the question
In order to leave comments, you need to log in
I write in Laravel, I don’t like that it is constantly necessary to create 2 functions 1 for displaying the view 2 for the logic itself
app
...
├── Http
│ ├── Controllers
│ │ ├── Auth // 1. тут мы обрабатываем роуты, ответственные за авторизацию
│ │ │ ├── ForgotPasswordController.php
│ │ │ ├── LoginController.php
│ │ │ ├── RegisterController.php
│ │ │ └── ResetPasswordController.php
│ │ ├── Backend // 2. тут мы показываем бекенд
│ │ ├── Frontend // 3. тут мы показываем фронтенд
│ │ │ ...
│ │ ├── Controller.php
│ │ ...
...
What does it mean to create? Is there an inspector above you?
Write as you like, send at least all requests to the function, and then figure it out.
You yourself gave an example, why do you not like it?
Suits you, the rest is not important.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question