T
T
Tarasovych2017-05-03 16:04:15
Laravel
Tarasovych, 2017-05-03 16:04:15

Do I understand the laravel form creation logic correctly?

I create a route:

Route::get('адрес_1', 
  ['as' => 'адрес_2', 'uses' => '[email protected]']);
Route::post('contact', 
  ['as' => 'адрес_3', 'uses' => '[email protected]']);

Do I understand correctly: адрес_1- "booking" the processing of requests specifically for this form; адрес_2- did not fully understand why it is needed - in order to call this form in the desired view (?); адрес_3- on this path, the view finds a method that should process the entered data?
class FormController extends Controller {

    public function create()
    {
        return view('about.адрес_1 ');
    }

    public function store(ContactFormRequest $request)
    {
        return \Redirect::route('тут вьюха, куда идет редирект после перенаправления?');
    }
}

upd.
there is a sense in routes to use resource? The controller seems to remain unchanged in this case ..
Route::resource('адрес_1', 'FormController')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
D3lphi, 2017-05-03
@Tarasovych

So, look: address_1 - the address that the user will go to to see and fill out this form. address_3 - form handler. Here we perform actions with the form. For example, if it were a registration form, then the user registration logic would be located here. Again, by the word "here" I mean not exactly the controller. All business logic is better to take out in a service layer. The controller will only call the methods of this service and give a response to the user.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question