public function login(Request $data) {
$credentials = [
'phone' => $data['phone'],
'password' => $data['password'],
];
if (Auth::attempt($credentials)) {
return response()->json(array('token' => Auth::user()->token), 200);
} else {
return response()->json(['error' => 'Incorrect phone or password',], 404);
}
}