inital commit
This commit is contained in:
77
app/Http/Controllers/SecurityQuestionController.php
Normal file
77
app/Http/Controllers/SecurityQuestionController.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\SecurityQuestion;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Utility\ActionLogCreate;
|
||||
use App\Http\Requests\SecurityQuestionRequest;
|
||||
use App\Traits\ApiResponseTrait;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
|
||||
class SecurityQuestionController extends Controller
|
||||
{
|
||||
use ApiResponseTrait;
|
||||
private $message;
|
||||
private $code;
|
||||
private $data;
|
||||
private $action;
|
||||
private $type;
|
||||
public function __construct()
|
||||
{
|
||||
$this->action='';
|
||||
$this->type='error';
|
||||
$this->message = 'Fail';
|
||||
$this->code = config('constant.API_FAILED_CODE');
|
||||
$this->data=[];
|
||||
}
|
||||
public function index()
|
||||
{
|
||||
$security_questions = (new SecurityQuestion())->getSecurityQuestion();
|
||||
return view('security_question.security_question',compact('security_questions'));
|
||||
|
||||
}
|
||||
public function createSecurityQuestion(SecurityQuestionRequest $request)
|
||||
{
|
||||
$this->action='INSERT_SECURITY_QUESTION';
|
||||
$this->message='can not save data.';
|
||||
$inputData=['questions'=>$request['question']];
|
||||
$returnData = (new SecurityQuestion())->insertSecurityQuestion($inputData);
|
||||
if (!empty($returnData)) {
|
||||
$this->message='Successfully Saved';
|
||||
$this->code=config('constant.API_SUCCESS_CODE');
|
||||
$this->type='success';
|
||||
}
|
||||
ActionLogCreate::logDataCreate( $this->action,$request->all(),$this->message,$returnData,$this->code);
|
||||
return back()->with($this->type, $this->message);
|
||||
}
|
||||
public function getSecurityQuestion(){
|
||||
$result=[];
|
||||
$this->action='INSERT_SECURITY_QUESTION';
|
||||
$this->message='can not get data.';
|
||||
$security_questions = (new SecurityQuestion())->getSecurityQuestion();
|
||||
if(!empty($security_questions)){
|
||||
$this->message = "Security Question info fetched successfully";
|
||||
$this->code = config('constant.API_SUCCESS_CODE');
|
||||
|
||||
foreach ($security_questions as $security_question)
|
||||
{
|
||||
$result['id']=$security_question['id'];
|
||||
$result['value']=$security_question['questions'];
|
||||
}
|
||||
}
|
||||
ActionLogCreate::logDataCreate( $this->action,'',$this->message,$security_questions,$this->code);
|
||||
return response()->json([
|
||||
'status_code'=> $this->code,
|
||||
'message' => $this->message,
|
||||
'security_question' => $result,
|
||||
],Response::HTTP_OK);
|
||||
// return $this->sendApiResponse(
|
||||
// $result,
|
||||
// $this->message,
|
||||
// $this->code
|
||||
// );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user