Fixed retrieve user by email
This commit is contained in:
@@ -43,16 +43,12 @@ class RespondentController extends Controller
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$respondent = Respondent::where('email', $request['email'])->get();
|
||||
|
||||
$response = $this->response
|
||||
->item($respondent, new RespondentTransformer, ['key' => 'respondents']);
|
||||
|
||||
var_dump($response);
|
||||
if ($response == []) {
|
||||
throw new NotFoundHttpException("Respondent not found");
|
||||
|
||||
} else return $response;
|
||||
$request['category_id'] = $request['category'];
|
||||
unset($request['category']);
|
||||
$respondent = Respondent::create($request->toArray());
|
||||
return $respondent;
|
||||
// return $this->response
|
||||
// ->item($respondent, new RespondentTransformer, ['key' => 'respondents']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,4 +98,16 @@ class RespondentController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function searchEmail($email)
|
||||
{
|
||||
try {
|
||||
$respondent = Respondent::where('email', $email)
|
||||
->firstOrFail();
|
||||
return $this->response
|
||||
->item($respondent, new RespondentTransformer, ['key' => 'respondents']);
|
||||
} catch (\Exception $e) {
|
||||
return ['message' => $e->getMessage()];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user