I am checking working on an invites only platform. You need to enter a valid token to get on board.
only the first token validates, any other token in the table is not even checked. What will be the best way to structure this to check all the tokens and only go to the else statement after checking the array.
$this->validate($request,['pin' => 'required|numeric|digits:6']);
$token = $request->input('pin');
$all_pins = \App\Pin::all()->toArray();
if (in_array($token,$all_pins,true))
{
$user = Auth::user()->id;
$user = $this->user->find($user);
$user->pin = $token;
$user->is_activated = true;
$user->has_pin = true;
$user->save();
flash('Your Pin was valid, Welcome', 'success');
return redirect()->route('token_page');
}
else
{
flash('Sorry this pin is not valid', 'warning');
return redirect()->route('reg_token_check');
}`
`