D
D
Dmitry2019-07-30 18:22:44
Laravel
Dmitry, 2019-07-30 18:22:44

How to access the field after validation in the controller?

Hello, in the controller, after validation, you need to access the value of the field that passed the validation.

public function editRequestProduct(ProductsRequest $request, int $id){
        $validated = $request->validated();
        // 1 вариант $slug = $request->slug;
       // 2 вариант $slug = $validated['slug'];
}

Is there a difference between the two options given in the code?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JhaoDa, 2019-07-30
@ddimonn8080

Is there a difference between the two options given in the code?

No.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question