mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-11 11:11:07 +03:30
Structor CSSD
This commit is contained in:
@@ -1,49 +1,49 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Auth;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Transformers\Json;
|
||||
use App\User;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
use Illuminate\Http\Request;
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset emails and
|
||||
| includes a trait which assists in sending these notifications from
|
||||
| your application to your users. Feel free to explore this trait.
|
||||
|
|
||||
*/
|
||||
use SendsPasswordResetEmails;
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
/**
|
||||
* Send a reset link to the given user.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function getResetToken(Request $request)
|
||||
{
|
||||
dd($request->all());
|
||||
$this->validate($request, ['email' => 'required|email']);
|
||||
if ($request->wantsJson()) {
|
||||
$user = User::where('email', $request->input('email'))->first();
|
||||
if (!$user) {
|
||||
return response()->json(Json::response(null, trans('passwords.user')), 400);
|
||||
}
|
||||
$token = $this->broker()->createToken($user);
|
||||
return response()->json(Json::response(['token' => $token]));
|
||||
}
|
||||
}
|
||||
}
|
||||
<?php␍
|
||||
namespace App\Http\Controllers\Auth;␍
|
||||
use App\Http\Controllers\Controller;␍
|
||||
use App\Transformers\Json;␍
|
||||
use App\User;␍
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;␍
|
||||
use Illuminate\Http\Request;␍
|
||||
class ForgotPasswordController extends Controller␍
|
||||
{␍
|
||||
/*␍
|
||||
|--------------------------------------------------------------------------␍
|
||||
| Password Reset Controller␍
|
||||
|--------------------------------------------------------------------------␍
|
||||
|␍
|
||||
| This controller is responsible for handling password reset emails and␍
|
||||
| includes a trait which assists in sending these notifications from␍
|
||||
| your application to your users. Feel free to explore this trait.␍
|
||||
|␍
|
||||
*/␍
|
||||
use SendsPasswordResetEmails;␍
|
||||
/**␍
|
||||
* Create a new controller instance.␍
|
||||
*␍
|
||||
* @return void␍
|
||||
*/␍
|
||||
public function __construct()␍
|
||||
{␍
|
||||
$this->middleware('guest');␍
|
||||
}␍
|
||||
/**␍
|
||||
* Send a reset link to the given user.␍
|
||||
*␍
|
||||
* @param \Illuminate\Http\Request $request␍
|
||||
* @return \Illuminate\Http\Response␍
|
||||
*/␍
|
||||
public function getResetToken(Request $request)␍
|
||||
{␍
|
||||
dd($request->all());␍
|
||||
$this->validate($request, ['email' => 'required|email']);␍
|
||||
if ($request->wantsJson()) {␍
|
||||
$user = User::where('email', $request->input('email'))->first();␍
|
||||
if (!$user) {␍
|
||||
return response()->json(Json::response(null, trans('passwords.user')), 400);␍
|
||||
}␍
|
||||
$token = $this->broker()->createToken($user);␍
|
||||
return response()->json(Json::response(['token' => $token]));␍
|
||||
}␍
|
||||
}␍
|
||||
}␍
|
||||
|
||||
@@ -1,61 +1,61 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Auth;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Transformers\Json;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
use ResetsPasswords;
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
/**
|
||||
* Reset the given user's password.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function reset(Request $request)
|
||||
{
|
||||
$this->validate($request, $this->rules(), $this->validationErrorMessages());
|
||||
// Here we will attempt to reset the user's password. If it is successful we
|
||||
// will update the password on an actual user model and persist it to the
|
||||
// database. Otherwise we will parse the error and return the response.
|
||||
$response = $this->broker()->reset(
|
||||
$this->credentials($request), function ($user, $password) {
|
||||
$this->resetPassword($user, $password);
|
||||
}
|
||||
);
|
||||
if ($request->wantsJson()) {
|
||||
if ($response == Password::PASSWORD_RESET) {
|
||||
return response()->json(Json::response(null, trans('passwords.reset')));
|
||||
} else {
|
||||
return response()->json(Json::response($request->input('email'), trans($response), 202));
|
||||
}
|
||||
}
|
||||
// If the password was successfully reset, we will redirect the user back to
|
||||
// the application's home authenticated view. If there is an error we can
|
||||
// redirect them back to where they came from with their error message.
|
||||
return $response == Password::PASSWORD_RESET
|
||||
? $this->sendResetResponse($response)
|
||||
: $this->sendResetFailedResponse($request, $response);
|
||||
}
|
||||
}
|
||||
<?php␍
|
||||
namespace App\Http\Controllers\Auth;␍
|
||||
use App\Http\Controllers\Controller;␍
|
||||
use App\Transformers\Json;␍
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;␍
|
||||
use Illuminate\Http\Request;␍
|
||||
use Illuminate\Support\Facades\Password;␍
|
||||
class ResetPasswordController extends Controller␍
|
||||
{␍
|
||||
/*␍
|
||||
|--------------------------------------------------------------------------␍
|
||||
| Password Reset Controller␍
|
||||
|--------------------------------------------------------------------------␍
|
||||
|␍
|
||||
| This controller is responsible for handling password reset requests␍
|
||||
| and uses a simple trait to include this behavior. You're free to␍
|
||||
| explore this trait and override any methods you wish to tweak.␍
|
||||
|␍
|
||||
*/␍
|
||||
use ResetsPasswords;␍
|
||||
/**␍
|
||||
* Create a new controller instance.␍
|
||||
*␍
|
||||
* @return void␍
|
||||
*/␍
|
||||
public function __construct()␍
|
||||
{␍
|
||||
$this->middleware('guest');␍
|
||||
}␍
|
||||
/**␍
|
||||
* Reset the given user's password.␍
|
||||
*␍
|
||||
* @param \Illuminate\Http\Request $request␍
|
||||
* @return \Illuminate\Http\Response␍
|
||||
*/␍
|
||||
public function reset(Request $request)␍
|
||||
{␍
|
||||
$this->validate($request, $this->rules(), $this->validationErrorMessages());␍
|
||||
// Here we will attempt to reset the user's password. If it is successful we␍
|
||||
// will update the password on an actual user model and persist it to the␍
|
||||
// database. Otherwise we will parse the error and return the response.␍
|
||||
$response = $this->broker()->reset(␍
|
||||
$this->credentials($request), function ($user, $password) {␍
|
||||
$this->resetPassword($user, $password);␍
|
||||
}␍
|
||||
);␍
|
||||
if ($request->wantsJson()) {␍
|
||||
if ($response == Password::PASSWORD_RESET) {␍
|
||||
return response()->json(Json::response(null, trans('passwords.reset')));␍
|
||||
} else {␍
|
||||
return response()->json(Json::response($request->input('email'), trans($response), 202));␍
|
||||
}␍
|
||||
}␍
|
||||
// If the password was successfully reset, we will redirect the user back to␍
|
||||
// the application's home authenticated view. If there is an error we can␍
|
||||
// redirect them back to where they came from with their error message.␍
|
||||
return $response == Password::PASSWORD_RESET␍
|
||||
? $this->sendResetResponse($response)␍
|
||||
: $this->sendResetFailedResponse($request, $response);␍
|
||||
}␍
|
||||
}␍
|
||||
|
||||
@@ -12,7 +12,7 @@ class MedicalCenterController extends Controller
|
||||
public function index()
|
||||
{
|
||||
$MedicalCenters = MedicalCenter::withCount('users')->paginate(10);
|
||||
return response()->json(['MedicalCenters' => $MedicalCenters]);
|
||||
return \MessageResponse::data($MedicalCenters);
|
||||
}
|
||||
|
||||
public function create()
|
||||
@@ -22,7 +22,7 @@ class MedicalCenterController extends Controller
|
||||
|
||||
public function store(StoreMedicalCenterRequest $request)
|
||||
{
|
||||
$MedicalCenter = MedicalCenter::create($request->all());
|
||||
MedicalCenter::create($request->all());
|
||||
return response()->json(trans('messages.success'));
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class TestResultController extends Controller
|
||||
//
|
||||
}
|
||||
|
||||
public function CreateChildFormValue($InputChild,$TestResultObj,$TestResultInfo)
|
||||
public function CreateChildFormValue2($InputChild,$TestResultObj,$TestResultInfo)
|
||||
{
|
||||
// dd($TestResultInfo[$InputChild->name]);
|
||||
// foreach ($Input->children as $InputChild) {
|
||||
@@ -40,6 +40,34 @@ class TestResultController extends Controller
|
||||
$InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id , 'input_id' => $InputChild['id'] , 'value' => $Value]);
|
||||
// dd(['test_result_id' => $TestResultObj->id , 'input_id' => $InputChild['id'] , 'value' => $Value]);
|
||||
// }
|
||||
}
|
||||
public function CreateChildFormValue($Input,$TestResultObj,$TestResultInfo)
|
||||
{
|
||||
// dd($Input->children[0]->children);
|
||||
// if ($Input->type == 'Form') {
|
||||
// code...
|
||||
|
||||
// $TestResultInfo = $TestResultInfo[$Input->name];
|
||||
foreach ($Input->children as $InputChild) {
|
||||
|
||||
// $TestResultInfo = $TestResultInfo[$InputChild->name];
|
||||
|
||||
if ($InputChild->type == 'Form') {
|
||||
|
||||
// dd($TestResultInfo[$InputChild->name]);
|
||||
$this->CreateChildFormValue($InputChild,$TestResultObj,$TestResultInfo[$InputChild->name]);
|
||||
// dd($InputChild);
|
||||
}
|
||||
else {
|
||||
$Value = $TestResultInfo[$InputChild->name];
|
||||
// dd($Value);
|
||||
$InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id , 'input_id' => $InputChild['id'] , 'value' => $Value ]);
|
||||
}
|
||||
|
||||
}
|
||||
return 'success';
|
||||
|
||||
|
||||
}
|
||||
public function store(StoreTestResultRequest $request)
|
||||
{
|
||||
@@ -57,39 +85,77 @@ class TestResultController extends Controller
|
||||
// $TestResultInfo = $request['info'];
|
||||
$TestResultInfo = [];
|
||||
|
||||
$Inputs = Input::with('options','children')->where('test_type_id',$request->test_type_id)->get();
|
||||
$Inputs = Input::with('options','children','children.children')->where('test_type_id',$request->test_type_id)->get();
|
||||
// dd($Inputs->toArray()[2]);
|
||||
// foreach ($Inputs as $Input) {
|
||||
// if ($Input['type'] == 'Form') {
|
||||
// $TestResultInfo = $request[$Input->name];
|
||||
//
|
||||
// // $this->CreateChildFormValue($Input,$TestResultObj,$TestResultInfo);
|
||||
//
|
||||
// ///--------------------------------------------------
|
||||
// foreach ($Input->children as $InputChild) {
|
||||
//
|
||||
// $this->CreateChildFormValue($InputChild,$TestResultObj,$TestResultInfo);
|
||||
// ///--------------------------------------------------
|
||||
// // $Value = $TestResultInfo[$InputChild->name];
|
||||
// //
|
||||
// // if ($InputChild->type == 'Form') {
|
||||
// // foreach ($InputChild->children as $InputChild2) {
|
||||
// // $Value = $TestResultInfo[$InputChild->name][$InputChild2->name];
|
||||
// // $InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id , 'input_id' => $InputChild2['id'] , 'value' => $Value]);
|
||||
// // return 'success';
|
||||
// // }
|
||||
// //
|
||||
// // }
|
||||
// // $InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id , 'input_id' => $InputChild['id'] , 'value' => $Value]);
|
||||
// }
|
||||
// ///--------------------------------------------------
|
||||
// }
|
||||
// else {
|
||||
// $TestResultInfo = $request->all();
|
||||
// }
|
||||
// $Value = $TestResultInfo[$Input->name];
|
||||
// $InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id , 'input_id' => $Input->id , 'value' => $Value]);
|
||||
// }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
foreach ($Inputs as $Input) {
|
||||
if ($Input['type'] == 'Form') {
|
||||
$TestResultInfo = $request[$Input->name];
|
||||
$TestResultInfo = $request[$Input->name];//-----estesna
|
||||
|
||||
// $this->CreateChildFormValue($Input,$TestResultObj,$TestResultInfo);
|
||||
|
||||
$this->CreateChildFormValue($Input,$TestResultObj,$TestResultInfo);
|
||||
|
||||
//******
|
||||
///--------------------------------------------------
|
||||
foreach ($Input->children as $InputChild) {
|
||||
|
||||
$this->CreateChildFormValue($InputChild,$TestResultObj,$TestResultInfo);
|
||||
///--------------------------------------------------
|
||||
// $Value = $TestResultInfo[$InputChild->name];
|
||||
//
|
||||
// if ($InputChild->type == 'Form') {
|
||||
// foreach ($InputChild->children as $InputChild2) {
|
||||
// $Value = $TestResultInfo[$InputChild->name][$InputChild2->name];
|
||||
// $InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id , 'input_id' => $InputChild2['id'] , 'value' => $Value]);
|
||||
// return 'success';
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// $InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id , 'input_id' => $InputChild['id'] , 'value' => $Value]);
|
||||
}
|
||||
// foreach ($Input->children as $InputChild) {
|
||||
//
|
||||
// $TestResultInfo = $TestResultInfo[$InputChild->name];
|
||||
// // dd($TestResultInfo);
|
||||
// if ($InputChild->type == 'Form') {
|
||||
// foreach ($InputChild->children as $InputChild2) {
|
||||
//
|
||||
// $Value = $TestResultInfo[$InputChild->name][$InputChild2->name];
|
||||
//
|
||||
// $InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id , 'input_id' => $InputChild2['id'] , 'value' => $Value]);
|
||||
// return 'success';
|
||||
// }
|
||||
// }
|
||||
// $InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id , 'input_id' => $InputChild['id'] , 'value' => $Value]);
|
||||
// }
|
||||
///--------------------------------------------------
|
||||
}
|
||||
else {
|
||||
$TestResultInfo = $request->all();
|
||||
// $TestResultInfo = $request->all();
|
||||
$Value = $request[$Input->name];
|
||||
// dd($Value);
|
||||
$InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id , 'input_id' => $Input->id , 'value' => $Value]);
|
||||
}
|
||||
$Value = $TestResultInfo[$Input->name];
|
||||
$InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id , 'input_id' => $Input->id , 'value' => $Value]);
|
||||
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
});
|
||||
} catch (\Exception $e) {
|
||||
|
||||
@@ -12,8 +12,8 @@ class TestTypeController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$TestTypes = TestType::paginate(10);
|
||||
return response()->json(['TestTypes' => $TestTypes, 'LastPage' => $TestTypes->lastPage()]);
|
||||
$TestTypes = TestType::with('user','user.medical_center')->paginate(10);
|
||||
return \MessageResponse::data($TestTypes);
|
||||
}
|
||||
|
||||
public function create()
|
||||
@@ -23,7 +23,7 @@ class TestTypeController extends Controller
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////// Add TestType /////////////////////////
|
||||
/////////////////////// Store TestType /////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -40,7 +40,7 @@ class TestTypeController extends Controller
|
||||
$InputObj = Input::create($InputData);
|
||||
//---------------------------------------------Input
|
||||
//---------------------------------------------Option
|
||||
if ($Input['type'] == 'CheckBox' || $Input['type'] == 'Select') {
|
||||
if ($Input['type'] == 'Checkbox' || $Input['type'] == 'Select') {
|
||||
foreach ($Input['options'] as $Option) {
|
||||
$Option = Option::create(['title' => $Option['title'] , 'input_id' => $InputObj->id]);
|
||||
}
|
||||
@@ -86,7 +86,7 @@ class TestTypeController extends Controller
|
||||
} catch (\Exception $e) {
|
||||
return response()->json($e->getMessage(), 441);
|
||||
}
|
||||
return \MessageResponse::success();
|
||||
return \MessageResponse::success(null,trans('messages.create'));
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
@@ -94,14 +94,105 @@ class TestTypeController extends Controller
|
||||
//
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$TestType = TestType::with('inputs','inputs.children','inputs.children.children','inputs.options')->findOrFail($id);//?????
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////// Edit TestType /////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// $TestType = TestType::where('id',$id)->with('inputs','inputs.children','inputs.children.children','inputs.options')->whereHas('inputs' , function($query){
|
||||
// $query->where('parent_id',null);
|
||||
// })->get();
|
||||
return response()->json(['TestType' => $TestType]);
|
||||
public function CreateInputInfo($Input)
|
||||
{
|
||||
//------------------------------------------------------Input
|
||||
$InputInfo = [
|
||||
'id' => $Input->id,
|
||||
'name' => $Input->name,
|
||||
'type' => $Input->type,
|
||||
'size' => $Input->size ,
|
||||
'parent_id' => $Input->parent_id,
|
||||
'options' => [],
|
||||
'children' => []
|
||||
];
|
||||
//------------------------------------------------------Input
|
||||
//------------------------------------------------------Option
|
||||
if ($Input['type'] == 'Checkbox' || $Input['type'] == 'Select') {
|
||||
|
||||
foreach ($Input['options'] as $Option) {
|
||||
$OptionInfo = [
|
||||
'id' => $Option->id ,
|
||||
'title' => $Option->title
|
||||
];
|
||||
$Options[] = $OptionInfo;
|
||||
}
|
||||
$InputInfo['options'] = $Options;
|
||||
}
|
||||
//------------------------------------------------------Option
|
||||
return $InputInfo;
|
||||
}
|
||||
// public function CreateChildFormInfo($Input,$InputInfo)
|
||||
// {
|
||||
// foreach ($Input['children'] as $InputChild) {
|
||||
//
|
||||
// $ChildInfo = $this->CreateInputInfo($InputChild);
|
||||
// $InputInfo['children'] = $ChildInfo;
|
||||
//
|
||||
// if ($InputChild['type'] == 'Form') {
|
||||
// return $this->CreateChildFormInfo($InputChild,$ChildInfo);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return $InputInfo;
|
||||
// }
|
||||
// public function CreateChildFormInfo($Input,$InputInfo)
|
||||
// {
|
||||
// foreach ($Input['children'] as $InputChild) {
|
||||
//
|
||||
// $InputInfo['children'] = $this->CreateInputInfo($InputChild);
|
||||
// $ChildInfo = $InputInfo['children'];
|
||||
// $Children[] = $ChildInfo;
|
||||
// if ($InputChild['type'] == 'Form') {
|
||||
// $ChildInfo['children'] = $this->CreateChildFormInfo($InputChild,$ChildInfo);
|
||||
// }
|
||||
// }
|
||||
// return $Children;
|
||||
// }
|
||||
public function CreateChildFormInfo($Input,$InputInfo)
|
||||
{
|
||||
foreach ($Input['children'] as $InputChild) {
|
||||
|
||||
$ChildInfo = $this->CreateInputInfo($InputChild);
|
||||
$Children[] = $ChildInfo;
|
||||
if ($InputChild['type'] == 'Form') {
|
||||
$this->CreateChildFormInfo($InputChild,$ChildInfo);
|
||||
}
|
||||
}
|
||||
return $Children;
|
||||
}
|
||||
|
||||
public function edit(TestType $TestType)
|
||||
{
|
||||
$Inputs = Input::with('children','options','children.options')->where('test_type_id',$TestType->id)->where('parent_id',null)->get();
|
||||
|
||||
$Info = [];
|
||||
$Options = [];
|
||||
$Children = [];
|
||||
|
||||
foreach ($Inputs as $Input) {
|
||||
|
||||
$InputInfo = $this->CreateInputInfo($Input);
|
||||
|
||||
if ($Input['type'] == 'Form') {
|
||||
$Children = $this->CreateChildFormInfo($Input,$InputInfo);
|
||||
$InputInfo['children'] = $Children;
|
||||
}
|
||||
$Info[] = $InputInfo;
|
||||
}
|
||||
$TestTypeInfo = [
|
||||
'id' => $TestType->id,
|
||||
'name' => $TestType->name,
|
||||
'unique_code' => $TestType->unique_code,
|
||||
'info' => $Info,
|
||||
];
|
||||
return \MessageResponse::data($TestTypeInfo);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -123,19 +214,19 @@ class TestTypeController extends Controller
|
||||
$InputObj = Input::where('id',$Input['id'])->update($InputData);
|
||||
//---------------------------------------------Input
|
||||
//---------------------------------------------Option
|
||||
if ($Input['type'] == 'CheckBox' || $Input['type'] == 'Select') {
|
||||
if ($Input['type'] == 'Checkbox' || $Input['type'] == 'Select') {
|
||||
foreach ($Input['options'] as $Option) {
|
||||
if ($Option['id'] == 0) {//--new
|
||||
$Option = Option::create(['title' => $Option['title'] , 'input_id' => $InputObj->id]);
|
||||
$Option = Option::create(['title' => $Option['title'] , 'input_id' => $Input['id'] ]);
|
||||
}
|
||||
else {
|
||||
$Option = Option::where('id', $Option['id'])->update(['title' => $Option['title'] ]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//---------------------------------------------Option
|
||||
return $InputObj;
|
||||
// dd($Input);
|
||||
return $Input;
|
||||
|
||||
}
|
||||
public function UpdateChildForm($Input,$TestType,$InputObj)
|
||||
@@ -150,7 +241,8 @@ class TestTypeController extends Controller
|
||||
}
|
||||
}
|
||||
else {
|
||||
$InputChildObj = $this->UpdateInput($InputChild,$TestType,$InputObj->id);
|
||||
// dd($InputObj);
|
||||
$InputChildObj = $this->UpdateInput($InputChild,$TestType,$InputObj['id']);
|
||||
if (isset($InputChild['children'])) {
|
||||
$this->UpdateChildForm($InputChild,$TestType,$InputChildObj);
|
||||
}
|
||||
@@ -162,6 +254,7 @@ class TestTypeController extends Controller
|
||||
|
||||
public function update(StoreTestTypeRequest $request, TestType $TestType)
|
||||
{
|
||||
// dd($request->all());
|
||||
$TestTypeData = [
|
||||
'name' => $request['name'],
|
||||
'unique_code' => $request['unique_code'],
|
||||
@@ -175,11 +268,13 @@ class TestTypeController extends Controller
|
||||
}
|
||||
else {
|
||||
$InputObj = $this->UpdateInput($Input,$TestType);
|
||||
// dd($InputObj);
|
||||
}
|
||||
if ($Input->Type == 'Form') {
|
||||
if ($Input['type'] == 'Form') {
|
||||
$this->UpdateChildForm($Input,$TestType,$InputObj);
|
||||
}
|
||||
}
|
||||
return \MessageResponse::success(null,trans('messages.update'));
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
|
||||
@@ -1,66 +1,83 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Http\Requests\StoreUserRequest;
|
||||
use App\User;
|
||||
use App\MedicalCenter;
|
||||
use App\User;
|
||||
|
||||
|
||||
|
||||
class UserController extends Controller
|
||||
|
||||
{
|
||||
public function index(Request $request)
|
||||
|
||||
public function index()
|
||||
{
|
||||
$Users = User::where('medicalcenter', $request->medical_center_id)->paginate(10);
|
||||
return response()->json(['Users' => $Users, 'LastPage' => $Users->lastPage()]);
|
||||
$Users = User::with(['medical_center', 'roles'])->paginate(10);
|
||||
return \MessageResponse::data($Users);
|
||||
}
|
||||
|
||||
public function store(StoreUserRequest $request)
|
||||
{
|
||||
$UserData = [
|
||||
'name' => $request->name,
|
||||
'cell_number' => $request->cell_number,
|
||||
'medical_center_id' => $request->medical_center_id,
|
||||
'name' => $request->name ,
|
||||
'cell_number' => $request->cell_number ,
|
||||
'medical_center_id' => $request->medical_center_id ,
|
||||
'status' => 'PreRegister',
|
||||
'verified' => 1,
|
||||
'password' => bcrypt($request->password),
|
||||
];
|
||||
$User = User::create($UserData);
|
||||
|
||||
return response()->json(trans('messages.success'));
|
||||
return \MessageResponse::success(trans('messages.success'));
|
||||
}
|
||||
|
||||
public function edit(User $User)
|
||||
{
|
||||
return response()->json(['User' => $User]);
|
||||
return \MessageResponse::data($User);
|
||||
}
|
||||
|
||||
public function update(StoreUserRequest $request, User $User)
|
||||
{
|
||||
$UserData = [
|
||||
'name' => $request->name,
|
||||
'cell_number' => $request->cell_number,
|
||||
'medical_center_id' => $request->medical_center_id,
|
||||
'name' => $request->name ,
|
||||
'cell_number' => $request->cell_number ,
|
||||
'medical_center_id' => $request->medical_center_id ,
|
||||
'status' => 'PreRegister',
|
||||
'verified' => 1,
|
||||
'password' => bcrypt($request->password),
|
||||
];
|
||||
$User->update($UserData);
|
||||
return response()->json(trans('messages.success'));
|
||||
return \MessageResponse::success(trans('messages.success'));
|
||||
}
|
||||
|
||||
public function destroy(User $User)
|
||||
{
|
||||
if (auth('api')->user()->can('delete', $User)) {
|
||||
return response()->json(trans('messages.failed'));
|
||||
return \MessageResponse::error(trans('messages.failed'));
|
||||
}
|
||||
$User->delete(); //?????????????????
|
||||
$User->delete();
|
||||
return \MessageResponse::success(trans('messages.success'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getByMedicalCenter(MedicalCenter $MedicalCenter)
|
||||
{
|
||||
$MedicalCenter = $MedicalCenter->load(['users' => function ($query) {
|
||||
return $query->select(['id', 'medical_center_id', 'name', 'cell_number', 'status']);
|
||||
}, 'users.roles']);
|
||||
return response()->json($MedicalCenter, 200);
|
||||
return \MessageResponse::data($MedicalCenter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function changeStatus(User $User)
|
||||
{
|
||||
if ($User->status == 'Active') {
|
||||
@@ -69,18 +86,26 @@ class UserController extends Controller
|
||||
$User->status = 'Active';
|
||||
}
|
||||
$User->save();
|
||||
return response()->json($User, 200);
|
||||
return \MessageResponse::data($User);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function changeRole(User $User, Request $request)
|
||||
{
|
||||
$User->syncRoles($request->roles);
|
||||
return response()->json($User, 200);
|
||||
return \MessageResponse::data($User);
|
||||
}
|
||||
|
||||
public function updateInfo(Request $request)
|
||||
{
|
||||
auth('api')->user()->update($request->all());
|
||||
return response()->json(['user' => auth('api')->user()], 200);
|
||||
return \MessageResponse::success(trans('messages.success'));
|
||||
}
|
||||
|
||||
public function getInfo()
|
||||
{
|
||||
return \MessageResponse::data([ 'user' => auth('api')->user(), 'roles' => auth('api')->user()->getRoleNames() ]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user