B
B
BonBon Slick2017-03-07 22:00:01
Laravel
BonBon Slick, 2017-03-07 22:00:01

How to do $data->wantsJson()?

// я не пойму как это тут отрабатывает, если поставить $myarray->wantsJson
// будет ошибка Call to a member function wantsJson() on array
   } catch (ValidatorException $e) {
            if ($data->wantsJson()) {
                return response()->json([
                    'error' => true,
                    'message' => $e->getMessageBag()
                    ]);
            }

How to check if json should be returned if the incoming request is not of Request class but of array data?
Standard Auth Laravel 5.4 protected function create(array $data)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sungat Arynov, 2017-03-09
@BonBonSlick

You are climbing the wrong place with wantsJson() and why do you need this exception? All these manipulations must be tracked in the register (Request there), the create () function only creates a user from the data array.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question