mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-10 19:11:07 +03:30
feat: install phpstan and resolving reported errors in PHPStan
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@ namespace App;
|
|||||||
|
|
||||||
use App\Services\Media\HasMediaTrait;
|
use App\Services\Media\HasMediaTrait;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Spatie\MediaLibrary\HasMedia\HasMedia;
|
use Spatie\MediaLibrary\HasMedia;
|
||||||
|
|
||||||
class FakeModel extends Model implements HasMedia
|
class FakeModel extends Model implements HasMedia
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,22 +3,22 @@
|
|||||||
namespace App\Http\Controllers\Api\Auth;
|
namespace App\Http\Controllers\Api\Auth;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
use App\User;
|
use App\User;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Packages\Messaging\src\Facades\MessageResponse;
|
||||||
|
|
||||||
class RegisterController extends Controller
|
class RegisterController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Register the given user.
|
* Register the given user.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function register(Request $request)
|
public function register(Request $request)
|
||||||
{
|
{
|
||||||
if (auth('api')->user()->cant('store', User::class)) {
|
if (auth('api')->user()->cant('store', User::class)) {
|
||||||
return \MessageResponse::error(trans('messages.failed'));
|
return MessageResponse::error(trans('messages.failed'));
|
||||||
}
|
}
|
||||||
$this->validate($request, $this->rules(), $this->validationErrorMessages());
|
$this->validate($request, $this->rules(), $this->validationErrorMessages());
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ class RegisterController extends Controller
|
|||||||
$user->cell_number = $request->cell_number;
|
$user->cell_number = $request->cell_number;
|
||||||
$user->gender = $request->gender;
|
$user->gender = $request->gender;
|
||||||
$user->medical_center_id = $request->medical_center_id;
|
$user->medical_center_id = $request->medical_center_id;
|
||||||
$user->password = bcrypt( $request->password );
|
$user->password = bcrypt($request->password);
|
||||||
$user->save();
|
$user->save();
|
||||||
$user->assignRole('User');
|
$user->assignRole('User');
|
||||||
return response()->json($user, 200);
|
return response()->json($user, 200);
|
||||||
|
|||||||
@@ -3,7 +3,10 @@
|
|||||||
namespace App\Http\Controllers\Api\Auth;
|
namespace App\Http\Controllers\Api\Auth;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Packages\Messaging\src\Facades\MessageResponse;
|
||||||
|
|
||||||
class ResetPasswordController extends Controller
|
class ResetPasswordController extends Controller
|
||||||
{
|
{
|
||||||
@@ -16,8 +19,8 @@ class ResetPasswordController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Reset the given user's password.
|
* Reset the given user's password.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param Request $request
|
||||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
|
* @return JsonResponse
|
||||||
*/
|
*/
|
||||||
public function reset(Request $request)
|
public function reset(Request $request)
|
||||||
{
|
{
|
||||||
@@ -25,20 +28,20 @@ class ResetPasswordController extends Controller
|
|||||||
|
|
||||||
if (auth('api')->check()) {
|
if (auth('api')->check()) {
|
||||||
$user = auth('api')->user();
|
$user = auth('api')->user();
|
||||||
$user->password = \Hash::make($request->password);
|
$user->password = Hash::make($request->password);
|
||||||
$user->save();
|
$user->save();
|
||||||
return \MessageResponse::success('Success Change Password');
|
return MessageResponse::success('Success Change Password');
|
||||||
}
|
}
|
||||||
return \MessageResponse::success('You Are Not Login');
|
return MessageResponse::success('You Are Not Login');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate the email for the given request.
|
* Validate the email for the given request.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param Request $request
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function validatePassword(Request $request)
|
protected function validatePassword(Request $request): void
|
||||||
{
|
{
|
||||||
$request->validate(['password' => 'required|confirmed|min:8',]);
|
$request->validate(['password' => 'required|confirmed|min:8',]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,55 +1,56 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use \Milon\Barcode\Facades\DNS1DFacade;
|
use App\Package;
|
||||||
use \Milon\Barcode\Facades\DNS2DFacade;
|
use App\TestResult;
|
||||||
use App\TestResult;
|
use Milon\Barcode\Facades\DNS1DFacade;
|
||||||
use App\Package;
|
use Milon\Barcode\Facades\DNS2DFacade;
|
||||||
|
use Packages\Messaging\src\Facades\MessageResponse;
|
||||||
|
|
||||||
class BarCodeController extends Controller
|
class BarCodeController extends Controller
|
||||||
|
{
|
||||||
|
public function generateBarcode($Number, $Type = null)
|
||||||
{
|
{
|
||||||
public function generateBarcode( $Number , $Type = null )
|
if ($Number != "undefined") {
|
||||||
{
|
$URL = 'https://www.cssd-doc.com/Show/' . $Type . '/' . $Number;
|
||||||
if ( $Number != "undefined" ) {
|
$Barcode = DNS1DFacade::getBarcodePNG($Number, "C128");
|
||||||
$URL = 'https://www.cssd-doc.com/Show/' . $Type . '/' . $Number;
|
$QRCode = DNS2DFacade::getBarcodePNG($URL, "QRCODE");
|
||||||
$Barcode = DNS1DFacade::getBarcodePNG( $Number , "C128" );
|
$ShowLink = 'Show/' . $Type . '/' . $Number;
|
||||||
$QRCode = DNS2DFacade::getBarcodePNG( $URL , "QRCODE" );
|
if ($Type == 'TestType') {
|
||||||
$ShowLink = 'Show/' . $Type . '/' . $Number;
|
$QRCode = DNS2DFacade::getBarcodePNG($Number, "QRCODE");
|
||||||
if ( $Type == 'TestType' ) {
|
|
||||||
$QRCode = DNS2DFacade::getBarcodePNG( $Number , "QRCODE" );
|
|
||||||
}
|
|
||||||
|
|
||||||
return \MessageResponse::data( [ 'Barcode' => 'data:image/png;base64,' . $Barcode , 'QRCode' => 'data:image/png;base64,' . $QRCode , 'ShowLink' => $ShowLink ] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function generateQRcode( TestResult $TestResult )
|
|
||||||
{
|
|
||||||
if ( $TestResult ) {
|
|
||||||
$URL = 'https://www.cssd-doc.com/ShowTestResult/' . $TestResult->id;
|
|
||||||
$QRCode = DNS2DFacade::getBarcodePNG( $URL , "QRCODE" );
|
|
||||||
return \MessageResponse::data( [ 'QRCode' => 'data:image/png;base64,' . $QRCode ] );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
return MessageResponse::data(['Barcode' => 'data:image/png;base64,' . $Barcode, 'QRCode' => 'data:image/png;base64,' . $QRCode, 'ShowLink' => $ShowLink]);
|
||||||
|
|
||||||
public function generatePackageBarcode( $Number )
|
|
||||||
{
|
|
||||||
if ( $Number != "undefined" ) {
|
|
||||||
// $Barcode = DNS1DFacade::getBarcodePNGUri($Number, "C128");
|
|
||||||
// $QRCode = DNS2DFacade::getBarcodePNGUri($Number, "QRCODE");
|
|
||||||
$Barcode = DNS1DFacade::getBarcodePNG( $Number , "C128" );
|
|
||||||
$QRCode = DNS2DFacade::getBarcodePNG( $Number , "QRCODE" );
|
|
||||||
$Package = Package::where( 'unique_id' , $Number )->first();
|
|
||||||
return \MessageResponse::data( [ 'Barcode' => $Barcode , 'QRCode' => $QRCode , 'ShowLink' => 'Show/Package/' . $Package->id ] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function generatePackageQRCode( Package $Package )
|
|
||||||
{
|
|
||||||
$URL = 'https://www.cssd-doc.com/Show/Package/' . $Package->id;
|
|
||||||
$QRCode = DNS2DFacade::getBarcodePNG( $URL , "QRCODE" );
|
|
||||||
return \MessageResponse::data( [ 'QRCode' => 'data:image/png;base64,' . $QRCode ] );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function generateQRcode(TestResult $TestResult)
|
||||||
|
{
|
||||||
|
if ($TestResult) {
|
||||||
|
$URL = 'https://www.cssd-doc.com/ShowTestResult/' . $TestResult->id;
|
||||||
|
$QRCode = DNS2DFacade::getBarcodePNG($URL, "QRCODE");
|
||||||
|
return MessageResponse::data(['QRCode' => 'data:image/png;base64,' . $QRCode]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generatePackageBarcode($Number)
|
||||||
|
{
|
||||||
|
if ($Number != "undefined") {
|
||||||
|
// $Barcode = DNS1DFacade::getBarcodePNGUri($Number, "C128");
|
||||||
|
// $QRCode = DNS2DFacade::getBarcodePNGUri($Number, "QRCODE");
|
||||||
|
$Barcode = DNS1DFacade::getBarcodePNG($Number, "C128");
|
||||||
|
$QRCode = DNS2DFacade::getBarcodePNG($Number, "QRCODE");
|
||||||
|
$Package = Package::where('unique_id', $Number)->first();
|
||||||
|
return MessageResponse::data(['Barcode' => $Barcode, 'QRCode' => $QRCode, 'ShowLink' => 'Show/Package/' . $Package->id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generatePackageQRCode(Package $Package)
|
||||||
|
{
|
||||||
|
$URL = 'https://www.cssd-doc.com/Show/Package/' . $Package->id;
|
||||||
|
$QRCode = DNS2DFacade::getBarcodePNG($URL, "QRCODE");
|
||||||
|
return MessageResponse::data(['QRCode' => 'data:image/png;base64,' . $QRCode]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,14 +3,15 @@
|
|||||||
namespace App\Http\Controllers\Media;
|
namespace App\Http\Controllers\Media;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
use Packages\Messaging\src\Facades\MessageResponse;
|
use Packages\Messaging\src\Facades\MessageResponse;
|
||||||
use Spatie\MediaLibrary\Models\Media;
|
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||||
|
|
||||||
class DestroyMedia extends Controller
|
class DestroyMedia extends Controller
|
||||||
{
|
{
|
||||||
public function __invoke(Media $media)
|
public function __invoke(Media $media): JsonResponse
|
||||||
{
|
{
|
||||||
$media->delete();
|
$media->delete();
|
||||||
return MessageResponse::success( null , trans( 'messages.success' ) );
|
return MessageResponse::success(null, trans('messages.success'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,46 +2,47 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use App\Http\Requests\StoreMessageRequest;
|
use App\Http\Requests\StoreMessageRequest;
|
||||||
use App\Message;
|
use App\Message;
|
||||||
use App\User;
|
use App\User;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Packages\Messaging\src\Facades\MessageResponse;
|
||||||
|
|
||||||
class MessageController extends Controller
|
class MessageController extends Controller
|
||||||
{
|
{
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$User = auth('api')->user();
|
$User = auth('api')->user();
|
||||||
$role = null;
|
$role = null;
|
||||||
$medical_center_id = null;
|
$medical_center_id = null;
|
||||||
|
|
||||||
$User = auth('api')->user();
|
$User = auth('api')->user();
|
||||||
if ($User->hasRole('Supervisor') || $User->hasRole('User')) {
|
if ($User->hasRole('Supervisor') || $User->hasRole('User')) {
|
||||||
$medical_center_id = $User->medical_center_id;
|
$medical_center_id = $User->medical_center_id;
|
||||||
$role = 'Admin';
|
$role = 'Admin';
|
||||||
}
|
}
|
||||||
$remove = $User->id;
|
$remove = $User->id;
|
||||||
$Users = User::whereHas('messagesSent', function($q) use($User){
|
$Users = User::whereHas('messagesSent', function ($q) use ($User) {
|
||||||
$q->where('recipient_user_id', $User->id);
|
$q->where('recipient_user_id', $User->id);
|
||||||
})
|
})
|
||||||
->orWhereHas('messagesReceived', function($q) use($User){
|
->orWhereHas('messagesReceived', function ($q) use ($User) {
|
||||||
$q->where('sender_user_id', $User->id);
|
$q->where('sender_user_id', $User->id);
|
||||||
})
|
})
|
||||||
->when($medical_center_id, function($query) use ($medical_center_id){
|
->when($medical_center_id, function ($query) use ($medical_center_id) {
|
||||||
$query->where('medical_center_id', $medical_center_id);
|
$query->where('medical_center_id', $medical_center_id);
|
||||||
})
|
})
|
||||||
->when($role, function($query) use($role){
|
->when($role, function ($query) use ($role) {
|
||||||
$query->role($role);
|
$query->role($role);
|
||||||
})
|
})
|
||||||
->paginate(10);
|
->paginate(10);
|
||||||
|
|
||||||
foreach ($Users as $user) {
|
foreach ($Users as $user) {
|
||||||
$UnReadReceivedMessages = Message::where('sender_user_id', $user->id)->where('recipient_user_id', $User->id)->where('status','UnRead')->get()->count();
|
$UnReadReceivedMessages = Message::where('sender_user_id', $user->id)->where('recipient_user_id', $User->id)->where('status', 'UnRead')->get()->count();
|
||||||
$user->unread_messages_count = $UnReadReceivedMessages;
|
$user->unread_messages_count = $UnReadReceivedMessages;
|
||||||
|
|
||||||
$MessagesCount = Message::where(function ($query) use ($user,$User){
|
$MessagesCount = Message::where(function ($query) use ($user, $User) {
|
||||||
$query->where('sender_user_id', $user->id)->where('recipient_user_id', $User->id);
|
$query->where('sender_user_id', $user->id)->where('recipient_user_id', $User->id);
|
||||||
})->orWhere(function ($query) use ($user,$User){
|
})->orWhere(function ($query) use ($user, $User) {
|
||||||
$query->where('sender_user_id', $User->id)->where('recipient_user_id', $user->id);
|
$query->where('sender_user_id', $User->id)->where('recipient_user_id', $user->id);
|
||||||
})->get()->count();
|
})->get()->count();
|
||||||
|
|
||||||
@@ -53,78 +54,81 @@ class MessageController extends Controller
|
|||||||
// return $value['id'] != $remove;
|
// return $value['id'] != $remove;
|
||||||
// });
|
// });
|
||||||
|
|
||||||
return \MessageResponse::data($Users);
|
return MessageResponse::data($Users);
|
||||||
}
|
}
|
||||||
public function create()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
public function create()
|
||||||
public function show($UserID)
|
{
|
||||||
{
|
|
||||||
// if (!auth('api')->user()->can('show', $Message)) {
|
|
||||||
// return \MessageResponse::error(trans('messages.access_denied'));
|
|
||||||
// }
|
|
||||||
|
|
||||||
$User = User::findOrFail($UserID);
|
}
|
||||||
// $SendMessages = Message::where('sender_user_id', auth('api')->user()->id)->where('recipient_user_id', $UserID)->get();
|
|
||||||
$ReceivedMessages = Message::where('sender_user_id', $UserID)->where('recipient_user_id', auth('api')->user()->id)->get();
|
|
||||||
|
|
||||||
$Messages = Message::where(function ($query) use ($UserID)
|
public function show($UserID)
|
||||||
{
|
{
|
||||||
$query->where('sender_user_id', auth('api')->user()->id)->where('recipient_user_id', $UserID);
|
// if (!auth('api')->user()->can('show', $Message)) {
|
||||||
})->orWhere(function ($query) use ($UserID)
|
// return MessageResponse::error(trans('messages.access_denied'));
|
||||||
{
|
// }
|
||||||
$query->where('sender_user_id', $UserID)->where('recipient_user_id', auth('api')->user()->id);
|
|
||||||
})->get();
|
|
||||||
|
|
||||||
foreach ($ReceivedMessages as $ReceivedMessage) {
|
$User = User::findOrFail($UserID);
|
||||||
$ReceivedMessage->status = 'Read';
|
// $SendMessages = Message::where('sender_user_id', auth('api')->user()->id)->where('recipient_user_id', $UserID)->get();
|
||||||
$ReceivedMessage->save();
|
$ReceivedMessages = Message::where('sender_user_id', $UserID)->where('recipient_user_id', auth('api')->user()->id)->get();
|
||||||
}
|
|
||||||
|
|
||||||
return \MessageResponse::data($Messages);
|
$Messages = Message::where(function ($query) use ($UserID) {
|
||||||
}
|
$query->where('sender_user_id', auth('api')->user()->id)->where('recipient_user_id', $UserID);
|
||||||
public function store(StoreMessageRequest $request)
|
})->orWhere(function ($query) use ($UserID) {
|
||||||
{
|
$query->where('sender_user_id', $UserID)->where('recipient_user_id', auth('api')->user()->id);
|
||||||
$MessageData = [
|
})->get();
|
||||||
// 'title' => $request->title,
|
|
||||||
'text' => $request->message,
|
foreach ($ReceivedMessages as $ReceivedMessage) {
|
||||||
'sender_user_id' => auth('api')->user()->id,
|
$ReceivedMessage->status = 'Read';
|
||||||
'recipient_user_id' => $request->user_id,
|
$ReceivedMessage->save();
|
||||||
'status' => 'UnRead',
|
}
|
||||||
];
|
|
||||||
Message::create($MessageData);
|
return MessageResponse::data($Messages);
|
||||||
return \MessageResponse::success(trans('messages.success'));
|
}
|
||||||
}
|
|
||||||
public function edit(Message $Message)
|
public function store(StoreMessageRequest $request)
|
||||||
{
|
{
|
||||||
// return \MessageResponse::data($Message);
|
$MessageData = [
|
||||||
}
|
// 'title' => $request->title,
|
||||||
public function update(StoreMessageRequest $request, Message $Message)
|
'text' => $request->message,
|
||||||
{
|
'sender_user_id' => auth('api')->user()->id,
|
||||||
// $Message->update($request->all());
|
'recipient_user_id' => $request->user_id,
|
||||||
// return \MessageResponse::success(trans('messages.success'));
|
'status' => 'UnRead',
|
||||||
}
|
];
|
||||||
public function destroy(Message $Message)
|
Message::create($MessageData);
|
||||||
{
|
return MessageResponse::success(trans('messages.success'));
|
||||||
if (auth('api')->user()->cant('delete', $Message)) {
|
}
|
||||||
return \MessageResponse::error(trans('messages.access_denied'));
|
|
||||||
}
|
public function edit(Message $Message)
|
||||||
$Message->delete();
|
{
|
||||||
return \MessageResponse::success(trans('messages.success'));
|
// return MessageResponse::data($Message);
|
||||||
}
|
}
|
||||||
public function destroyUserMessages(User $User)
|
|
||||||
{
|
public function update(StoreMessageRequest $request, Message $Message)
|
||||||
// if (auth('api')->user()->cant('deleteUserMessage', Message::class)) {
|
{
|
||||||
// return \MessageResponse::error(trans('messages.access_denied'));
|
// $Message->update($request->all());
|
||||||
// }
|
// return MessageResponse::success(trans('messages.success'));
|
||||||
Message::where(function ($query) use ($User)
|
}
|
||||||
{
|
|
||||||
$query->where('sender_user_id', auth('api')->user()->id)->where('recipient_user_id', $User->id);
|
public function destroy(Message $Message)
|
||||||
})->orWhere(function ($query) use ($User)
|
{
|
||||||
{
|
if (auth('api')->user()->cant('delete', $Message)) {
|
||||||
$query->where('sender_user_id', $User->id)->where('recipient_user_id', auth('api')->user()->id);
|
return MessageResponse::error(trans('messages.access_denied'));
|
||||||
})->get()->each->delete();
|
}
|
||||||
return \MessageResponse::success(trans('messages.success'));
|
$Message->delete();
|
||||||
}
|
return MessageResponse::success(trans('messages.success'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroyUserMessages(User $User)
|
||||||
|
{
|
||||||
|
// if (auth('api')->user()->cant('deleteUserMessage', Message::class)) {
|
||||||
|
// return MessageResponse::error(trans('messages.access_denied'));
|
||||||
|
// }
|
||||||
|
Message::where(function ($query) use ($User) {
|
||||||
|
$query->where('sender_user_id', auth('api')->user()->id)->where('recipient_user_id', $User->id);
|
||||||
|
})->orWhere(function ($query) use ($User) {
|
||||||
|
$query->where('sender_user_id', $User->id)->where('recipient_user_id', auth('api')->user()->id);
|
||||||
|
})->get()->each->delete();
|
||||||
|
return MessageResponse::success(trans('messages.success'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,141 +12,142 @@ use App\TestResult;
|
|||||||
use App\TestType;
|
use App\TestType;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Packages\Messaging\src\Facades\MessageResponse;
|
use Packages\Messaging\src\Facades\MessageResponse;
|
||||||
|
|
||||||
class TestResultController extends Controller
|
class TestResultController extends Controller
|
||||||
{
|
{
|
||||||
public function index( Request $request )
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
$user = auth( 'api' )->user();
|
$user = auth('api')->user();
|
||||||
|
|
||||||
if ( $user->hasRole( 'Supervisor|User' ) ) {
|
if ($user->hasRole('Supervisor|User')) {
|
||||||
$medical_center_id = $user->medical_center_id;
|
$medical_center_id = $user->medical_center_id;
|
||||||
} elseif ( $request->has( 'medicalCenter_id' ) && $request->medicalCenter_id != '' && $request->medicalCenter_id != 'undefined' ) {
|
} elseif ($request->has('medicalCenter_id') && $request->medicalCenter_id != '' && $request->medicalCenter_id != 'undefined') {
|
||||||
$medical_center_id = $request->medicalCenter_id;
|
$medical_center_id = $request->medicalCenter_id;
|
||||||
} else {
|
} else {
|
||||||
$medical_center_id = null;
|
$medical_center_id = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $user->hasRole( 'User' ) ) {
|
if ($user->hasRole('User')) {
|
||||||
$user_name = $user->name;
|
$user_name = $user->name;
|
||||||
} elseif ( $request->has( 'user_name' ) && $request->user_name ) {
|
} elseif ($request->has('user_name') && $request->user_name) {
|
||||||
$user_name = $request->user_name;
|
$user_name = $request->user_name;
|
||||||
} else {
|
} else {
|
||||||
$user_name = null;
|
$user_name = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$TestResult = TestResult::when( $request->has( 'verified' ) , function ( $query ) use ( $request ) {
|
$TestResult = TestResult::when($request->has('verified'), function ($query) use ($request) {
|
||||||
return $query->where( 'verified' , $request->verified )->orWhere( 'verified' , "None" );
|
return $query->where('verified', $request->verified)->orWhere('verified', "None");
|
||||||
} )
|
})
|
||||||
->when( ( $request->has( 'fromPicker' ) && $request->fromPicker ) || ( $request->has( 'upToPicker' ) && $request->upToPicker ) , function ( $query ) use ( $request ) {
|
->when(($request->has('fromPicker') && $request->fromPicker) || ($request->has('upToPicker') && $request->upToPicker), function ($query) use ($request) {
|
||||||
$from = ( $request->fromPicker ) ? date( $request->fromPicker . ' 00:00:00' ) : date( '2010-01-01' . ' 00:00:00' );
|
$from = ($request->fromPicker) ? date($request->fromPicker . ' 00:00:00') : date('2010-01-01' . ' 00:00:00');
|
||||||
$upTo = ( $request->upToPicker ) ? date( $request->upToPicker . ' 23:59:59' ) : date( 'Y-m-d' . ' 23:59:59' );
|
$upTo = ($request->upToPicker) ? date($request->upToPicker . ' 23:59:59') : date('Y-m-d' . ' 23:59:59');
|
||||||
return $query->whereBetween( 'created_at' , [ $from , $upTo ] );
|
return $query->whereBetween('created_at', [$from, $upTo]);
|
||||||
} )
|
})
|
||||||
->when( $request->has( 'testType_id' ) && $request->testType_id , function ( $query ) use ( $request ) {
|
->when($request->has('testType_id') && $request->testType_id, function ($query) use ($request) {
|
||||||
$query->where( 'test_type_id' , $request->testType_id );
|
$query->where('test_type_id', $request->testType_id);
|
||||||
} )
|
})
|
||||||
->when( ( $request->has( 'device_id' ) && $request->device_id ) && ( $request->has( 'device_label' ) && $request->device_label && $request->device_label != "undefined" ) , function ( $query ) use ( $request ) {
|
->when(($request->has('device_id') && $request->device_id) && ($request->has('device_label') && $request->device_label && $request->device_label != "undefined"), function ($query) use ($request) {
|
||||||
if ( $request->device_label != 'undefined' ) {
|
if ($request->device_label != 'undefined') {
|
||||||
$query->whereHas( 'input_values' , function ( $query ) use ( $request ) {
|
$query->whereHas('input_values', function ($query) use ($request) {
|
||||||
$query->whereHas( 'input' , function ( $query ) use ( $request ) {
|
$query->whereHas('input', function ($query) use ($request) {
|
||||||
$query->where( 'name' , $request->device_label );
|
$query->where('name', $request->device_label);
|
||||||
} )->where( 'value' , $request->device_id );
|
})->where('value', $request->device_id);
|
||||||
} );
|
});
|
||||||
} else {
|
} else {
|
||||||
$query->where( function ( $query ) use ( $request ) {
|
$query->where(function ($query) use ($request) {
|
||||||
$query->where( 'id' , $request->device_id );
|
$query->where('id', $request->device_id);
|
||||||
} );
|
});
|
||||||
}
|
}
|
||||||
} )
|
})
|
||||||
->when( ( $request->has( 'device_id' ) && $request->device_id ) && ! ( $request->has( 'device_label' ) && $request->device_label && $request->device_label != "undefined" ) , function ( $query ) use ( $request ) {
|
->when(($request->has('device_id') && $request->device_id) && !($request->has('device_label') && $request->device_label && $request->device_label != "undefined"), function ($query) use ($request) {
|
||||||
$query->where( function ( $query ) use ( $request ) {
|
$query->where(function ($query) use ($request) {
|
||||||
$query->where( 'id' , $request->device_id );
|
$query->where('id', $request->device_id);
|
||||||
} );
|
});
|
||||||
} )
|
})
|
||||||
->when( ( $request->has( 'device_label' ) && $request->device_label && $request->device_label != "undefined" ) && ! ( $request->has( 'device_id' ) && $request->device_id ) , function ( $query ) use ( $request ) {
|
->when(($request->has('device_label') && $request->device_label && $request->device_label != "undefined") && !($request->has('device_id') && $request->device_id), function ($query) use ($request) {
|
||||||
$query->whereHas( 'input_values' , function ( $query ) use ( $request ) {
|
$query->whereHas('input_values', function ($query) use ($request) {
|
||||||
$query->whereHas( 'input' , function ( $query ) use ( $request ) {
|
$query->whereHas('input', function ($query) use ($request) {
|
||||||
$query->where( 'name' , $request->device_label );
|
$query->where('name', $request->device_label);
|
||||||
} );
|
});
|
||||||
} );
|
});
|
||||||
} )
|
})
|
||||||
->when( $user_name , function ( $query ) use ( $user_name ) {
|
->when($user_name, function ($query) use ($user_name) {
|
||||||
$query->whereHas( 'user' , function ( $query ) use ( $user_name ) {
|
$query->whereHas('user', function ($query) use ($user_name) {
|
||||||
$query->where( 'name' , 'LIKE' , '%' . $user_name . '%' );
|
$query->where('name', 'LIKE', '%' . $user_name . '%');
|
||||||
} );
|
});
|
||||||
} )
|
})
|
||||||
->when( $medical_center_id , function ( $query ) use ( $medical_center_id ) {
|
->when($medical_center_id, function ($query) use ($medical_center_id) {
|
||||||
$query->whereHas( 'user' , function ( $query ) use ( $medical_center_id ) {
|
$query->whereHas('user', function ($query) use ($medical_center_id) {
|
||||||
$query->where( 'medical_center_id' , $medical_center_id );
|
$query->where('medical_center_id', $medical_center_id);
|
||||||
} );
|
});
|
||||||
} )
|
})
|
||||||
->with( [
|
->with([
|
||||||
'user' ,
|
'user',
|
||||||
'user.medical_center' => function ( $query ) {
|
'user.medical_center' => function ($query) {
|
||||||
$query->select( 'id' , 'name' , 'address' , 'phone_number' );
|
$query->select('id', 'name', 'address', 'phone_number');
|
||||||
} ,
|
},
|
||||||
'test_type' => function ( $query ) {
|
'test_type' => function ($query) {
|
||||||
$query->select( 'id' , 'name' );
|
$query->select('id', 'name');
|
||||||
} ] )
|
}])
|
||||||
->orderByDesc( 'id' )->paginate( 10 );
|
->orderByDesc('id')->paginate(10);
|
||||||
|
|
||||||
return TestResultResource::collection( $TestResult );
|
return TestResultResource::collection($TestResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function store( StoreTestResultRequest $request )
|
public function store(StoreTestResultRequest $request)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
DB::transaction( function () use ( $request ) {
|
DB::transaction(function () use ($request) {
|
||||||
|
|
||||||
$TestResult = [
|
$TestResult = [
|
||||||
'user_id' => auth( 'api' )->user()->id ,
|
'user_id' => auth('api')->user()->id,
|
||||||
'cycle_number' => $request->cycle_number ,
|
'cycle_number' => $request->cycle_number,
|
||||||
'date' => $request->date ,
|
'date' => $request->date,
|
||||||
'test_type_id' => $request->test_type_id ,
|
'test_type_id' => $request->test_type_id,
|
||||||
'result' => $request->result ,
|
'result' => $request->result,
|
||||||
'verified' => 'None' ,
|
'verified' => 'None',
|
||||||
];
|
];
|
||||||
$TestResultObj = TestResult::create( $TestResult );
|
$TestResultObj = TestResult::create($TestResult);
|
||||||
$TestResultInfo = $request->all();
|
$TestResultInfo = $request->all();
|
||||||
|
|
||||||
$Inputs = Input::with( 'options' , 'children' , 'children.options' )->whereNull( 'parent_id' )->where( 'test_type_id' , $request->test_type_id )->get();
|
$Inputs = Input::with('options', 'children', 'children.options')->whereNull('parent_id')->where('test_type_id', $request->test_type_id)->get();
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////Inputs
|
///////////////////////////////////////////////////////////////////////////Inputs
|
||||||
foreach ( $Inputs as $Input ) {
|
foreach ($Inputs as $Input) {
|
||||||
if ( $Input[ 'type' ] != 'Form' ) {
|
if ($Input['type'] != 'Form') {
|
||||||
$Value = $TestResultInfo[ $Input->name . '_' . $Input->id ];
|
$Value = $TestResultInfo[$Input->name . '_' . $Input->id];
|
||||||
if ( $Input[ 'type' ] == 'Checkbox' || $Input[ 'type' ] == 'Select' || $Input[ 'type' ] == 'Radiobutton' ) {
|
if ($Input['type'] == 'Checkbox' || $Input['type'] == 'Select' || $Input['type'] == 'Radiobutton') {
|
||||||
|
|
||||||
foreach ( $Input->options as $Option ) {//--2
|
foreach ($Input->options as $Option) {//--2
|
||||||
if ( is_array( $Value ) && in_array( $Option->id , $Value ) ) {
|
if (is_array($Value) && in_array($Option->id, $Value)) {
|
||||||
$InputValueObj = InputValue::create( [ 'test_result_id' => $TestResultObj->id , 'input_id' => $Input->id , 'option_id' => $Option->id ] );
|
$InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id, 'input_id' => $Input->id, 'option_id' => $Option->id]);
|
||||||
}
|
}
|
||||||
if ( $Input[ 'type' ] == 'Radiobutton' && $Option->id == $Value ) {
|
if ($Input['type'] == 'Radiobutton' && $Option->id == $Value) {
|
||||||
$InputValueObj = InputValue::create( [ 'test_result_id' => $TestResultObj->id , 'input_id' => $Input->id , 'option_id' => $Option->id ] );
|
$InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id, 'input_id' => $Input->id, 'option_id' => $Option->id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$InputValueObj = InputValue::create( [ 'test_result_id' => $TestResultObj->id , 'input_id' => $Input->id , 'value' => $Value ] );
|
$InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id, 'input_id' => $Input->id, 'value' => $Value]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach ( $Input->children as $InputChild ) {
|
foreach ($Input->children as $InputChild) {
|
||||||
$Value = $TestResultInfo[ $InputChild->name . '_' . $InputChild->id ];
|
$Value = $TestResultInfo[$InputChild->name . '_' . $InputChild->id];
|
||||||
|
|
||||||
if ( $InputChild[ 'type' ] == 'Checkbox' || $InputChild[ 'type' ] == 'Select' || $InputChild[ 'type' ] == 'Radiobutton' ) {
|
if ($InputChild['type'] == 'Checkbox' || $InputChild['type'] == 'Select' || $InputChild['type'] == 'Radiobutton') {
|
||||||
|
|
||||||
foreach ( $InputChild->options as $Option ) {//--2
|
foreach ($InputChild->options as $Option) {//--2
|
||||||
if ( is_array( $Value ) && in_array( $Option->id , $Value ) ) {
|
if (is_array($Value) && in_array($Option->id, $Value)) {
|
||||||
$InputValueObj = InputValue::create( [ 'test_result_id' => $TestResultObj->id , 'input_id' => $InputChild->id , 'option_id' => $Option->id ] );
|
$InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id, 'input_id' => $InputChild->id, 'option_id' => $Option->id]);
|
||||||
}
|
}
|
||||||
if ( $InputChild[ 'type' ] == 'Radiobutton' && $Option->id == $Value ) {
|
if ($InputChild['type'] == 'Radiobutton' && $Option->id == $Value) {
|
||||||
$InputValueObj = InputValue::create( [ 'test_result_id' => $TestResultObj->id , 'input_id' => $InputChild->id , 'option_id' => $Option->id ] );
|
$InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id, 'input_id' => $InputChild->id, 'option_id' => $Option->id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$InputValueObj = InputValue::create( [ 'test_result_id' => $TestResultObj->id , 'input_id' => $InputChild->id , 'value' => $Value ] );
|
$InputValueObj = InputValue::create(['test_result_id' => $TestResultObj->id, 'input_id' => $InputChild->id, 'value' => $Value]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -155,285 +156,285 @@ class TestResultController extends Controller
|
|||||||
}
|
}
|
||||||
///////////////////////////////////////////////////////////////////////////Inputs
|
///////////////////////////////////////////////////////////////////////////Inputs
|
||||||
|
|
||||||
MediaHelper::moveMediaTo( $TestResultObj );
|
MediaHelper::moveMediaTo($TestResultObj);
|
||||||
|
|
||||||
} );
|
});
|
||||||
} catch ( \Exception $e ) {
|
} catch (\Exception $e) {
|
||||||
return response()->json( $e->getMessage() , 441 );
|
return response()->json($e->getMessage(), 441);
|
||||||
}
|
}
|
||||||
return MessageResponse::success( null , trans( 'messages.create' ) );
|
return MessageResponse::success(null, trans('messages.create'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show( $id )
|
public function show($id)
|
||||||
{
|
{
|
||||||
$TestResult = TestResult::with( 'input_values' , 'user.medical_center' , 'test_type' )
|
$TestResult = TestResult::with('input_values', 'user.medical_center', 'test_type')
|
||||||
->select( 'result' , 'verified' , 'device_id' , 'user_id' , 'id' , 'test_type_id' , 'created_at' )
|
->select('result', 'verified', 'device_id', 'user_id', 'id', 'test_type_id', 'created_at')
|
||||||
->findOrFail( $id );
|
->findOrFail($id);
|
||||||
$options = [];
|
$options = [];
|
||||||
foreach ( $TestResult->input_values as $value ) {
|
foreach ($TestResult->input_values as $value) {
|
||||||
$input = $value->input;
|
$input = $value->input;
|
||||||
|
|
||||||
if ( $input->parent_id != null && $input->parent[ 'type' ] == 'Form' ) {
|
if ($input->parent_id != null && $input->parent['type'] == 'Form') {
|
||||||
//----------------------------------------------------------------------FormType
|
//----------------------------------------------------------------------FormType
|
||||||
if ( $input->type == 'Checkbox' || $input->type == 'Select' || $input[ 'type' ] == 'Radiobutton' ) {
|
if ($input->type == 'Checkbox' || $input->type == 'Select' || $input['type'] == 'Radiobutton') {
|
||||||
$input_options = InputValue::with( 'option' )->where( 'test_result_id' , $TestResult->id )->where( 'input_id' , $input->id )->get();
|
$input_options = InputValue::with('option')->where('test_result_id', $TestResult->id)->where('input_id', $input->id)->get();
|
||||||
$options = [];
|
$options = [];
|
||||||
foreach ( $input_options as $input_option ) {
|
foreach ($input_options as $input_option) {
|
||||||
$options[] = $input_option->option->title;
|
$options[] = $input_option->option->title;
|
||||||
$input_values[ $input->name ] = $options;
|
$input_values[$input->name] = $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
$children[ $input->parent->name ] = $input_values;
|
$children[$input->parent->name] = $input_values;
|
||||||
$TestResult[ 'children' ] = $children;
|
$TestResult['children'] = $children;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$children[ $input->parent->name ][ $input->name ] = $value->value;
|
$children[$input->parent->name][$input->name] = $value->value;
|
||||||
$TestResult[ 'children' ] = $children;
|
$TestResult['children'] = $children;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------FormType
|
//-----------------------------------------------------------------------FormType
|
||||||
} else {
|
} else {
|
||||||
//-----------------------------------------------------------------------Anothertype
|
//-----------------------------------------------------------------------Anothertype
|
||||||
if ( $input->type == 'Checkbox' || $input->type == 'Select' || $input[ 'type' ] == 'Radiobutton' ) {
|
if ($input->type == 'Checkbox' || $input->type == 'Select' || $input['type'] == 'Radiobutton') {
|
||||||
$input_options = InputValue::with( 'option' )->where( 'test_result_id' , $TestResult->id )->where( 'input_id' , $input->id )->get();
|
$input_options = InputValue::with('option')->where('test_result_id', $TestResult->id)->where('input_id', $input->id)->get();
|
||||||
$options = [];
|
$options = [];
|
||||||
foreach ( $input_options as $input_option ) {
|
foreach ($input_options as $input_option) {
|
||||||
$options[] = $input_option->option->title;
|
$options[] = $input_option->option->title;
|
||||||
}
|
}
|
||||||
|
|
||||||
$values[ $input->name ] = $options;
|
$values[$input->name] = $options;
|
||||||
$TestResult[ 'options' ] = $values;
|
$TestResult['options'] = $values;
|
||||||
} else {
|
} else {
|
||||||
$inputs[ $input->name ] = $value->value;
|
$inputs[$input->name] = $value->value;
|
||||||
$TestResult[ 'inputs' ] = $inputs;
|
$TestResult['inputs'] = $inputs;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------Anothertype
|
//-----------------------------------------------------------------------Anothertype
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$TestResult[ 'device_label' ] = $TestResult->test_type->device_label;
|
$TestResult['device_label'] = $TestResult->test_type->device_label;
|
||||||
|
|
||||||
return TestResultResource::make( $TestResult );
|
return TestResultResource::make($TestResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit( TestResult $TestResult )
|
public function edit(TestResult $TestResult)
|
||||||
{
|
{
|
||||||
foreach ( $TestResult->input_values as $key => $value ) {
|
foreach ($TestResult->input_values as $key => $value) {
|
||||||
$input = $value->input;
|
$input = $value->input;
|
||||||
if ( $input->type == 'Checkbox' || $input->type == 'Select' || $input[ 'type' ] == 'Radiobutton' ) {
|
if ($input->type == 'Checkbox' || $input->type == 'Select' || $input['type'] == 'Radiobutton') {
|
||||||
$input_options = InputValue::where( 'test_result_id' , $TestResult->id )->where( 'input_id' , $input->id )->get()->pluck( 'option_id' )->toArray();
|
$input_options = InputValue::where('test_result_id', $TestResult->id)->where('input_id', $input->id)->get()->pluck('option_id')->toArray();
|
||||||
if ( $input[ 'type' ] == 'Radiobutton' ) {
|
if ($input['type'] == 'Radiobutton') {
|
||||||
$TestResult[ $input->name . '_' . $input->id ] = $input_options[ 0 ];
|
$TestResult[$input->name . '_' . $input->id] = $input_options[0];
|
||||||
} else {
|
} else {
|
||||||
$TestResult[ $input->name . '_' . $input->id ] = $input_options;
|
$TestResult[$input->name . '_' . $input->id] = $input_options;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$TestResult[ $input->name . '_' . $input->id ] = $value->value;
|
$TestResult[$input->name . '_' . $input->id] = $value->value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TestResultResource::make( $TestResult );
|
return TestResultResource::make($TestResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function storage_path( $path )
|
public static function storage_path($path)
|
||||||
{
|
{
|
||||||
if ( starts_with( $path , 'media/' ) ) {
|
if (Str::startsWith($path, 'media/')) {
|
||||||
$path = substr( $path , 6 );
|
$path = substr($path, 6);
|
||||||
}
|
}
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update( StoreTestResultRequest $request , TestResult $TestResult )
|
public function update(StoreTestResultRequest $request, TestResult $TestResult)
|
||||||
{
|
{
|
||||||
$TestResultData = [
|
$TestResultData = [
|
||||||
'cycle_number' => $request->cycle_number ,
|
'cycle_number' => $request->cycle_number,
|
||||||
'date' => $request->date ,
|
'date' => $request->date,
|
||||||
'test_type_id' => $request->test_type_id ,
|
'test_type_id' => $request->test_type_id,
|
||||||
'result' => $request->result ,
|
'result' => $request->result,
|
||||||
// 'verified' => 'NotVerified',
|
// 'verified' => 'NotVerified',
|
||||||
];
|
];
|
||||||
$TestResult->update( $TestResultData );
|
$TestResult->update($TestResultData);
|
||||||
$TestResultInfo = $request->all();
|
$TestResultInfo = $request->all();
|
||||||
|
|
||||||
$Inputs = Input::with( 'options' , 'children' , 'children.options' )->whereNull( 'parent_id' )->where( 'test_type_id' , $request->test_type_id )->get();
|
$Inputs = Input::with('options', 'children', 'children.options')->whereNull('parent_id')->where('test_type_id', $request->test_type_id)->get();
|
||||||
|
|
||||||
foreach ( $Inputs as $Input ) {
|
foreach ($Inputs as $Input) {
|
||||||
if ( $Input[ 'type' ] != 'Form' ) {
|
if ($Input['type'] != 'Form') {
|
||||||
$Value = $TestResultInfo[ $Input->name . '_' . $Input->id ];
|
$Value = $TestResultInfo[$Input->name . '_' . $Input->id];
|
||||||
if ( $Input[ 'type' ] == 'Checkbox' || $Input[ 'type' ] == 'Select' || $Input[ 'type' ] == 'Radiobutton' ) {
|
if ($Input['type'] == 'Checkbox' || $Input['type'] == 'Select' || $Input['type'] == 'Radiobutton') {
|
||||||
|
|
||||||
$InputOptions = InputValue::where( 'test_result_id' , $TestResult->id )->where( 'input_id' , $Input->id )->get()->each->delete();
|
$InputOptions = InputValue::where('test_result_id', $TestResult->id)->where('input_id', $Input->id)->get()->each->delete();
|
||||||
|
|
||||||
foreach ( $Input->options as $Option ) {//--2
|
foreach ($Input->options as $Option) {//--2
|
||||||
if ( is_array( $Value ) && in_array( $Option->id , $Value ) ) {
|
if (is_array($Value) && in_array($Option->id, $Value)) {
|
||||||
$InputValueObj = InputValue::create( [ 'test_result_id' => $TestResult->id , 'input_id' => $Input->id , 'option_id' => $Option->id ] );
|
$InputValueObj = InputValue::create(['test_result_id' => $TestResult->id, 'input_id' => $Input->id, 'option_id' => $Option->id]);
|
||||||
}
|
}
|
||||||
if ( $Input[ 'type' ] == 'Radiobutton' && $Option->id == $Value ) {
|
if ($Input['type'] == 'Radiobutton' && $Option->id == $Value) {
|
||||||
$InputValueObj = InputValue::create( [ 'test_result_id' => $TestResult->id , 'input_id' => $Input->id , 'option_id' => $Option->id ] );
|
$InputValueObj = InputValue::create(['test_result_id' => $TestResult->id, 'input_id' => $Input->id, 'option_id' => $Option->id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$InputValueObj = InputValue::where( 'test_result_id' , $TestResult->id )->where( 'input_id' , $Input[ 'id' ] )->update( [ 'value' => $Value ] );
|
$InputValueObj = InputValue::where('test_result_id', $TestResult->id)->where('input_id', $Input['id'])->update(['value' => $Value]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach ( $Input->children as $InputChild ) {
|
foreach ($Input->children as $InputChild) {
|
||||||
|
|
||||||
$Value = $TestResultInfo[ $InputChild->name . '_' . $InputChild->id ];
|
$Value = $TestResultInfo[$InputChild->name . '_' . $InputChild->id];
|
||||||
|
|
||||||
if ( $InputChild[ 'type' ] == 'Checkbox' || $InputChild[ 'type' ] == 'Select' || $InputChild[ 'type' ] == 'Radiobutton' ) {
|
if ($InputChild['type'] == 'Checkbox' || $InputChild['type'] == 'Select' || $InputChild['type'] == 'Radiobutton') {
|
||||||
$InputOptions = InputValue::where( 'test_result_id' , $TestResult->id )->where( 'input_id' , $InputChild->id )->get()->each->delete();
|
$InputOptions = InputValue::where('test_result_id', $TestResult->id)->where('input_id', $InputChild->id)->get()->each->delete();
|
||||||
|
|
||||||
foreach ( $InputChild->options as $Option ) {//--2
|
foreach ($InputChild->options as $Option) {//--2
|
||||||
if ( is_array( $Value ) && in_array( $Option->id , $Value ) ) {
|
if (is_array($Value) && in_array($Option->id, $Value)) {
|
||||||
$InputValueObj = InputValue::create( [ 'test_result_id' => $TestResult->id , 'input_id' => $InputChild->id , 'option_id' => $Option->id ] );
|
$InputValueObj = InputValue::create(['test_result_id' => $TestResult->id, 'input_id' => $InputChild->id, 'option_id' => $Option->id]);
|
||||||
}
|
}
|
||||||
if ( $InputChild[ 'type' ] == 'Radiobutton' && $Option->id == $Value ) {
|
if ($InputChild['type'] == 'Radiobutton' && $Option->id == $Value) {
|
||||||
$InputValueObj = InputValue::create( [ 'test_result_id' => $TestResult->id , 'input_id' => $InputChild->id , 'option_id' => $Option->id ] );
|
$InputValueObj = InputValue::create(['test_result_id' => $TestResult->id, 'input_id' => $InputChild->id, 'option_id' => $Option->id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$InputValueObj = InputValue::where( 'test_result_id' , $TestResult->id )->where( 'input_id' , $InputChild[ 'id' ] )->update( [ 'value' => $Value ] );
|
$InputValueObj = InputValue::where('test_result_id', $TestResult->id)->where('input_id', $InputChild['id'])->update(['value' => $Value]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/////////////////////////////////////////////////////////////////////Images
|
/////////////////////////////////////////////////////////////////////Images
|
||||||
|
|
||||||
return MessageResponse::success( null , trans( 'messages.update' ) );
|
return MessageResponse::success(null, trans('messages.update'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function destroy( TestResult $TestResult )
|
public function destroy(TestResult $TestResult)
|
||||||
{
|
{
|
||||||
if ( ! auth( 'api' )->user()->can( 'delete' , $TestResult ) ) {
|
if (!auth('api')->user()->can('delete', $TestResult)) {
|
||||||
return MessageResponse::error( trans( 'messages.access_denied' ) );
|
return MessageResponse::error(trans('messages.access_denied'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( count( $TestResult->input_values ) ) {
|
if (count($TestResult->input_values)) {
|
||||||
InputValue::where( 'test_result_id' , $TestResult->id )->get()->each->delete();
|
InputValue::where('test_result_id', $TestResult->id)->get()->each->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
$TestResult->delete();
|
$TestResult->delete();
|
||||||
|
|
||||||
return MessageResponse::success( null , trans( 'messages.success' ) );
|
return MessageResponse::success(null, trans('messages.success'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function verifyTestResult( TestResult $TestResult , $Value )
|
public function verifyTestResult(TestResult $TestResult, $Value)
|
||||||
{
|
{
|
||||||
if ( auth( 'api' )->user()->cant( 'verifyTestResult' , $TestResult ) ) {
|
if (auth('api')->user()->cant('verifyTestResult', $TestResult)) {
|
||||||
return MessageResponse::error( trans( 'You dont have permission or this test result belongs to another medical center' ) );
|
return MessageResponse::error(trans('You dont have permission or this test result belongs to another medical center'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$TestResult->verified = $Value;
|
$TestResult->verified = $Value;
|
||||||
$TestResult->save();
|
$TestResult->save();
|
||||||
$TestResult = $TestResult->load( 'user.medical_center' );
|
$TestResult = $TestResult->load('user.medical_center');
|
||||||
return MessageResponse::success( trans( 'messages.success' ) , null , $TestResult );
|
return MessageResponse::success(trans('messages.success'), null, $TestResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listFilterItems()
|
public function listFilterItems()
|
||||||
{
|
{
|
||||||
$user = auth( 'api' )->user();
|
$user = auth('api')->user();
|
||||||
$MedicalCenter = MedicalCenter::when( ! $user->hasRole( 'Admin' ) , function ( $query ) use ( $user ) {
|
$MedicalCenter = MedicalCenter::when(!$user->hasRole('Admin'), function ($query) use ($user) {
|
||||||
$query->where( 'id' , $user->medical_center_id );
|
$query->where('id', $user->medical_center_id);
|
||||||
} )->select( 'name' , 'id' )->get()->toArray();
|
})->select('name', 'id')->get()->toArray();
|
||||||
|
|
||||||
$TestType = TestType::select( 'name' , 'id' )->get()->toArray();
|
$TestType = TestType::select('name', 'id')->get()->toArray();
|
||||||
return MessageResponse::data( [
|
return MessageResponse::data([
|
||||||
'MedicalCenters' => $MedicalCenter ,
|
'MedicalCenters' => $MedicalCenter,
|
||||||
'TestTypes' => $TestType
|
'TestTypes' => $TestType
|
||||||
] );
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function chart( Request $request )
|
public function chart(Request $request)
|
||||||
{
|
{
|
||||||
$user = auth( 'api' )->user();
|
$user = auth('api')->user();
|
||||||
if ( $user->hasRole( 'User' ) ) {
|
if ($user->hasRole('User')) {
|
||||||
$userId = $user->id;
|
$userId = $user->id;
|
||||||
} elseif ( $request->has( 'userId' ) && $request->userId ) {
|
} elseif ($request->has('userId') && $request->userId) {
|
||||||
$userId = $request->userId;
|
$userId = $request->userId;
|
||||||
} else {
|
} else {
|
||||||
$userId = null;
|
$userId = null;
|
||||||
}
|
}
|
||||||
if ( $user->hasRole( 'Admin' ) && $request->has( 'medicalCenterId' ) && $request->medicalCenterId ) {
|
if ($user->hasRole('Admin') && $request->has('medicalCenterId') && $request->medicalCenterId) {
|
||||||
$medicalCenterId = $request->medicalCenterId;
|
$medicalCenterId = $request->medicalCenterId;
|
||||||
} else {
|
} else {
|
||||||
$medicalCenterId = $user->medical_center_id;
|
$medicalCenterId = $user->medical_center_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$TestResults = TestResult::when( $userId , function ( $query ) use ( $userId ) {
|
$TestResults = TestResult::when($userId, function ($query) use ($userId) {
|
||||||
$query->where( 'user_id' , $userId );
|
$query->where('user_id', $userId);
|
||||||
} )
|
})
|
||||||
->when( $medicalCenterId , function ( $query ) use ( $medicalCenterId ) {
|
->when($medicalCenterId, function ($query) use ($medicalCenterId) {
|
||||||
$query->whereHas( 'user' , function ( $query ) use ( $medicalCenterId ) {
|
$query->whereHas('user', function ($query) use ($medicalCenterId) {
|
||||||
$query->where( 'medical_center_id' , $medicalCenterId );
|
$query->where('medical_center_id', $medicalCenterId);
|
||||||
} );
|
});
|
||||||
} )
|
})
|
||||||
->when( $request->has( 'testTypeId' ) && $request->testTypeId , function ( $query ) use ( $request ) {
|
->when($request->has('testTypeId') && $request->testTypeId, function ($query) use ($request) {
|
||||||
$query->where( 'test_type_id' , $request->testTypeId );
|
$query->where('test_type_id', $request->testTypeId);
|
||||||
} )
|
})
|
||||||
->when( $request->has( 'result' ) && $request->result , function ( $query ) use ( $request ) {
|
->when($request->has('result') && $request->result, function ($query) use ($request) {
|
||||||
$query->where( 'result' , $request->result );
|
$query->where('result', $request->result);
|
||||||
} )
|
})
|
||||||
->when( ( $request->has( 'fromPicker' ) && $request->fromPicker ) || ( $request->has( 'upToPicker' ) && $request->upToPicker ) , function ( $query ) use ( $request ) {
|
->when(($request->has('fromPicker') && $request->fromPicker) || ($request->has('upToPicker') && $request->upToPicker), function ($query) use ($request) {
|
||||||
$from = ( $request->fromPicker ) ? date( $request->fromPicker . ' 00:00:00' ) : date( '2010-01-01' . ' 00:00:00' );
|
$from = ($request->fromPicker) ? date($request->fromPicker . ' 00:00:00') : date('2010-01-01' . ' 00:00:00');
|
||||||
$upTo = ( $request->upToPicker ) ? date( $request->upToPicker . ' 23:59:59' ) : date( 'Y-m-d' . ' 23:59:59' );
|
$upTo = ($request->upToPicker) ? date($request->upToPicker . ' 23:59:59') : date('Y-m-d' . ' 23:59:59');
|
||||||
return $query->whereBetween( 'created_at' , [ $from , $upTo ] );
|
return $query->whereBetween('created_at', [$from, $upTo]);
|
||||||
} )
|
})
|
||||||
->when( $request->has( 'verify' ) && $request->verify , function ( $query ) use ( $request ) {
|
->when($request->has('verify') && $request->verify, function ($query) use ($request) {
|
||||||
$query->where( 'verified' , $request->verify );
|
$query->where('verified', $request->verify);
|
||||||
} )->select( 'result' )->get()->groupBy( 'result' );
|
})->select('result')->get()->groupBy('result');
|
||||||
$AcceptCount = ( isset( $TestResults[ 'Accept' ] ) ) ? $TestResults[ 'Accept' ]->count() : 0;
|
$AcceptCount = (isset($TestResults['Accept'])) ? $TestResults['Accept']->count() : 0;
|
||||||
$RejectCount = ( isset( $TestResults[ 'Reject' ] ) ) ? $TestResults[ 'Reject' ]->count() : 0;
|
$RejectCount = (isset($TestResults['Reject'])) ? $TestResults['Reject']->count() : 0;
|
||||||
|
|
||||||
|
|
||||||
return MessageResponse::data( [ 'labels' => [ 'Number Of Accepted Test Results' , 'Number Of Rejected Test Results' ] , 'data' => [ $AcceptCount , $RejectCount ] ] );
|
return MessageResponse::data(['labels' => ['Number Of Accepted Test Results', 'Number Of Rejected Test Results'], 'data' => [$AcceptCount, $RejectCount]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showTestResult( $id )
|
public function showTestResult($id)
|
||||||
{
|
{
|
||||||
$TestResult = TestResult::with( 'input_values' , 'user.medical_center' , 'test_type' )->select( 'result' , 'verified' , 'device_id' , 'user_id' , 'id' , 'test_type_id' , 'created_at' )->findOrFail( $id );
|
$TestResult = TestResult::with('input_values', 'user.medical_center', 'test_type')->select('result', 'verified', 'device_id', 'user_id', 'id', 'test_type_id', 'created_at')->findOrFail($id);
|
||||||
$options = [];
|
$options = [];
|
||||||
foreach ( $TestResult->input_values as $value ) {
|
foreach ($TestResult->input_values as $value) {
|
||||||
$input = $value->input;
|
$input = $value->input;
|
||||||
|
|
||||||
if ( $input->parent_id != null && $input->parent[ 'type' ] == 'Form' ) {
|
if ($input->parent_id != null && $input->parent['type'] == 'Form') {
|
||||||
//----------------------------------------------------------------------FormType
|
//----------------------------------------------------------------------FormType
|
||||||
if ( $input->type == 'Checkbox' || $input->type == 'Select' || $input[ 'type' ] == 'Radiobutton' ) {
|
if ($input->type == 'Checkbox' || $input->type == 'Select' || $input['type'] == 'Radiobutton') {
|
||||||
$input_options = InputValue::with( 'option' )->where( 'test_result_id' , $TestResult->id )->where( 'input_id' , $input->id )->get();
|
$input_options = InputValue::with('option')->where('test_result_id', $TestResult->id)->where('input_id', $input->id)->get();
|
||||||
$options = [];
|
$options = [];
|
||||||
foreach ( $input_options as $input_option ) {
|
foreach ($input_options as $input_option) {
|
||||||
$options[] = $input_option->option->title;
|
$options[] = $input_option->option->title;
|
||||||
$input_values[ $input->name ] = $options;
|
$input_values[$input->name] = $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
$children[ $input->parent->name ] = $input_values;
|
$children[$input->parent->name] = $input_values;
|
||||||
$TestResult[ 'children' ] = $children;
|
$TestResult['children'] = $children;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$children[ $input->parent->name ][ $input->name ] = $value->value;
|
$children[$input->parent->name][$input->name] = $value->value;
|
||||||
$TestResult[ 'children' ] = $children;
|
$TestResult['children'] = $children;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------FormType
|
//-----------------------------------------------------------------------FormType
|
||||||
} else {
|
} else {
|
||||||
//-----------------------------------------------------------------------Anothertype
|
//-----------------------------------------------------------------------Anothertype
|
||||||
if ( $input->type == 'Checkbox' || $input->type == 'Select' || $input[ 'type' ] == 'Radiobutton' ) {
|
if ($input->type == 'Checkbox' || $input->type == 'Select' || $input['type'] == 'Radiobutton') {
|
||||||
$input_options = InputValue::with( 'option' )->where( 'test_result_id' , $TestResult->id )->where( 'input_id' , $input->id )->get();
|
$input_options = InputValue::with('option')->where('test_result_id', $TestResult->id)->where('input_id', $input->id)->get();
|
||||||
$options = [];
|
$options = [];
|
||||||
foreach ( $input_options as $input_option ) {
|
foreach ($input_options as $input_option) {
|
||||||
$options[] = $input_option->option->title;
|
$options[] = $input_option->option->title;
|
||||||
}
|
}
|
||||||
|
|
||||||
$values[ $input->name ] = $options;
|
$values[$input->name] = $options;
|
||||||
$TestResult[ 'options' ] = $values;
|
$TestResult['options'] = $values;
|
||||||
} else {
|
} else {
|
||||||
$inputs[ $input->name ] = $value->value;
|
$inputs[$input->name] = $value->value;
|
||||||
$TestResult[ 'inputs' ] = $inputs;
|
$TestResult['inputs'] = $inputs;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------Anothertype
|
//-----------------------------------------------------------------------Anothertype
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$TestResult[ 'device_label' ] = $TestResult->test_type->device_label;
|
$TestResult['device_label'] = $TestResult->test_type->device_label;
|
||||||
return MessageResponse::data( $TestResult );
|
return MessageResponse::data($TestResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,67 +2,63 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use App\Http\Requests\StoreTestTypeRequest;
|
||||||
use App\TestType;
|
|
||||||
use App\TestResult;
|
|
||||||
use App\Input;
|
use App\Input;
|
||||||
use App\Option;
|
use App\Option;
|
||||||
use App\Http\Requests\StoreTestTypeRequest;
|
use App\TestResult;
|
||||||
use \Milon\Barcode\DNS1D;
|
use App\TestType;
|
||||||
use \Milon\Barcode\DNS2D;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Milon\Barcode\Facades\DNS1DFacade;
|
||||||
|
use Milon\Barcode\Facades\DNS2DFacade;
|
||||||
|
use Packages\Messaging\src\Facades\MessageResponse;
|
||||||
|
|
||||||
|
|
||||||
use App\InputValue;
|
|
||||||
use App\Gallery;
|
|
||||||
use App\Uploadable;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
|
|
||||||
class TestTypeController extends Controller
|
class TestTypeController extends Controller
|
||||||
{
|
{
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
if (!auth('api')->user()->can('list', TestType::class)) {
|
if (!auth('api')->user()->can('list', TestType::class)) {
|
||||||
return \MessageResponse::error(trans('messages.access_denied'));
|
return MessageResponse::error(trans('messages.access_denied'));
|
||||||
}
|
}
|
||||||
$TestTypes = TestType::when($request->has('name') && $request->name, function($query) use($request){
|
$TestTypes = TestType::when($request->has('name') && $request->name, function ($query) use ($request) {
|
||||||
$query->where('name', 'LIKE', '%'.$request->name.'%');
|
$query->where('name', 'LIKE', '%' . $request->name . '%');
|
||||||
})
|
})
|
||||||
->when(($request->has('fromPicker') && $request->fromPicker) || ($request->has('upToPicker') && $request->upToPicker), function ($query) use ($request)
|
->when(($request->has('fromPicker') && $request->fromPicker) || ($request->has('upToPicker') && $request->upToPicker), function ($query) use ($request) {
|
||||||
{
|
$from = ($request->fromPicker) ? date($request->fromPicker . ' 00:00:00') : date('2010-01-01' . ' 00:00:00');
|
||||||
$from = ($request->fromPicker) ? date($request->fromPicker . ' 00:00:00') : date('2010-01-01' . ' 00:00:00');
|
$upTo = ($request->upToPicker) ? date($request->upToPicker . ' 23:59:59') : date('Y-m-d' . ' 23:59:59');
|
||||||
$upTo = ($request->upToPicker) ? date($request->upToPicker . ' 23:59:59') : date('Y-m-d' . ' 23:59:59');
|
return $query->whereBetween('created_at', [$from, $upTo]);
|
||||||
return $query->whereBetween('created_at', [$from, $upTo]);
|
})
|
||||||
})
|
->when($request->has('unique_id') && $request->unique_id, function ($query) use ($request) {
|
||||||
->when($request->has('unique_id') && $request->unique_id, function($query) use($request){
|
$query->where('unique_code', $request->unique_id);
|
||||||
$query->where('unique_code', $request->unique_id);
|
})
|
||||||
})
|
->when($request->has('user_name') && $request->user_name, function ($query) use ($request) {
|
||||||
->when($request->has('user_name') && $request->user_name, function($query) use($request){
|
$query->whereHas('user', function ($query) use ($request) {
|
||||||
$query->whereHas('user', function($query) use($request){
|
$query->where('name', 'LIKE', '%' . $request->user_name . '%');
|
||||||
$query->where('name', 'LIKE', '%'.$request->user_name.'%');
|
});
|
||||||
});
|
})
|
||||||
})
|
->withCount('test_results')
|
||||||
->withCount('test_results')
|
->with(['user' => function ($query) {
|
||||||
->with(['user' => function($query){
|
$query->select('id', 'name', 'medical_center_id');
|
||||||
$query->select('id', 'name', 'medical_center_id');
|
},
|
||||||
},
|
'user.medical_center' => function ($query) {
|
||||||
'user.medical_center' => function($query){
|
$query->select('id', 'name');
|
||||||
$query->select('id', 'name');
|
}])->orderByDesc('id')->paginate(10);
|
||||||
}])->orderByDesc('id')->paginate(10);
|
|
||||||
|
|
||||||
return \MessageResponse::data($TestTypes);
|
return MessageResponse::data($TestTypes);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateBarcode(TestType $TestType)
|
public function generateBarcode(TestType $TestType)
|
||||||
{
|
{
|
||||||
if (!auth('api')->user()->can('generateBarcode', $TestType)) {
|
if (!auth('api')->user()->can('generateBarcode', $TestType)) {
|
||||||
return \MessageResponse::error(trans('messages.access_denied'));
|
return MessageResponse::error(trans('messages.access_denied'));
|
||||||
}
|
}
|
||||||
$Number = $TestType->unique_code;
|
$Number = $TestType->unique_code;
|
||||||
$Barcode = DNS1D::getBarcodePNGUri($Number, "C128");
|
$Barcode = DNS1DFacade::getBarcodePNGUri($Number, "C128");
|
||||||
$QRCode = DNS2D::getBarcodePNGUri($Number, "QRCODE");
|
$QRCode = DNS2DFacade::getBarcodePNGUri($Number, "QRCODE");
|
||||||
$TestType->update(['bar_code' => $Barcode]);
|
$TestType->update(['bar_code' => $Barcode]);
|
||||||
return \MessageResponse::data(['Barcode' => $Barcode, 'QRCode' => $QRCode]);
|
return MessageResponse::data(['Barcode' => $Barcode, 'QRCode' => $QRCode]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create()
|
public function create()
|
||||||
@@ -76,7 +72,7 @@ class TestTypeController extends Controller
|
|||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public function CreateInput($Input,$TestType,$ParentID = null)
|
public function CreateInput($Input, $TestType, $ParentID = null)
|
||||||
{
|
{
|
||||||
//---------------------------------------------Input
|
//---------------------------------------------Input
|
||||||
$InputData = [
|
$InputData = [
|
||||||
@@ -94,20 +90,20 @@ class TestTypeController extends Controller
|
|||||||
//---------------------------------------------Option
|
//---------------------------------------------Option
|
||||||
if ($Input['type'] == 'Checkbox' || $Input['type'] == 'Select' || $Input['type'] == 'Radiobutton' || $Input['type'] == 'Range') {
|
if ($Input['type'] == 'Checkbox' || $Input['type'] == 'Select' || $Input['type'] == 'Radiobutton' || $Input['type'] == 'Range') {
|
||||||
foreach ($Input['options'] as $Option) {
|
foreach ($Input['options'] as $Option) {
|
||||||
$Option = Option::create(['title' => $Option['title'] , 'input_id' => $InputObj->id]);
|
$Option = Option::create(['title' => $Option['title'], 'input_id' => $InputObj->id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//---------------------------------------------Option
|
//---------------------------------------------Option
|
||||||
return $InputObj;
|
return $InputObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function CreateChildForm($Input,$TestType,$InputObj)
|
public function CreateChildForm($Input, $TestType, $InputObj)
|
||||||
{
|
{
|
||||||
if (isset($Input['children'])) {
|
if (isset($Input['children'])) {
|
||||||
foreach ($Input['children'] as $InputChild) {
|
foreach ($Input['children'] as $InputChild) {
|
||||||
$InputChildObj = $this->CreateInput($InputChild,$TestType,$InputObj->id);
|
$InputChildObj = $this->CreateInput($InputChild, $TestType, $InputObj->id);
|
||||||
if (isset($InputChild['children'])) {
|
if (isset($InputChild['children'])) {
|
||||||
$this->CreateChildForm($InputChild,$TestType,$InputChildObj);
|
$this->CreateChildForm($InputChild, $TestType, $InputChildObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +112,7 @@ class TestTypeController extends Controller
|
|||||||
public function store(StoreTestTypeRequest $request)
|
public function store(StoreTestTypeRequest $request)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$return_value = \DB::transaction(function () use ($request) {
|
$return_value = DB::transaction(function () use ($request) {
|
||||||
|
|
||||||
$TestType = [
|
$TestType = [
|
||||||
'name' => $request['name'],
|
'name' => $request['name'],
|
||||||
@@ -130,17 +126,17 @@ class TestTypeController extends Controller
|
|||||||
|
|
||||||
foreach ($TestTypeInfo as $Input) {
|
foreach ($TestTypeInfo as $Input) {
|
||||||
|
|
||||||
$InputObj = $this->CreateInput($Input,$TestType);
|
$InputObj = $this->CreateInput($Input, $TestType);
|
||||||
|
|
||||||
if ($Input['type'] == 'Form') {
|
if ($Input['type'] == 'Form') {
|
||||||
$this->CreateChildForm($Input,$TestType,$InputObj);
|
$this->CreateChildForm($Input, $TestType, $InputObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return response()->json($e->getMessage(), 441);
|
return response()->json($e->getMessage(), 441);
|
||||||
}
|
}
|
||||||
return \MessageResponse::success(null,trans('messages.create'));
|
return MessageResponse::success(null, trans('messages.create'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($id)
|
public function show($id)
|
||||||
@@ -162,8 +158,8 @@ class TestTypeController extends Controller
|
|||||||
'id' => $Input->id,
|
'id' => $Input->id,
|
||||||
'name' => $Input->name,
|
'name' => $Input->name,
|
||||||
'type' => $Input->type,
|
'type' => $Input->type,
|
||||||
'size' => $Input->size ,
|
'size' => $Input->size,
|
||||||
'require_scanner' => $Input->require_scanner ,
|
'require_scanner' => $Input->require_scanner,
|
||||||
'parent_id' => $Input->parent_id,
|
'parent_id' => $Input->parent_id,
|
||||||
'options' => [],
|
'options' => [],
|
||||||
'children' => []
|
'children' => []
|
||||||
@@ -174,7 +170,7 @@ class TestTypeController extends Controller
|
|||||||
|
|
||||||
foreach ($Input['options'] as $Option) {
|
foreach ($Input['options'] as $Option) {
|
||||||
$OptionInfo = [
|
$OptionInfo = [
|
||||||
'id' => $Option->id ,
|
'id' => $Option->id,
|
||||||
'title' => $Option->title
|
'title' => $Option->title
|
||||||
];
|
];
|
||||||
$Options[] = $OptionInfo;
|
$Options[] = $OptionInfo;
|
||||||
@@ -185,7 +181,7 @@ class TestTypeController extends Controller
|
|||||||
return $InputInfo;
|
return $InputInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function CreateChildFormInfo($Input,$InputInfo)
|
public function CreateChildFormInfo($Input, $InputInfo)
|
||||||
{
|
{
|
||||||
$Children = [];
|
$Children = [];
|
||||||
foreach ($Input['children'] as $InputChild) {
|
foreach ($Input['children'] as $InputChild) {
|
||||||
@@ -193,7 +189,7 @@ class TestTypeController extends Controller
|
|||||||
$ChildInfo = $this->CreateInputInfo($InputChild);
|
$ChildInfo = $this->CreateInputInfo($InputChild);
|
||||||
$Children[] = $ChildInfo;
|
$Children[] = $ChildInfo;
|
||||||
if ($InputChild['type'] == 'Form') {
|
if ($InputChild['type'] == 'Form') {
|
||||||
$this->CreateChildFormInfo($InputChild,$ChildInfo);
|
$this->CreateChildFormInfo($InputChild, $ChildInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $Children;
|
return $Children;
|
||||||
@@ -202,9 +198,9 @@ class TestTypeController extends Controller
|
|||||||
public function edit(TestType $TestType)
|
public function edit(TestType $TestType)
|
||||||
{
|
{
|
||||||
if (count($TestType->test_results) > 0) {
|
if (count($TestType->test_results) > 0) {
|
||||||
return \MessageResponse::error(trans('messages.access_denied'));
|
return MessageResponse::error(trans('messages.access_denied'));
|
||||||
}
|
}
|
||||||
$Inputs = Input::with('children','options','children.options')->where('test_type_id',$TestType->id)->where('parent_id',null)->get();
|
$Inputs = Input::with('children', 'options', 'children.options')->where('test_type_id', $TestType->id)->where('parent_id', null)->get();
|
||||||
|
|
||||||
$Info = [];
|
$Info = [];
|
||||||
$Options = [];
|
$Options = [];
|
||||||
@@ -215,7 +211,7 @@ class TestTypeController extends Controller
|
|||||||
$InputInfo = $this->CreateInputInfo($Input);
|
$InputInfo = $this->CreateInputInfo($Input);
|
||||||
|
|
||||||
if ($Input['type'] == 'Form') {
|
if ($Input['type'] == 'Form') {
|
||||||
$Children = $this->CreateChildFormInfo($Input,$InputInfo);
|
$Children = $this->CreateChildFormInfo($Input, $InputInfo);
|
||||||
$InputInfo['children'] = $Children;
|
$InputInfo['children'] = $Children;
|
||||||
}
|
}
|
||||||
$Info[] = $InputInfo;
|
$Info[] = $InputInfo;
|
||||||
@@ -227,7 +223,7 @@ class TestTypeController extends Controller
|
|||||||
'device_label' => $TestType->device_label,
|
'device_label' => $TestType->device_label,
|
||||||
'info' => $Info,
|
'info' => $Info,
|
||||||
];
|
];
|
||||||
return \MessageResponse::data($TestTypeInfo);
|
return MessageResponse::data($TestTypeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -236,7 +232,7 @@ class TestTypeController extends Controller
|
|||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
public function UpdateInput($Input,$TestType,$ParentID = null)
|
public function UpdateInput($Input, $TestType, $ParentID = null)
|
||||||
{
|
{
|
||||||
//---------------------------------------------Input
|
//---------------------------------------------Input
|
||||||
$InputData = [
|
$InputData = [
|
||||||
@@ -249,7 +245,7 @@ class TestTypeController extends Controller
|
|||||||
if ($Input['type'] == 'Text') {
|
if ($Input['type'] == 'Text') {
|
||||||
$InputData['require_scanner'] = $Input['require_scanner'];
|
$InputData['require_scanner'] = $Input['require_scanner'];
|
||||||
}
|
}
|
||||||
Input::where('id',$Input['id'])->update($InputData);
|
Input::where('id', $Input['id'])->update($InputData);
|
||||||
$InputObj = Input::findOrFail($Input['id']);
|
$InputObj = Input::findOrFail($Input['id']);
|
||||||
//---------------------------------------------Input
|
//---------------------------------------------Input
|
||||||
//---------------------------------------------Option
|
//---------------------------------------------Option
|
||||||
@@ -262,24 +258,23 @@ class TestTypeController extends Controller
|
|||||||
|
|
||||||
foreach ($Input['options'] as $Option) {
|
foreach ($Input['options'] as $Option) {
|
||||||
if ($Option['id'] == 0) {//--new
|
if ($Option['id'] == 0) {//--new
|
||||||
$Option = Option::create(['title' => $Option['title'] , 'input_id' => $Input['id'] ]);
|
$Option = Option::create(['title' => $Option['title'], 'input_id' => $Input['id']]);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
//**************************
|
//**************************
|
||||||
if(in_array($Option['id'],$DeletedOptionIDs)){
|
if (in_array($Option['id'], $DeletedOptionIDs)) {
|
||||||
foreach ($DeletedOptionIDs as $index=>$DeletedOptionID){
|
foreach ($DeletedOptionIDs as $index => $DeletedOptionID) {
|
||||||
if($DeletedOptionID == $Option['id']){
|
if ($DeletedOptionID == $Option['id']) {
|
||||||
unset($DeletedOptionIDs[$index]);
|
unset($DeletedOptionIDs[$index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//****************************
|
//****************************
|
||||||
$Option = Option::where('id', $Option['id'])->update(['title' => $Option['title'] ]);
|
$Option = Option::where('id', $Option['id'])->update(['title' => $Option['title']]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//**************************
|
//**************************
|
||||||
foreach ($DeletedOptionIDs as $DeletedOptionID){
|
foreach ($DeletedOptionIDs as $DeletedOptionID) {
|
||||||
$DeletedOption = Option::findOrFail($DeletedOptionID);
|
$DeletedOption = Option::findOrFail($DeletedOptionID);
|
||||||
$DeletedOption->delete();
|
$DeletedOption->delete();
|
||||||
}
|
}
|
||||||
@@ -289,7 +284,7 @@ class TestTypeController extends Controller
|
|||||||
return $Input;
|
return $Input;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function UpdateChildForm($Input,$TestType,$InputObj)
|
public function UpdateChildForm($Input, $TestType, $InputObj)
|
||||||
{
|
{
|
||||||
//**********************************
|
//**********************************
|
||||||
$InputObject = Input::findOrFail($InputObj['id']);//$InputObj['id'] OR $Input['id']???????
|
$InputObject = Input::findOrFail($InputObj['id']);//$InputObj['id'] OR $Input['id']???????
|
||||||
@@ -300,30 +295,29 @@ class TestTypeController extends Controller
|
|||||||
foreach ($Input['children'] as $InputChild) {
|
foreach ($Input['children'] as $InputChild) {
|
||||||
if ($InputChild['id'] == 0) {//--newChild
|
if ($InputChild['id'] == 0) {//--newChild
|
||||||
|
|
||||||
$InputChildObj = $this->CreateInput($InputChild,$TestType,$InputObj['id']);
|
$InputChildObj = $this->CreateInput($InputChild, $TestType, $InputObj['id']);
|
||||||
if (isset($InputChild['children'])) {
|
if (isset($InputChild['children'])) {
|
||||||
$this->CreateChildForm($InputChild,$TestType,$InputChildObj);
|
$this->CreateChildForm($InputChild, $TestType, $InputChildObj);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
//******************************
|
//******************************
|
||||||
if(in_array($InputChild['id'],$DeletedChildIDs)){
|
if (in_array($InputChild['id'], $DeletedChildIDs)) {
|
||||||
foreach ($DeletedChildIDs as $index=>$DeletedChildID){
|
foreach ($DeletedChildIDs as $index => $DeletedChildID) {
|
||||||
if($DeletedChildID == $InputChild['id']){
|
if ($DeletedChildID == $InputChild['id']) {
|
||||||
unset($DeletedChildIDs[$index]);
|
unset($DeletedChildIDs[$index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//******************************
|
//******************************
|
||||||
$InputChildObj = $this->UpdateInput($InputChild,$TestType,$InputObj['id']);
|
$InputChildObj = $this->UpdateInput($InputChild, $TestType, $InputObj['id']);
|
||||||
if (isset($InputChild['children'])) {
|
if (isset($InputChild['children'])) {
|
||||||
$this->UpdateChildForm($InputChild,$TestType,$InputChildObj);
|
$this->UpdateChildForm($InputChild, $TestType, $InputChildObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//*****************************
|
//*****************************
|
||||||
foreach ($DeletedChildIDs as $DeletedChildID){
|
foreach ($DeletedChildIDs as $DeletedChildID) {
|
||||||
$DeletedChild = Input::findOrFail($DeletedChildID);
|
$DeletedChild = Input::findOrFail($DeletedChildID);
|
||||||
$DeletedChild->options()->delete();
|
$DeletedChild->options()->delete();
|
||||||
foreach ($DeletedChild->children as $DeletedChild1) {
|
foreach ($DeletedChild->children as $DeletedChild1) {
|
||||||
@@ -346,31 +340,30 @@ class TestTypeController extends Controller
|
|||||||
];
|
];
|
||||||
$TestType->update($TestTypeData);
|
$TestType->update($TestTypeData);
|
||||||
$TestTypeInfo = $request['info'];
|
$TestTypeInfo = $request['info'];
|
||||||
$DeletedInputIDs = $TestType->inputs->where('parent_id',null)->pluck('id')->toArray();
|
$DeletedInputIDs = $TestType->inputs->where('parent_id', null)->pluck('id')->toArray();
|
||||||
|
|
||||||
foreach ($TestTypeInfo as $Input) {
|
foreach ($TestTypeInfo as $Input) {
|
||||||
if ($Input['id'] == 0) {//--new
|
if ($Input['id'] == 0) {//--new
|
||||||
$InputObj = $this->CreateInput($Input,$TestType);
|
$InputObj = $this->CreateInput($Input, $TestType);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
//**************************
|
//**************************
|
||||||
if(in_array($Input['id'],$DeletedInputIDs)){
|
if (in_array($Input['id'], $DeletedInputIDs)) {
|
||||||
foreach ($DeletedInputIDs as $index=>$DeletedInputID){
|
foreach ($DeletedInputIDs as $index => $DeletedInputID) {
|
||||||
if($DeletedInputID == $Input['id']){
|
if ($DeletedInputID == $Input['id']) {
|
||||||
unset($DeletedInputIDs[$index]);
|
unset($DeletedInputIDs[$index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//****************************
|
//****************************
|
||||||
$InputObj = $this->UpdateInput($Input,$TestType);
|
$InputObj = $this->UpdateInput($Input, $TestType);
|
||||||
}
|
}
|
||||||
if ($Input['type'] == 'Form') {
|
if ($Input['type'] == 'Form') {
|
||||||
$this->UpdateChildForm($Input,$TestType,$InputObj);
|
$this->UpdateChildForm($Input, $TestType, $InputObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//******************************
|
//******************************
|
||||||
foreach ($DeletedInputIDs as $DeletedInputID){
|
foreach ($DeletedInputIDs as $DeletedInputID) {
|
||||||
$DeletedInput = Input::findOrFail($DeletedInputID);
|
$DeletedInput = Input::findOrFail($DeletedInputID);
|
||||||
$DeletedInput->options()->delete();
|
$DeletedInput->options()->delete();
|
||||||
foreach ($DeletedInput->children as $DeletedInput1) {
|
foreach ($DeletedInput->children as $DeletedInput1) {
|
||||||
@@ -382,7 +375,7 @@ class TestTypeController extends Controller
|
|||||||
}
|
}
|
||||||
//******************************
|
//******************************
|
||||||
|
|
||||||
return \MessageResponse::success(null,trans('messages.update'));
|
return MessageResponse::success(null, trans('messages.update'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -390,9 +383,9 @@ class TestTypeController extends Controller
|
|||||||
public function getInputs(Request $request)
|
public function getInputs(Request $request)
|
||||||
{
|
{
|
||||||
if (auth('api')->user()->can('getInputs')) {
|
if (auth('api')->user()->can('getInputs')) {
|
||||||
return \MessageResponse::error(trans('messages.failed'));
|
return MessageResponse::error(trans('messages.failed'));
|
||||||
}
|
}
|
||||||
if($request->test_result_id !== '') {
|
if ($request->test_result_id !== '') {
|
||||||
$testTypeId = TestResult::find($request->test_result_id);
|
$testTypeId = TestResult::find($request->test_result_id);
|
||||||
}
|
}
|
||||||
if (isset($testTypeId) && $testTypeId) {
|
if (isset($testTypeId) && $testTypeId) {
|
||||||
@@ -403,38 +396,38 @@ class TestTypeController extends Controller
|
|||||||
if (isset($testType) && $testType) {
|
if (isset($testType) && $testType) {
|
||||||
|
|
||||||
$inputs = Input::select('id', 'name', 'type', 'size', 'parent_id', 'require_scanner')->with(
|
$inputs = Input::select('id', 'name', 'type', 'size', 'parent_id', 'require_scanner')->with(
|
||||||
['options' => function ($query) {
|
['options' => function ($query) {
|
||||||
$query->select('id', 'title','input_id');
|
$query->select('id', 'title', 'input_id');
|
||||||
},
|
},
|
||||||
'children' => function ($query) {
|
'children' => function ($query) {
|
||||||
$query->select('id', 'name', 'type', 'size', 'parent_id', 'test_type_id', 'require_scanner');
|
$query->select('id', 'name', 'type', 'size', 'parent_id', 'test_type_id', 'require_scanner');
|
||||||
},
|
},
|
||||||
'children.options' => function ($query) {
|
'children.options' => function ($query) {
|
||||||
$query->select('id', 'title', 'input_id');
|
$query->select('id', 'title', 'input_id');
|
||||||
}]
|
}]
|
||||||
)->whereNull('parent_id')->where('test_type_id',$testType->id)->get();
|
)->whereNull('parent_id')->where('test_type_id', $testType->id)->get();
|
||||||
|
|
||||||
return \MessageResponse::data(['testType' => $testType, 'inputs' => $inputs]);
|
return MessageResponse::data(['testType' => $testType, 'inputs' => $inputs]);
|
||||||
}
|
}
|
||||||
return \MessageResponse::error();
|
return MessageResponse::error();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listNames()
|
public function listNames()
|
||||||
{
|
{
|
||||||
$testType = TestType::pluck('name');
|
$testType = TestType::pluck('name');
|
||||||
return \MessageResponse::data($testType);
|
return MessageResponse::data($testType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function destroy(TestType $TestType)
|
public function destroy(TestType $TestType)
|
||||||
{
|
{
|
||||||
if (!auth('api')->user()->can('delete', $TestType)) {
|
if (!auth('api')->user()->can('delete', $TestType)) {
|
||||||
return \MessageResponse::error(trans('messages.access_denied'));
|
return MessageResponse::error(trans('messages.access_denied'));
|
||||||
}
|
}
|
||||||
$UniqueID = substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, 10);
|
$UniqueID = substr(base_convert(sha1(uniqid(mt_rand())), 16, 36), 0, 10);
|
||||||
$TestType->unique_code = $TestType->unique_code.'--'.$UniqueID;
|
$TestType->unique_code = $TestType->unique_code . '--' . $UniqueID;
|
||||||
$TestType->save();
|
$TestType->save();
|
||||||
$TestType->delete();
|
$TestType->delete();
|
||||||
return \MessageResponse::success(trans('messages.success'));
|
return MessageResponse::success(trans('messages.success'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,19 +3,15 @@
|
|||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class Authenticate extends Middleware
|
class Authenticate extends Middleware
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the path the user should be redirected to when they are not authenticated.
|
* Get the path the user should be redirected to when they are not authenticated.
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
protected function redirectTo($request)
|
protected function redirectTo(Request $request): ?string
|
||||||
{
|
{
|
||||||
if (! $request->expectsJson()) {
|
return $request->expectsJson() ? null : route('login');
|
||||||
return route('login');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Fideloper\Proxy\TrustProxies as Middleware;
|
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||||
use Symfony\Component\HttpFoundation\Request as RequestAlias;
|
use Symfony\Component\HttpFoundation\Request as RequestAlias;
|
||||||
|
|
||||||
class TrustProxies extends Middleware
|
class TrustProxies extends Middleware
|
||||||
|
|||||||
+17
-13
@@ -3,55 +3,56 @@
|
|||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
use App\Constants\StatusTypeEnum;
|
use App\Constants\StatusTypeEnum;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Spatie\MediaLibrary\HasMedia\HasMedia;
|
|
||||||
use App\Services\Media\HasMediaTrait;
|
use App\Services\Media\HasMediaTrait;
|
||||||
use Spatie\MediaLibrary\Models\Media;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Spatie\Image\Exceptions\InvalidManipulation;
|
||||||
|
use Spatie\MediaLibrary\HasMedia;
|
||||||
|
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||||
|
|
||||||
class Item extends Model implements HasMedia
|
class Item extends Model implements HasMedia
|
||||||
{
|
{
|
||||||
use HasMediaTrait;
|
use HasMediaTrait;
|
||||||
|
|
||||||
public $fillable = [ 'name' , 'size' , 'unique_id' , 'specific' , 'note' , 'user_id' , 'udi' , 'status' , 'repair' , 'package_id' , 'creator_id' ];
|
public $fillable = ['name', 'size', 'unique_id', 'specific', 'note', 'user_id', 'udi', 'status', 'repair', 'package_id', 'creator_id'];
|
||||||
|
|
||||||
public function scopeIsNotRepaired($query)
|
public function scopeIsNotRepaired($query)
|
||||||
{
|
{
|
||||||
return $query->where( 'repair' , 0 );
|
return $query->where('repair', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function package()
|
public function package()
|
||||||
{
|
{
|
||||||
return $this->belongsTo( 'App\Package' );
|
return $this->belongsTo('App\Package');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function user()
|
public function user()
|
||||||
{
|
{
|
||||||
return $this->belongsTo( 'App\User' );
|
return $this->belongsTo('App\User');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function creator()
|
public function creator()
|
||||||
{
|
{
|
||||||
return $this->belongsTo( 'App\User' , "creator_id" );
|
return $this->belongsTo('App\User', "creator_id");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function transfersAll()
|
public function transfersAll()
|
||||||
{
|
{
|
||||||
return $this->morphMany( 'App\Transfer' , "transferable" )->orderBy("id" , "desc");
|
return $this->morphMany('App\Transfer', "transferable")->orderBy("id", "desc");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function transfers()
|
public function transfers()
|
||||||
{
|
{
|
||||||
return $this->morphMany( 'App\Transfer' , "transferable" )->where( "status" , StatusTypeEnum::APPROVED )->orderBy("id" , "desc");
|
return $this->morphMany('App\Transfer', "transferable")->where("status", StatusTypeEnum::APPROVED)->orderBy("id", "desc");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function latestTransfer()
|
public function latestTransfer()
|
||||||
{
|
{
|
||||||
return $this->morphOne( 'App\Transfer' , "transferable" )->where( "status" , StatusTypeEnum::APPROVED )->orderBy("id" , "desc")->latest();
|
return $this->morphOne('App\Transfer', "transferable")->where("status", StatusTypeEnum::APPROVED)->orderBy("id", "desc")->latest();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function transferActive()
|
public function transferActive()
|
||||||
{
|
{
|
||||||
return $this->morphMany( 'App\Transfer' , "transferable" )->where( "status" , StatusTypeEnum::APPROVED )->whereNull( "to_date" )->orderBy("id" , "desc");
|
return $this->morphMany('App\Transfer', "transferable")->where("status", StatusTypeEnum::APPROVED)->whereNull("to_date")->orderBy("id", "desc");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function registerMediaCollections(): void
|
public function registerMediaCollections(): void
|
||||||
@@ -61,7 +62,10 @@ class Item extends Model implements HasMedia
|
|||||||
->useFallbackPath(public_path('/files/default_pastry.jpg'));
|
->useFallbackPath(public_path('/files/default_pastry.jpg'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function registerMediaConversions( Media $media = null )
|
/**
|
||||||
|
* @throws InvalidManipulation
|
||||||
|
*/
|
||||||
|
public function registerMediaConversions(Media $media = null): void
|
||||||
{
|
{
|
||||||
$this->addMediaConversion('thumbnail')
|
$this->addMediaConversion('thumbnail')
|
||||||
->width(480)
|
->width(480)
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Services\Media;
|
namespace App\Services\Media;
|
||||||
|
|
||||||
use Spatie\MediaLibrary\HasMedia\HasMediaTrait as BasicHasMedia;
|
|
||||||
|
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||||
|
|
||||||
trait HasMediaTrait
|
trait HasMediaTrait
|
||||||
{
|
{
|
||||||
use BasicHasMedia;
|
use InteractsWithMedia;
|
||||||
|
|
||||||
public function main_image()
|
public function main_image()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Services\Media;
|
namespace App\Services\Media;
|
||||||
|
|
||||||
use Spatie\MediaLibrary\Models\Media as BaseMedia;
|
use Spatie\MediaLibrary\MediaCollections\Models\Media as BaseMedia;
|
||||||
|
|
||||||
class Media extends BaseMedia
|
class Media extends BaseMedia
|
||||||
{
|
{
|
||||||
public function getTable()
|
public function getTable(): string
|
||||||
{
|
{
|
||||||
return 'media';
|
return 'media';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,18 +2,22 @@
|
|||||||
|
|
||||||
namespace App\Services\Media;
|
namespace App\Services\Media;
|
||||||
|
|
||||||
use Spatie\MediaLibrary\Models\Media;
|
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||||
use Spatie\MediaLibrary\PathGenerator\PathGenerator as BasePathGenerator;
|
use Spatie\MediaLibrary\Support\PathGenerator\DefaultPathGenerator;
|
||||||
|
|
||||||
class PathGenerator implements BasePathGenerator
|
class PathGenerator extends DefaultPathGenerator
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the path for the given media, relative to the root storage path.
|
* Get the path for the given media, relative to the root storage path.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
* @param Media $media
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getPath(Media $media): string
|
public function getPath(Media $media): string
|
||||||
{
|
{
|
||||||
return md5($media->id).'/';
|
return md5($media->id) . '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -21,7 +25,7 @@ class PathGenerator implements BasePathGenerator
|
|||||||
*/
|
*/
|
||||||
public function getPathForConversions(Media $media): string
|
public function getPathForConversions(Media $media): string
|
||||||
{
|
{
|
||||||
return $this->getPath($media).'conversions/';
|
return $this->getPath($media) . 'conversions/';
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -29,7 +33,7 @@ class PathGenerator implements BasePathGenerator
|
|||||||
*/
|
*/
|
||||||
public function getPathForResponsiveImages(Media $media): string
|
public function getPathForResponsiveImages(Media $media): string
|
||||||
{
|
{
|
||||||
return $this->getPath($media).'responsive-images/';
|
return $this->getPath($media) . 'responsive-images/';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
namespace App\Services\Media\UrlGenerator;
|
namespace App\Services\Media\UrlGenerator;
|
||||||
|
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
use Spatie\MediaLibrary\UrlGenerator\BaseUrlGenerator;
|
use Spatie\MediaLibrary\MediaCollections\Exceptions\InvalidUrlGenerator;
|
||||||
use Spatie\MediaLibrary\Exceptions\UrlCannotBeDetermined;
|
use Spatie\MediaLibrary\Support\UrlGenerator\BaseUrlGenerator;
|
||||||
|
|
||||||
class FtpUrlGenerator extends BaseUrlGenerator
|
class FtpUrlGenerator extends BaseUrlGenerator
|
||||||
{
|
{
|
||||||
@@ -15,7 +15,7 @@ class FtpUrlGenerator extends BaseUrlGenerator
|
|||||||
*/
|
*/
|
||||||
public function getUrl(): string
|
public function getUrl(): string
|
||||||
{
|
{
|
||||||
return config( 'media-library.wm-cdn' ) . '/' . $this->getPathRelativeToRoot();
|
return config('media-library.wm-cdn') . '/' . $this->getPathRelativeToRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,13 +23,11 @@ class FtpUrlGenerator extends BaseUrlGenerator
|
|||||||
* @param array $options
|
* @param array $options
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
* @throws InvalidUrlGenerator
|
||||||
* @throws UrlCannotBeDetermined
|
|
||||||
*/
|
*/
|
||||||
public function getTemporaryUrl( DateTimeInterface $expiration , array $options = [] ): string
|
public function getTemporaryUrl(DateTimeInterface $expiration, array $options = []): string
|
||||||
{
|
{
|
||||||
throw UrlCannotBeDetermined::filesystemDoesNotSupportTemporaryUrls();
|
throw new InvalidUrlGenerator();
|
||||||
return 'done';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,7 +36,7 @@ class FtpUrlGenerator extends BaseUrlGenerator
|
|||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getPath()
|
public function getPath(): string
|
||||||
{
|
{
|
||||||
return $this->getPathRelativeToRoot();
|
return $this->getPathRelativeToRoot();
|
||||||
}
|
}
|
||||||
@@ -50,6 +48,6 @@ class FtpUrlGenerator extends BaseUrlGenerator
|
|||||||
*/
|
*/
|
||||||
public function getResponsiveImagesDirectoryUrl(): string
|
public function getResponsiveImagesDirectoryUrl(): string
|
||||||
{
|
{
|
||||||
return config( 'media-library.wm-cdn' ) . '/' . $this->pathGenerator->getPathForResponsiveImages( $this->media );
|
return config('media-library.wm-cdn') . '/' . $this->pathGenerator->getPathForResponsiveImages($this->media);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
namespace App\Services\Media\UrlGenerator;
|
namespace App\Services\Media\UrlGenerator;
|
||||||
|
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
use Spatie\MediaLibrary\UrlGenerator\BaseUrlGenerator;
|
use Spatie\MediaLibrary\Support\UrlGenerator\BaseUrlGenerator;
|
||||||
|
|
||||||
class S3UrlGenerator extends BaseUrlGenerator
|
class S3UrlGenerator extends BaseUrlGenerator
|
||||||
{
|
{
|
||||||
@@ -14,7 +14,7 @@ class S3UrlGenerator extends BaseUrlGenerator
|
|||||||
*/
|
*/
|
||||||
public function getUrl(): string
|
public function getUrl(): string
|
||||||
{
|
{
|
||||||
return config( 'media-library.s3.domain' ) . '/' . $this->getPathRelativeToRoot();
|
return config('media-library.s3.domain') . '/' . $this->getPathRelativeToRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,7 +24,7 @@ class S3UrlGenerator extends BaseUrlGenerator
|
|||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getTemporaryUrl( DateTimeInterface $expiration , array $options = [] ): string
|
public function getTemporaryUrl(DateTimeInterface $expiration, array $options = []): string
|
||||||
{
|
{
|
||||||
|
|
||||||
return 'done';
|
return 'done';
|
||||||
@@ -48,6 +48,6 @@ class S3UrlGenerator extends BaseUrlGenerator
|
|||||||
*/
|
*/
|
||||||
public function getResponsiveImagesDirectoryUrl(): string
|
public function getResponsiveImagesDirectoryUrl(): string
|
||||||
{
|
{
|
||||||
return config( 'media-library.s3.domain' ) . '/' . $this->pathGenerator->getPathForResponsiveImages( $this->media );
|
return config('media-library.s3.domain') . '/' . $this->pathGenerator->getPathForResponsiveImages($this->media);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-6
@@ -2,16 +2,17 @@
|
|||||||
|
|
||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Spatie\MediaLibrary\HasMedia\HasMedia;
|
|
||||||
use App\Services\Media\HasMediaTrait;
|
use App\Services\Media\HasMediaTrait;
|
||||||
use Spatie\MediaLibrary\Models\Media;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Spatie\Image\Exceptions\InvalidManipulation;
|
||||||
|
use Spatie\MediaLibrary\HasMedia;
|
||||||
|
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||||
|
|
||||||
class TestResult extends Model implements HasMedia
|
class TestResult extends Model implements HasMedia
|
||||||
{
|
{
|
||||||
use HasMediaTrait;
|
use HasMediaTrait;
|
||||||
|
|
||||||
public $fillable = [ 'result', 'verified', 'test_type_id', 'user_id', 'device_id', 'cycle_number', 'date'];
|
public $fillable = ['result', 'verified', 'test_type_id', 'user_id', 'device_id', 'cycle_number', 'date'];
|
||||||
|
|
||||||
public function test_type()
|
public function test_type()
|
||||||
{
|
{
|
||||||
@@ -28,14 +29,17 @@ class TestResult extends Model implements HasMedia
|
|||||||
return $this->hasMany('App\InputValue');
|
return $this->hasMany('App\InputValue');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function registerMediaCollections()
|
public function registerMediaCollections(): void
|
||||||
{
|
{
|
||||||
$this->addMediaCollection('files')
|
$this->addMediaCollection('files')
|
||||||
->useFallbackUrl('/files/default_pastry.jpg')
|
->useFallbackUrl('/files/default_pastry.jpg')
|
||||||
->useFallbackPath(public_path('/files/default_pastry.jpg'));
|
->useFallbackPath(public_path('/files/default_pastry.jpg'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function registerMediaConversions( Media $media = null ): void
|
/**
|
||||||
|
* @throws InvalidManipulation
|
||||||
|
*/
|
||||||
|
public function registerMediaConversions(Media $media = null): void
|
||||||
{
|
{
|
||||||
$this->addMediaConversion('thumbnail')
|
$this->addMediaConversion('thumbnail')
|
||||||
->width(480)
|
->width(480)
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
"fzaninotto/faker": "^1.4",
|
"fzaninotto/faker": "^1.4",
|
||||||
"mockery/mockery": "^1.0",
|
"mockery/mockery": "^1.0",
|
||||||
"nunomaduro/collision": "^7.0",
|
"nunomaduro/collision": "^7.0",
|
||||||
|
"nunomaduro/larastan": "^2.9",
|
||||||
|
"phpstan/phpstan": "^1.12",
|
||||||
"phpunit/phpunit": "^10.0"
|
"phpunit/phpunit": "^10.0"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
|
|||||||
Generated
+250
-1
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "e2748582c5a2c41a9931dc128d1bf8cb",
|
"content-hash": "d40968ccde886735623454e5620cb78b",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "aws/aws-crt-php",
|
"name": "aws/aws-crt-php",
|
||||||
@@ -9579,6 +9579,110 @@
|
|||||||
],
|
],
|
||||||
"time": "2024-10-15T15:12:40+00:00"
|
"time": "2024-10-15T15:12:40+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "nunomaduro/larastan",
|
||||||
|
"version": "v2.9.10",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/larastan/larastan.git",
|
||||||
|
"reference": "9e7233d88f4f10796fadb8a2d85c5f2b55277c76"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/larastan/larastan/zipball/9e7233d88f4f10796fadb8a2d85c5f2b55277c76",
|
||||||
|
"reference": "9e7233d88f4f10796fadb8a2d85c5f2b55277c76",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-json": "*",
|
||||||
|
"illuminate/console": "^9.52.16 || ^10.28.0 || ^11.16",
|
||||||
|
"illuminate/container": "^9.52.16 || ^10.28.0 || ^11.16",
|
||||||
|
"illuminate/contracts": "^9.52.16 || ^10.28.0 || ^11.16",
|
||||||
|
"illuminate/database": "^9.52.16 || ^10.28.0 || ^11.16",
|
||||||
|
"illuminate/http": "^9.52.16 || ^10.28.0 || ^11.16",
|
||||||
|
"illuminate/pipeline": "^9.52.16 || ^10.28.0 || ^11.16",
|
||||||
|
"illuminate/support": "^9.52.16 || ^10.28.0 || ^11.16",
|
||||||
|
"php": "^8.0.2",
|
||||||
|
"phpmyadmin/sql-parser": "^5.9.0",
|
||||||
|
"phpstan/phpstan": "^1.12.5"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"doctrine/coding-standard": "^12.0",
|
||||||
|
"nikic/php-parser": "^4.19.1",
|
||||||
|
"orchestra/canvas": "^7.11.1 || ^8.11.0 || ^9.0.2",
|
||||||
|
"orchestra/testbench": "^7.33.0 || ^8.13.0 || ^9.0.3",
|
||||||
|
"phpstan/phpstan-deprecation-rules": "^1.2",
|
||||||
|
"phpunit/phpunit": "^9.6.13 || ^10.5.16"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"orchestra/testbench": "Using Larastan for analysing a package needs Testbench"
|
||||||
|
},
|
||||||
|
"type": "phpstan-extension",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "2.0-dev"
|
||||||
|
},
|
||||||
|
"phpstan": {
|
||||||
|
"includes": [
|
||||||
|
"extension.neon"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Larastan\\Larastan\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Can Vural",
|
||||||
|
"email": "can9119@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Nuno Maduro",
|
||||||
|
"email": "enunomaduro@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Larastan - Discover bugs in your code without running it. A phpstan/phpstan wrapper for Laravel",
|
||||||
|
"keywords": [
|
||||||
|
"PHPStan",
|
||||||
|
"code analyse",
|
||||||
|
"code analysis",
|
||||||
|
"larastan",
|
||||||
|
"laravel",
|
||||||
|
"package",
|
||||||
|
"php",
|
||||||
|
"static analysis"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/larastan/larastan/issues",
|
||||||
|
"source": "https://github.com/larastan/larastan/tree/v2.9.10"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://www.paypal.com/paypalme/enunomaduro",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/canvural",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/nunomaduro",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://www.patreon.com/nunomaduro",
|
||||||
|
"type": "patreon"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"abandoned": "larastan/larastan",
|
||||||
|
"time": "2024-10-19T23:04:40+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "phar-io/manifest",
|
"name": "phar-io/manifest",
|
||||||
"version": "2.0.4",
|
"version": "2.0.4",
|
||||||
@@ -9697,6 +9801,151 @@
|
|||||||
},
|
},
|
||||||
"time": "2022-02-21T01:04:05+00:00"
|
"time": "2022-02-21T01:04:05+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "phpmyadmin/sql-parser",
|
||||||
|
"version": "5.10.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/phpmyadmin/sql-parser.git",
|
||||||
|
"reference": "91d980ab76c3f152481e367f62b921adc38af451"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/phpmyadmin/sql-parser/zipball/91d980ab76c3f152481e367f62b921adc38af451",
|
||||||
|
"reference": "91d980ab76c3f152481e367f62b921adc38af451",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.2 || ^8.0",
|
||||||
|
"symfony/polyfill-mbstring": "^1.3",
|
||||||
|
"symfony/polyfill-php80": "^1.16"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"phpmyadmin/motranslator": "<3.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpbench/phpbench": "^1.1",
|
||||||
|
"phpmyadmin/coding-standard": "^3.0",
|
||||||
|
"phpmyadmin/motranslator": "^4.0 || ^5.0",
|
||||||
|
"phpstan/extension-installer": "^1.1",
|
||||||
|
"phpstan/phpstan": "^1.9.12",
|
||||||
|
"phpstan/phpstan-phpunit": "^1.3.3",
|
||||||
|
"phpunit/phpunit": "^8.5 || ^9.6",
|
||||||
|
"psalm/plugin-phpunit": "^0.16.1",
|
||||||
|
"vimeo/psalm": "^4.11",
|
||||||
|
"zumba/json-serializer": "~3.0.2"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-mbstring": "For best performance",
|
||||||
|
"phpmyadmin/motranslator": "Translate messages to your favorite locale"
|
||||||
|
},
|
||||||
|
"bin": [
|
||||||
|
"bin/highlight-query",
|
||||||
|
"bin/lint-query",
|
||||||
|
"bin/sql-parser",
|
||||||
|
"bin/tokenize-query"
|
||||||
|
],
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"PhpMyAdmin\\SqlParser\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"GPL-2.0-or-later"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "The phpMyAdmin Team",
|
||||||
|
"email": "developers@phpmyadmin.net",
|
||||||
|
"homepage": "https://www.phpmyadmin.net/team/"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "A validating SQL lexer and parser with a focus on MySQL dialect.",
|
||||||
|
"homepage": "https://github.com/phpmyadmin/sql-parser",
|
||||||
|
"keywords": [
|
||||||
|
"analysis",
|
||||||
|
"lexer",
|
||||||
|
"parser",
|
||||||
|
"query linter",
|
||||||
|
"sql",
|
||||||
|
"sql lexer",
|
||||||
|
"sql linter",
|
||||||
|
"sql parser",
|
||||||
|
"sql syntax highlighter",
|
||||||
|
"sql tokenizer"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/phpmyadmin/sql-parser/issues",
|
||||||
|
"source": "https://github.com/phpmyadmin/sql-parser"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://www.phpmyadmin.net/donate/",
|
||||||
|
"type": "other"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-08-29T20:56:34+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "phpstan/phpstan",
|
||||||
|
"version": "1.12.8",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/phpstan/phpstan.git",
|
||||||
|
"reference": "f6a60a4d66142b8156c9da923f1972657bc4748c"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/f6a60a4d66142b8156c9da923f1972657bc4748c",
|
||||||
|
"reference": "f6a60a4d66142b8156c9da923f1972657bc4748c",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.2|^8.0"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"phpstan/phpstan-shim": "*"
|
||||||
|
},
|
||||||
|
"bin": [
|
||||||
|
"phpstan",
|
||||||
|
"phpstan.phar"
|
||||||
|
],
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"bootstrap.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"description": "PHPStan - PHP Static Analysis Tool",
|
||||||
|
"keywords": [
|
||||||
|
"dev",
|
||||||
|
"static analysis"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"docs": "https://phpstan.org/user-guide/getting-started",
|
||||||
|
"forum": "https://github.com/phpstan/phpstan/discussions",
|
||||||
|
"issues": "https://github.com/phpstan/phpstan/issues",
|
||||||
|
"security": "https://github.com/phpstan/phpstan/security/policy",
|
||||||
|
"source": "https://github.com/phpstan/phpstan-src"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/ondrejmirtes",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/phpstan",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-11-06T19:06:49+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-code-coverage",
|
"name": "phpunit/php-code-coverage",
|
||||||
"version": "10.1.16",
|
"version": "10.1.16",
|
||||||
|
|||||||
+166
-61
@@ -12,7 +12,13 @@ return [
|
|||||||
* The maximum file size of an item in bytes.
|
* The maximum file size of an item in bytes.
|
||||||
* Adding a larger file will result in an exception.
|
* Adding a larger file will result in an exception.
|
||||||
*/
|
*/
|
||||||
'max_file_size' => 1024 * 1024 * 10,
|
'max_file_size' => 1024 * 1024 * 10, // 10MB
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This queue connection will be used to generate derived and responsive images.
|
||||||
|
* Leave empty to use the default queue connection.
|
||||||
|
*/
|
||||||
|
'queue_connection_name' => env('QUEUE_CONNECTION', 'sync'),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This queue will be used to generate derived and responsive images.
|
* This queue will be used to generate derived and responsive images.
|
||||||
@@ -20,61 +26,78 @@ return [
|
|||||||
*/
|
*/
|
||||||
'queue_name' => '',
|
'queue_name' => '',
|
||||||
|
|
||||||
|
/*
|
||||||
|
* By default all conversions will be performed on a queue.
|
||||||
|
*/
|
||||||
|
'queue_conversions_by_default' => env('QUEUE_CONVERSIONS_BY_DEFAULT', true),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The fully qualified class name of the media model.
|
* The fully qualified class name of the media model.
|
||||||
*/
|
*/
|
||||||
'media_model' => Spatie\MediaLibrary\Models\Media::class,
|
'media_model' => Spatie\MediaLibrary\MediaCollections\Models\Media::class,
|
||||||
|
|
||||||
's3' => [
|
/*
|
||||||
/*
|
* When enabled, media collections will be serialised using the default
|
||||||
* The domain that should be prepended when generating urls.
|
* laravel model serialization behaviour.
|
||||||
*/
|
*
|
||||||
'domain' => env('AWS_URL'),
|
* Keep this option disabled if using Media Library Pro components (https://medialibrary.pro)
|
||||||
],
|
*/
|
||||||
|
'use_default_collection_serialization' => false,
|
||||||
|
|
||||||
'remote' => [
|
/*
|
||||||
/*
|
* The fully qualified class name of the model used for temporary uploads.
|
||||||
* Any extra headers that should be included when uploading media to
|
*
|
||||||
* a remote disk. Even though supported headers may vary between
|
* This model is only used in Media Library Pro (https://medialibrary.pro)
|
||||||
* different drivers, a sensible default has been provided.
|
*/
|
||||||
*
|
'temporary_upload_model' => Spatie\MediaLibraryPro\Models\TemporaryUpload::class,
|
||||||
* Supported by S3: CacheControl, Expires, StorageClass,
|
|
||||||
* ServerSideEncryption, Metadata, ACL, ContentEncoding
|
|
||||||
*/
|
|
||||||
'extra_headers' => [
|
|
||||||
'CacheControl' => 'max-age=604800',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
|
|
||||||
'responsive_images' => [
|
/*
|
||||||
|
* When enabled, Media Library Pro will only process temporary uploads that were uploaded
|
||||||
|
* in the same session. You can opt to disable this for stateless usage of
|
||||||
|
* the pro components.
|
||||||
|
*/
|
||||||
|
'enable_temporary_uploads_session_affinity' => true,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This class is responsible for calculating the target widths of the responsive
|
* When enabled, Media Library pro will generate thumbnails for uploaded file.
|
||||||
* images. By default we optimize for filesize and create variations that each are 20%
|
*/
|
||||||
* smaller than the previous one. More info in the documentation.
|
'generate_thumbnails_for_temporary_uploads' => true,
|
||||||
*
|
|
||||||
* https://docs.spatie.be/laravel-medialibrary/v7/advanced-usage/generating-responsive-images
|
|
||||||
*/
|
|
||||||
'width_calculator' => Spatie\MediaLibrary\ResponsiveImages\WidthCalculator\FileSizeOptimizedWidthCalculator::class,
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* By default rendering media to a responsive image will add some javascript and a tiny placeholder.
|
* This is the class that is responsible for naming generated files.
|
||||||
* This ensures that the browser can already determine the correct layout.
|
*/
|
||||||
*/
|
'file_namer' => Spatie\MediaLibrary\Support\FileNamer\DefaultFileNamer::class,
|
||||||
'use_tiny_placeholders' => true,
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This class will generate the tiny placeholder used for progressive image loading. By default
|
* The class that contains the strategy for determining a media file's path.
|
||||||
* the medialibrary will use a tiny blurred jpg image.
|
*/
|
||||||
*/
|
'path_generator' => Spatie\MediaLibrary\Support\PathGenerator\DefaultPathGenerator::class,
|
||||||
'tiny_placeholder_generator' => Spatie\MediaLibrary\ResponsiveImages\TinyPlaceholderGenerator\Blurred::class,
|
|
||||||
|
/*
|
||||||
|
* The class that contains the strategy for determining how to remove files.
|
||||||
|
*/
|
||||||
|
'file_remover_class' => Spatie\MediaLibrary\Support\FileRemover\DefaultFileRemover::class,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Here you can specify which path generator should be used for the given class.
|
||||||
|
*/
|
||||||
|
'custom_path_generators' => [
|
||||||
|
// Model::class => PathGenerator::class
|
||||||
|
// or
|
||||||
|
// 'model_morph_alias' => PathGenerator::class
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When urls to files get generated, this class will be called. Leave empty
|
* When urls to files get generated, this class will be called. Use the default
|
||||||
* if your files are stored locally above the site root or on s3.
|
* if your files are stored locally above the site root or on s3.
|
||||||
*/
|
*/
|
||||||
'url_generator' => null,
|
'url_generator' => Spatie\MediaLibrary\Support\UrlGenerator\DefaultUrlGenerator::class,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Moves media on updating to keep path consistent. Enable it only with a custom
|
||||||
|
* PathGenerator that uses, for example, the media UUID.
|
||||||
|
*/
|
||||||
|
'moves_media_on_update' => false,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Whether to activate versioning when urls to files get generated.
|
* Whether to activate versioning when urls to files get generated.
|
||||||
@@ -83,17 +106,14 @@ return [
|
|||||||
'version_urls' => false,
|
'version_urls' => false,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The class that contains the strategy for determining a media file's path.
|
* The media library will try to optimize all converted images by removing
|
||||||
*/
|
|
||||||
'path_generator' => null,
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Medialibrary will try to optimize all converted images by removing
|
|
||||||
* metadata and applying a little bit of compression. These are
|
* metadata and applying a little bit of compression. These are
|
||||||
* the optimizers that will be used by default.
|
* the optimizers that will be used by default.
|
||||||
*/
|
*/
|
||||||
'image_optimizers' => [
|
'image_optimizers' => [
|
||||||
Spatie\ImageOptimizer\Optimizers\Jpegoptim::class => [
|
Spatie\ImageOptimizer\Optimizers\Jpegoptim::class => [
|
||||||
|
'-m85', // set maximum quality to 85%
|
||||||
|
'--force', // ensure that progressive generation is always done also if a little bigger
|
||||||
'--strip-all', // this strips out all text information such as comments and EXIF data
|
'--strip-all', // this strips out all text information such as comments and EXIF data
|
||||||
'--all-progressive', // this will make sure the resulting image is a progressive one
|
'--all-progressive', // this will make sure the resulting image is a progressive one
|
||||||
],
|
],
|
||||||
@@ -112,19 +132,42 @@ return [
|
|||||||
'-b', // required parameter for this package
|
'-b', // required parameter for this package
|
||||||
'-O3', // this produces the slowest but best results
|
'-O3', // this produces the slowest but best results
|
||||||
],
|
],
|
||||||
|
Spatie\ImageOptimizer\Optimizers\Cwebp::class => [
|
||||||
|
'-m 6', // for the slowest compression method in order to get the best compression.
|
||||||
|
'-pass 10', // for maximizing the amount of analysis pass.
|
||||||
|
'-mt', // multithreading for some speed improvements.
|
||||||
|
'-q 90', //quality factor that brings the least noticeable changes.
|
||||||
|
],
|
||||||
|
Spatie\ImageOptimizer\Optimizers\Avifenc::class => [
|
||||||
|
'-a cq-level=23', // constant quality level, lower values mean better quality and greater file size (0-63).
|
||||||
|
'-j all', // number of jobs (worker threads, "all" uses all available cores).
|
||||||
|
'--min 0', // min quantizer for color (0-63).
|
||||||
|
'--max 63', // max quantizer for color (0-63).
|
||||||
|
'--minalpha 0', // min quantizer for alpha (0-63).
|
||||||
|
'--maxalpha 63', // max quantizer for alpha (0-63).
|
||||||
|
'-a end-usage=q', // rate control mode set to Constant Quality mode.
|
||||||
|
'-a tune=ssim', // SSIM as tune the encoder for distortion metric.
|
||||||
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These generators will be used to create an image of media files.
|
* These generators will be used to create an image of media files.
|
||||||
*/
|
*/
|
||||||
'image_generators' => [
|
'image_generators' => [
|
||||||
Spatie\MediaLibrary\ImageGenerators\FileTypes\Image::class,
|
Spatie\MediaLibrary\Conversions\ImageGenerators\Image::class,
|
||||||
Spatie\MediaLibrary\ImageGenerators\FileTypes\Webp::class,
|
Spatie\MediaLibrary\Conversions\ImageGenerators\Webp::class,
|
||||||
Spatie\MediaLibrary\ImageGenerators\FileTypes\Pdf::class,
|
Spatie\MediaLibrary\Conversions\ImageGenerators\Avif::class,
|
||||||
Spatie\MediaLibrary\ImageGenerators\FileTypes\Svg::class,
|
Spatie\MediaLibrary\Conversions\ImageGenerators\Pdf::class,
|
||||||
Spatie\MediaLibrary\ImageGenerators\FileTypes\Video::class,
|
Spatie\MediaLibrary\Conversions\ImageGenerators\Svg::class,
|
||||||
|
Spatie\MediaLibrary\Conversions\ImageGenerators\Video::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The path where to store temporary files while performing image conversions.
|
||||||
|
* If set to null, storage_path('media-library/temp') will be used.
|
||||||
|
*/
|
||||||
|
'temporary_directory_path' => null,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The engine that should perform the image conversions.
|
* The engine that should perform the image conversions.
|
||||||
* Should be either `gd` or `imagick`.
|
* Should be either `gd` or `imagick`.
|
||||||
@@ -139,18 +182,80 @@ return [
|
|||||||
'ffmpeg_path' => env('FFMPEG_PATH', '/usr/bin/ffmpeg'),
|
'ffmpeg_path' => env('FFMPEG_PATH', '/usr/bin/ffmpeg'),
|
||||||
'ffprobe_path' => env('FFPROBE_PATH', '/usr/bin/ffprobe'),
|
'ffprobe_path' => env('FFPROBE_PATH', '/usr/bin/ffprobe'),
|
||||||
|
|
||||||
/*
|
|
||||||
* The path where to store temporary files while performing image conversions.
|
|
||||||
* If set to null, storage_path('medialibrary/temp') will be used.
|
|
||||||
*/
|
|
||||||
'temporary_directory_path' => null,
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Here you can override the class names of the jobs used by this package. Make sure
|
* Here you can override the class names of the jobs used by this package. Make sure
|
||||||
* your custom jobs extend the ones provided by the package.
|
* your custom jobs extend the ones provided by the package.
|
||||||
*/
|
*/
|
||||||
'jobs' => [
|
'jobs' => [
|
||||||
'perform_conversions' => Spatie\MediaLibrary\Jobs\PerformConversions::class,
|
'perform_conversions' => Spatie\MediaLibrary\Conversions\Jobs\PerformConversionsJob::class,
|
||||||
'generate_responsive_images' => Spatie\MediaLibrary\Jobs\GenerateResponsiveImages::class,
|
'generate_responsive_images' => Spatie\MediaLibrary\ResponsiveImages\Jobs\GenerateResponsiveImagesJob::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When using the addMediaFromUrl method you may want to replace the default downloader.
|
||||||
|
* This is particularly useful when the url of the image is behind a firewall and
|
||||||
|
* need to add additional flags, possibly using curl.
|
||||||
|
*/
|
||||||
|
'media_downloader' => Spatie\MediaLibrary\Downloaders\DefaultDownloader::class,
|
||||||
|
|
||||||
|
'remote' => [
|
||||||
|
/*
|
||||||
|
* Any extra headers that should be included when uploading media to
|
||||||
|
* a remote disk. Even though supported headers may vary between
|
||||||
|
* different drivers, a sensible default has been provided.
|
||||||
|
*
|
||||||
|
* Supported by S3: CacheControl, Expires, StorageClass,
|
||||||
|
* ServerSideEncryption, Metadata, ACL, ContentEncoding
|
||||||
|
*/
|
||||||
|
'extra_headers' => [
|
||||||
|
'CacheControl' => 'max-age=604800',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
'responsive_images' => [
|
||||||
|
/*
|
||||||
|
* This class is responsible for calculating the target widths of the responsive
|
||||||
|
* images. By default we optimize for filesize and create variations that each are 30%
|
||||||
|
* smaller than the previous one. More info in the documentation.
|
||||||
|
*
|
||||||
|
* https://docs.spatie.be/laravel-medialibrary/v9/advanced-usage/generating-responsive-images
|
||||||
|
*/
|
||||||
|
'width_calculator' => Spatie\MediaLibrary\ResponsiveImages\WidthCalculator\FileSizeOptimizedWidthCalculator::class,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* By default rendering media to a responsive image will add some javascript and a tiny placeholder.
|
||||||
|
* This ensures that the browser can already determine the correct layout.
|
||||||
|
*/
|
||||||
|
'use_tiny_placeholders' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This class will generate the tiny placeholder used for progressive image loading. By default
|
||||||
|
* the media library will use a tiny blurred jpg image.
|
||||||
|
*/
|
||||||
|
'tiny_placeholder_generator' => Spatie\MediaLibrary\ResponsiveImages\TinyPlaceholderGenerator\Blurred::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When enabling this option, a route will be registered that will enable
|
||||||
|
* the Media Library Pro Vue and React components to move uploaded files
|
||||||
|
* in a S3 bucket to their right place.
|
||||||
|
*/
|
||||||
|
'enable_vapor_uploads' => env('ENABLE_MEDIA_LIBRARY_VAPOR_UPLOADS', false),
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When converting Media instances to response the media library will add
|
||||||
|
* a `loading` attribute to the `img` tag. Here you can set the default
|
||||||
|
* value of that attribute.
|
||||||
|
*
|
||||||
|
* Possible values: 'lazy', 'eager', 'auto' or null if you don't want to set any loading instruction.
|
||||||
|
*
|
||||||
|
* More info: https://css-tricks.com/native-lazy-loading/
|
||||||
|
*/
|
||||||
|
'default_loading_attribute_value' => null,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* You can specify a prefix for that is used for storing all media.
|
||||||
|
* If you set this to `/my-subdir`, all your media will be stored in a `/my-subdir` directory.
|
||||||
|
*/
|
||||||
|
'prefix' => env('MEDIA_PREFIX', ''),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use Illuminate\Http\Request;
|
|||||||
use App\User;
|
use App\User;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use App\Http\Controllers\Api\Auth\LoginController;
|
use App\Http\Controllers\Api\Auth\LoginController;
|
||||||
|
use Packages\Messaging\src\Facades\MessageResponse;
|
||||||
use Packages\SMSSender\SMSSender;
|
use Packages\SMSSender\SMSSender;
|
||||||
|
|
||||||
trait SendsPasswordResetEmails
|
trait SendsPasswordResetEmails
|
||||||
@@ -32,7 +33,7 @@ trait SendsPasswordResetEmails
|
|||||||
* Check Disposable Password And Login
|
* Check Disposable Password And Login
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
public function checkDisposablePassword(Request $request)
|
public function checkDisposablePassword(Request $request)
|
||||||
{
|
{
|
||||||
@@ -48,9 +49,9 @@ trait SendsPasswordResetEmails
|
|||||||
$request->merge([ 'cell_number' => $user->cell_number, 'password' => $password ]);
|
$request->merge([ 'cell_number' => $user->cell_number, 'password' => $password ]);
|
||||||
return (new LoginController())->login($request);
|
return (new LoginController())->login($request);
|
||||||
}
|
}
|
||||||
return \MessageResponse::error('User Not Found');
|
return MessageResponse::error('User Not Found');
|
||||||
}
|
}
|
||||||
return \MessageResponse::error('Error');
|
return MessageResponse::error('Error');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -61,9 +62,9 @@ trait SendsPasswordResetEmails
|
|||||||
$code = rand(100000, 999999);
|
$code = rand(100000, 999999);
|
||||||
\Cache::put($code, $user->id, Carbon::now()->addMinutes(30));
|
\Cache::put($code, $user->id, Carbon::now()->addMinutes(30));
|
||||||
SMSSender::instance()->patternSend($request->cell_number, 'jqomyn42wo', ["verification-code" => $code]);
|
SMSSender::instance()->patternSend($request->cell_number, 'jqomyn42wo', ["verification-code" => $code]);
|
||||||
return \MessageResponse::success('Send Disposable Password');
|
return MessageResponse::success('Send Disposable Password');
|
||||||
}
|
}
|
||||||
return \MessageResponse::error('User Not Found');
|
return MessageResponse::error('User Not Found');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4,55 +4,58 @@ namespace Packages\SMSSender;
|
|||||||
|
|
||||||
class SMSSender
|
class SMSSender
|
||||||
{
|
{
|
||||||
private $userName = null;
|
private $userName = null;
|
||||||
private $password = null;
|
private $password = null;
|
||||||
private $webService = null;
|
private $webService = null;
|
||||||
private $fromNumber = null;
|
private $fromNumber = null;
|
||||||
private static $panel = null;
|
private static $panel = null;
|
||||||
|
|
||||||
private function __construct() { }
|
private function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public static function instance() {
|
public static function instance()
|
||||||
|
{
|
||||||
if (static::$panel === null) {
|
if (static::$panel === null) {
|
||||||
static::$panel = new static();
|
static::$panel = new self();
|
||||||
}
|
}
|
||||||
return static::$panel;
|
return static::$panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUserName ($userName)
|
public function setUserName($userName)
|
||||||
{
|
{
|
||||||
$this->userName = $userName;
|
$this->userName = $userName;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPassword ($password)
|
public function setPassword($password)
|
||||||
{
|
{
|
||||||
$this->password = $password;
|
$this->password = $password;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setWebService ($webService)
|
public function setWebService($webService)
|
||||||
{
|
{
|
||||||
$this->webService = $webService;
|
$this->webService = $webService;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUserName ()
|
public function getUserName()
|
||||||
{
|
{
|
||||||
return ($this->userName) ? $this->userName : env('SMS_USERNAME', '');
|
return ($this->userName) ? $this->userName : env('SMS_USERNAME', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPassword ()
|
public function getPassword()
|
||||||
{
|
{
|
||||||
return ($this->password) ? $this->password : env('SMS_PASSWORD', '');
|
return ($this->password) ? $this->password : env('SMS_PASSWORD', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFromNumber ()
|
public function getFromNumber()
|
||||||
{
|
{
|
||||||
return ($this->fromNumber) ? $this->fromNumber : env('SMS_FROM_NUMBER', '');
|
return ($this->fromNumber) ? $this->fromNumber : env('SMS_FROM_NUMBER', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getWebService ()
|
public function getWebService()
|
||||||
{
|
{
|
||||||
return ($this->webService) ? $this->webService : env('SMS_WEBSERVICE', '');
|
return ($this->webService) ? $this->webService : env('SMS_WEBSERVICE', '');
|
||||||
}
|
}
|
||||||
@@ -64,8 +67,8 @@ class SMSSender
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$user = $this->getUserName();
|
$user = $this->getUserName();
|
||||||
$pass = $this->getPassword();
|
$pass = $this->getPassword();
|
||||||
$fromNum = $this->getFromNumber();
|
$fromNum = $this->getFromNumber();
|
||||||
$client = new \SoapClient($this->getWebService());
|
$client = new \SoapClient($this->getWebService());
|
||||||
$client->sendPatternSms($fromNum, $cellNumber, $user, $pass, $pattern_code, $input_data);
|
$client->sendPatternSms($fromNum, $cellNumber, $user, $pass, $pattern_code, $input_data);
|
||||||
|
|
||||||
@@ -84,11 +87,11 @@ class SMSSender
|
|||||||
ini_set("soap.wsdl_cache_enabled", "0");
|
ini_set("soap.wsdl_cache_enabled", "0");
|
||||||
try {
|
try {
|
||||||
$user = $this->getUserName();
|
$user = $this->getUserName();
|
||||||
$pass = $this->getPassword();
|
$pass = $this->getPassword();
|
||||||
$fromNum = $this->getFromNumber();
|
$fromNum = $this->getFromNumber();
|
||||||
//If you want to send in the future ==> $time = '2016-07-30' //$time = '2016-07-30 12:50:50'
|
//If you want to send in the future ==> $time = '2016-07-30' //$time = '2016-07-30 12:50:50'
|
||||||
$client = new \SoapClient($this->getWebService());
|
$client = new \SoapClient($this->getWebService());
|
||||||
$client->SendSMS($fromNum, $cellNumber, $messageContent, $user, $pass, '', 'send');
|
$client->SendSMS($fromNum, $cellNumber, $messageContent, $user, $pass, '', 'send');
|
||||||
return true;
|
return true;
|
||||||
} catch (\SoapFault $sf) {
|
} catch (\SoapFault $sf) {
|
||||||
print $sf->faultcode . "\n";
|
print $sf->faultcode . "\n";
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| API Routes
|
| API Routes
|
||||||
@@ -11,6 +12,7 @@
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
Route::group(['namespace' => 'Api'],function () {
|
Route::group(['namespace' => 'Api'],function () {
|
||||||
|
|
||||||
Route::post('/login', 'Auth\LoginController@login')->name('login');
|
Route::post('/login', 'Auth\LoginController@login')->name('login');
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Broadcast;
|
||||||
|
|
||||||
Broadcast::channel('App.User.{id}', function ($user, $id) {
|
Broadcast::channel('App.User.{id}', function ($user, $id) {
|
||||||
return (int) $user->id === (int) $id;
|
return (int) $user->id === (int) $id;
|
||||||
});
|
});
|
||||||
|
|||||||
+3
-1
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Foundation\Inspiring;
|
use Illuminate\Foundation\Inspiring;
|
||||||
|
use Illuminate\Support\Facades\Artisan;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@@ -15,4 +16,5 @@ use Illuminate\Foundation\Inspiring;
|
|||||||
|
|
||||||
Artisan::command('inspire', function () {
|
Artisan::command('inspire', function () {
|
||||||
$this->comment(Inspiring::quote());
|
$this->comment(Inspiring::quote());
|
||||||
})->describe('Display an inspiring quote');
|
})->purpose('Display an inspiring quote');
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -12,4 +12,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
Route::post('oauth/token', '\Laravel\Passport\Http\Controllers\AccessTokenController@issueToken')->middleware('throttle');
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
Route::post(
|
||||||
|
'oauth/token',
|
||||||
|
'\Laravel\Passport\Http\Controllers\AccessTokenController@issueToken')
|
||||||
|
->middleware('throttle');
|
||||||
|
|||||||
+9
-9
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Web Routes
|
| Web Routes
|
||||||
@@ -10,11 +12,8 @@
|
|||||||
| contains the "web" middleware group. Now create something great!
|
| contains the "web" middleware group. Now create something great!
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
//
|
|
||||||
// app()->bind('messages', function() {
|
|
||||||
// return new \App\Appended\Classes\Common\Response\MessageResponse;
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
#todo move passport routes to own file
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Laravel Passport Routes
|
| Laravel Passport Routes
|
||||||
@@ -26,6 +25,7 @@
|
|||||||
| This will use "auth:api" guard instead of "auth"
|
| This will use "auth:api" guard instead of "auth"
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Route::get('oauth/authorize', '\Laravel\Passport\Http\Controllers\AuthorizationController@authorize')->middleware('auth:api');
|
Route::get('oauth/authorize', '\Laravel\Passport\Http\Controllers\AuthorizationController@authorize')->middleware('auth:api');
|
||||||
Route::delete('oauth/authorize', '\Laravel\Passport\Http\Controllers\DenyAuthorizationController@deny')->middleware('auth:api');
|
Route::delete('oauth/authorize', '\Laravel\Passport\Http\Controllers\DenyAuthorizationController@deny')->middleware('auth:api');
|
||||||
Route::post('oauth/authorize', '\Laravel\Passport\Http\Controllers\ApproveAuthorizationController@approve')->middleware('auth:api');
|
Route::post('oauth/authorize', '\Laravel\Passport\Http\Controllers\ApproveAuthorizationController@approve')->middleware('auth:api');
|
||||||
@@ -51,19 +51,19 @@ Route::delete('oauth/tokens/{token_id}', '\Laravel\Passport\Http\Controllers\Aut
|
|||||||
| Allows vue router to pick up all other URL's.
|
| Allows vue router to pick up all other URL's.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
Route::get('/test',function(){
|
Route::get('/test', function () {
|
||||||
return view('home');
|
return view('home');
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
// Route::get('Show/Package/{Package}', 'PackageController@show');
|
// Route::get('Show/Package/{Package}', 'PackageController@show');
|
||||||
Route::get('/',function(){
|
Route::get('/', function () {
|
||||||
return view('showMaster');
|
return view('showMaster');
|
||||||
});
|
});
|
||||||
Route::get('/Show/{any?}/{any2?}',function(){
|
Route::get('/Show/{any?}/{any2?}', function () {
|
||||||
return view('showMaster');
|
return view('showMaster');
|
||||||
});
|
});
|
||||||
Route::get('Landingpage',function(){
|
Route::get('Landingpage', function () {
|
||||||
return view('Landingpage');
|
return view('Landingpage');
|
||||||
});
|
});
|
||||||
Route::get('ShowTestResult/{id}', 'TestResultController@showTestResult');
|
Route::get('ShowTestResult/{id}', 'TestResultController@showTestResult');
|
||||||
@@ -74,6 +74,6 @@ Route::get('ShowCycle/{Cycle}', 'CycleController@showCycle');
|
|||||||
Route::post('/BarCode/{Code}/{Type?}', 'BarCodeController@generateBarcode');
|
Route::post('/BarCode/{Code}/{Type?}', 'BarCodeController@generateBarcode');
|
||||||
Route::post('Package/QRCode/{Package}', 'BarCodeController@generatePackageQRCode');
|
Route::post('Package/QRCode/{Package}', 'BarCodeController@generatePackageQRCode');
|
||||||
|
|
||||||
Route::any('{all}', function(){
|
Route::any('{all}', function () {
|
||||||
return view('welcome');
|
return view('welcome');
|
||||||
})->where(['all' => '.*']);
|
})->where(['all' => '.*']);
|
||||||
|
|||||||
Reference in New Issue
Block a user