Structor CSSD

This commit is contained in:
saeid
2019-04-25 20:14:09 +04:30
parent fc162db99b
commit 14a91bdef7
72 changed files with 6957 additions and 4636 deletions
@@ -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'));
}
+89 -23
View File
@@ -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) {
+113 -18
View File
@@ -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)
+45 -20
View File
@@ -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() ]);
}
}
+30 -30
View File
@@ -1,30 +1,30 @@
<?php // /app/Http/Middleware/Cors.php
namespace App\Http\Middleware;
use Closure;
class Cors {
public function handle($request, Closure $next)
{
/* @var $response Response */
$response = $next($request)
->header('Access-Control-Allow-Origin', '*')
->header('Access-Control-Allow-credentials', true)
->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
if (!$request->isMethod('OPTIONS')) {
return $response;
}
$allow = $response->headers->get('Allow'); // true list of allowed methods
if (!$allow) {
return $response;
}
$headers = [
'Access-Control-Allow-Methods' => $allow,
'Access-Control-Max-Age' => 3600,
'Access-Control-Allow-Headers' => 'X-Requested-With, Origin, X-Csrftoken, Content-Type, Accept',
];
return $response->withHeaders($headers);
}
}
<?php // /app/Http/Middleware/Cors.php␍
namespace App\Http\Middleware;␍
use Closure;␍
class Cors {␍
␍
␍
public function handle($request, Closure $next)␍
{␍
/* @var $response Response */␍
$response = $next($request)␍
->header('Access-Control-Allow-Origin', '*')␍
->header('Access-Control-Allow-credentials', true)␍
->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');␍
if (!$request->isMethod('OPTIONS')) {␍
return $response;␍
}␍
$allow = $response->headers->get('Allow'); // true list of allowed methods␍
if (!$allow) {␍
return $response;␍
}␍
$headers = [␍
'Access-Control-Allow-Methods' => $allow,␍
'Access-Control-Max-Age' => 3600,␍
'Access-Control-Allow-Headers' => 'X-Requested-With, Origin, X-Csrftoken, Content-Type, Accept',␍
];␍
return $response->withHeaders($headers);␍
}␍
␍
␍
}␍
+53 -53
View File
@@ -1,53 +1,53 @@
<?php
namespace App\Http\Requests;
use App\MedicalCenter;
use Illuminate\Validation\Rule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Contracts\Validation\Validator;
class StoreMedicalCenterRequest extends FormRequest
{
public function authorize()
{
if ($this->method() == 'POST') {
return auth('api')->check() && auth('api')->user()->can('store', MedicalCenter::class);
} else {
$MedicalCenter = $this->route('MedicalCenter');
return auth('api')->check() && $MedicalCenter && auth('api')->user()->can('update', $MedicalCenter);
}
}
public function rules()
{
switch ($this->method()) {
case 'POST': {
return [
'name' => 'required|max:100|unique:medical_centers',
// 'operatores.*.name'=>'required|string|max:255',
// 'operatores.*.cell_number'=>'required|digits_between:10,11|unique:users',
// 'operatores.*.password'=>'required|string|min:6',
];
break;
}
case 'PUT':
case 'PATCH': {
$MedicalCenter = $this->route('MedicalCenter');
return [
'name' => 'required|max:100|unique:medical_centers,id,'.$MedicalCenter->id,
// 'operatores.*.name'=>'required|string|max:255',
// 'operatores.*.cell_number'=>'required|digits_between:10,11|unique:users',
// 'operatores.*.password'=>'required|string|min:6',
];
break;
}
default:
break;
}
}
}
<?php␍
␍
namespace App\Http\Requests;␍
␍
use App\MedicalCenter;␍
use Illuminate\Validation\Rule;␍
use Illuminate\Foundation\Http\FormRequest;␍
use Illuminate\Contracts\Validation\Validator;␍
␍
␍
class StoreMedicalCenterRequest extends FormRequest␍
{␍
public function authorize()␍
{␍
if ($this->method() == 'POST') {␍
return auth('api')->check() && auth('api')->user()->can('store', MedicalCenter::class);␍
} else {␍
$MedicalCenter = $this->route('MedicalCenter');␍
return auth('api')->check() && $MedicalCenter && auth('api')->user()->can('update', $MedicalCenter);␍
}␍
}␍
␍
public function rules()␍
{␍
switch ($this->method()) {␍
case 'POST': {␍
return [␍
'name' => 'required|max:100|unique:medical_centers',␍
// 'operatores.*.name'=>'required|string|max:255',␍
// 'operatores.*.cell_number'=>'required|digits_between:10,11|unique:users',␍
// 'operatores.*.password'=>'required|string|min:6',␍
];␍
break;␍
}␍
case 'PUT':␍
case 'PATCH': {␍
$MedicalCenter = $this->route('MedicalCenter');␍
return [␍
'name' => 'required|max:100|unique:medical_centers,id,'.$MedicalCenter->id,␍
// 'operatores.*.name'=>'required|string|max:255',␍
// 'operatores.*.cell_number'=>'required|digits_between:10,11|unique:users',␍
// 'operatores.*.password'=>'required|string|min:6',␍
];␍
break;␍
␍
}␍
default:␍
break;␍
}␍
␍
}␍
␍
}␍
@@ -0,0 +1,63 @@
<?php␍
␍
namespace App\Http\Requests;␍
␍
use App\TestResult;␍
use Illuminate\Validation\Rule;␍
use Illuminate\Foundation\Http\FormRequest;␍
use Illuminate\Contracts\Validation\Validator;␍
␍
␍
class StoreTestResultRequest extends FormRequest␍
{␍
public function authorize()␍
{␍
if ($this->method() == 'POST') {␍
return auth('api')->check() && auth('api')->user()->can('store', TestResult::class);␍
} else {␍
$TestResult = $this->route('TestResult');␍
return auth('api')->check() && $TestResult && auth('api')->user()->can('update', $TestResult);␍
}␍
}␍
␍
public function rules()␍
{␍
switch ($this->method()) {␍
case 'POST': {␍
return [␍
// 'user_id' => 'required',␍
'autoclave_id' => 'required',␍
'test_type_id' => 'required|numeric|exists:test_types,id',␍
'result' => 'required',␍
// 'verified' => 'required',␍
// 'info.*.name'=>'required',␍
// 'info.*.type'=>'required',␍
// 'info.*.size'=>'nullable',␍
// 'info.*.parent_id'=>'nullable|numeric|exists:inputs,id',␍
];␍
break;␍
}␍
case 'PUT':␍
case 'PATCH': {␍
// $TestResult = $this->route('TestResult');␍
return [␍
// 'user_id' => 'required',␍
'autoclave_id' => 'required',␍
'test_type_id' => 'required|numeric|exists:test_types,id',␍
'result' => 'required',␍
// 'verified' => 'required',␍
// 'info.*.name'=>'required',␍
// 'info.*.type'=>'required',␍
// 'info.*.size'=>'nullable',␍
// 'info.*.parent_id'=>'nullable|numeric|exists:inputs,id',␍
];␍
break;␍
␍
}␍
default:␍
break;␍
}␍
␍
}␍
␍
}␍
+57 -57
View File
@@ -1,57 +1,57 @@
<?php
namespace App\Http\Requests;
use App\TestType;
use Illuminate\Validation\Rule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Contracts\Validation\Validator;
class StoreTestTypeRequest extends FormRequest
{
public function authorize()
{
if ($this->method() == 'POST') {
return auth('api')->check() && auth('api')->user()->can('store', TestType::class);
} else {
$TestType = $this->route('TestType');
return auth('api')->check() && $TestType && auth('api')->user()->can('update', $TestType);
}
}
public function rules()
{
switch ($this->method()) {
case 'POST': {
return [
'name' => 'required|max:100|unique:test_types',
'unique_code' => 'required|max:100|unique:test_types',
'info.*.name'=>'required',
'info.*.type'=>'required',
'info.*.size'=>'required',
'info.*.parent_id'=>'nullable|numeric|exists:inputs,id',
];
break;
}
case 'PUT':
case 'PATCH': {
$TestType = $this->route('TestType');
return [
'name' => 'required|max:100|unique:test_types,id,'.$TestType->id,
'unique_code' => 'required|max:100|unique:test_types,id,'.$TestType->id,
'info.*.name'=>'required',
'info.*.type'=>'required',
'info.*.size'=>'required',
'info.*.parent_id'=>'nullable|numeric|exists:inputs,id',
];
break;
}
default:
break;
}
}
}
<?php␍
␍
namespace App\Http\Requests;␍
␍
use App\TestType;␍
use Illuminate\Validation\Rule;␍
use Illuminate\Foundation\Http\FormRequest;␍
use Illuminate\Contracts\Validation\Validator;␍
␍
␍
class StoreTestTypeRequest extends FormRequest␍
{␍
public function authorize()␍
{␍
if ($this->method() == 'POST') {␍
return auth('api')->check() && auth('api')->user()->can('store', TestType::class);␍
} else {␍
$TestType = $this->route('TestType');␍
return auth('api')->check() && $TestType && auth('api')->user()->can('update', $TestType);␍
}␍
}␍
␍
public function rules()␍
{␍
switch ($this->method()) {␍
case 'POST': {␍
return [␍
'name' => 'required|max:100|unique:test_types',␍
'unique_code' => 'required|max:100|unique:test_types',␍
'info.*.name'=>'required',␍
'info.*.type'=>'required',␍
'info.*.size'=>'nullable',␍
'info.*.parent_id'=>'nullable|numeric|exists:inputs,id',␍
];␍
break;␍
}␍
case 'PUT':␍
case 'PATCH': {␍
$TestType = $this->route('TestType');␍
return [␍
'name' => 'required|max:100|unique:test_types,id,'.$TestType->id,␍
'unique_code' => 'required|max:100|unique:test_types,id,'.$TestType->id,␍
'info.*.name'=>'required',␍
'info.*.type'=>'required',␍
'info.*.size'=>'nullable',␍
'info.*.parent_id'=>'nullable|numeric|exists:inputs,id',␍
];␍
break;␍
␍
}␍
default:␍
break;␍
}␍
␍
}␍
␍
}␍
+53 -53
View File
@@ -1,53 +1,53 @@
<?php
namespace App\Http\Requests;
use App\User;
use Illuminate\Validation\Rule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Contracts\Validation\Validator;
class StoreUserRequest extends FormRequest
{
public function authorize()
{
if ($this->method() == 'POST') {
return auth('api')->check() && auth('api')->user()->can('store', User::class);
} else {
$User = $this->route('User');
return auth('api')->check() && $User && auth('api')->user()->can('update', $User);
}
}
public function rules()
{
switch ($this->method()) {
case 'POST': {
return [
'name'=>'required|string|max:255',
'cell_number'=>'required|digits_between:10,11|unique:users',
'password'=>'required|string|min:6',
'medical_center_id' => 'required|numeric|exists:medical_centers,id',
];
break;
}
case 'PUT':
case 'PATCH': {
$User = $this->route('User');
return [
'name'=>'required|string|max:255',
'cell_number'=>'required|digits_between:10,11|unique:users,id,'.$User->id,
'password'=>'required|string|min:6',
'medical_center_id' => 'required|numeric|exists:medical_centers,id',
];
break;
}
default:
break;
}
}
}
<?php␍
␍
namespace App\Http\Requests;␍
␍
use App\User;␍
use Illuminate\Validation\Rule;␍
use Illuminate\Foundation\Http\FormRequest;␍
use Illuminate\Contracts\Validation\Validator;␍
␍
␍
class StoreUserRequest extends FormRequest␍
{␍
public function authorize()␍
{␍
if ($this->method() == 'POST') {␍
return auth('api')->check() && auth('api')->user()->can('store', User::class);␍
} else {␍
$User = $this->route('User');␍
return auth('api')->check() && $User && auth('api')->user()->can('update', $User);␍
}␍
}␍
␍
public function rules()␍
{␍
switch ($this->method()) {␍
case 'POST': {␍
return [␍
'name'=>'required|string|max:255',␍
'cell_number'=>'required|digits_between:10,11|unique:users',␍
'password'=>'required|string|min:6',␍
'medical_center_id' => 'required|numeric|exists:medical_centers,id',␍
];␍
break;␍
}␍
case 'PUT':␍
case 'PATCH': {␍
$User = $this->route('User');␍
return [␍
'name'=>'required|string|max:255',␍
'cell_number'=>'required|digits_between:10,11|unique:users,id,'.$User->id,␍
'password'=>'required|string|min:6',␍
'medical_center_id' => 'required|numeric|exists:medical_centers,id',␍
];␍
break;␍
␍
}␍
default:␍
break;␍
}␍
␍
}␍
␍
}␍