diff --git a/app/FakeModel.php b/app/FakeModel.php new file mode 100644 index 00000000..58636eea --- /dev/null +++ b/app/FakeModel.php @@ -0,0 +1,16 @@ +user(); - - $Items = Item::when( $user->cant( 'showAll' , Item::class ) , function ( $query ) use ( $user ) { - if ( $user->hasRole( 'Supervisor' ) or $user->hasRole( 'User' ) ) { - $query->whereHas( 'user' , function ( $query ) use ( $user ) { - $query->where( 'medical_center_id' , $user->medical_center_id ); - } ); - } + $Items = Item::when( $request->has( 'name' ) && $request->name != '' , function ( $query ) use ( $request ) { + $query->where( 'name' , 'LIKE' , '%' . $request->name . '%' ); } ) - ->when( $request->has( 'name' ) && $request->name != '' , function ( $query ) use ( $request ) { - $query->where( 'name' , 'LIKE' , '%' . $request->name . '%' ); - } ) ->when( $request->has( 'udi' ) && $request->udi != '' , function ( $query ) use ( $request ) { $query->where( 'udi' , 'LIKE' , '%' . $request->udi . '%' ); } ) @@ -41,52 +33,114 @@ class ItemController extends Controller $query->where( 'medical_center_id' , $request->medical_center_id ); } ); } ) - ->with( [ 'user' => function ( $query ) { - $query->select( 'id' , 'name' , 'medical_center_id' ); - } , + ->with( [ + 'user' , + 'package' , 'user.medical_center' => function ( $query ) { - $query->select( 'id' , 'name' ); - } - ] ) - ->orderByDesc( 'id' ) - ->paginate( 10 ); - return \MessageResponse::data( $Items ); + $query->select( 'id' , 'name' , 'address' , 'phone_number' ); + } , + ] ); + + $user = auth( 'api' )->user(); + if ( $user->hasRole( 'User' ) ) { + $Items = $Items->whereHas( 'user' , function ( $query ) use ( $user ) { + $query->where( 'medical_center_id' , $user->medical_center_id ); + } )->where( "status" , 1 ); + } elseif ( $user->hasRole( 'Supervisor' ) ) { + $Items = $Items->whereHas( 'user' , function ( $query ) use ( $user ) { + $query->where( 'medical_center_id' , $user->medical_center_id ); + } ); + } + + $Items = $Items->orderByDesc( 'id' )->paginate( 10 ); + + return ItemResource::collection( $Items ); } - public function create() + public function myItems( Request $request ) { + $Items = Item::when( $request->has( 'name' ) && $request->name != '' , function ( $query ) use ( $request ) { + $query->where( 'name' , 'LIKE' , '%' . $request->name . '%' ); + } ) + ->when( $request->has( 'udi' ) && $request->udi != '' , function ( $query ) use ( $request ) { + $query->where( 'udi' , 'LIKE' , '%' . $request->udi . '%' ); + } ) + ->when( $request->has( 'size' ) && $request->size != '' , function ( $query ) use ( $request ) { + $query->where( 'size' , $request->size ); + } ) + ->when( $request->has( 'item_id' ) && $request->item_id != '' , function ( $query ) use ( $request ) { + $query->where( 'id' , $request->item_id ); + } ) + ->when( $request->has( 'specific' ) && $request->specific != '' , function ( $query ) use ( $request ) { + $query->where( 'specific' , $request->specific ); + } ) + ->with( [ + 'user' , + 'package' , + 'user.medical_center' => function ( $query ) { + $query->select( 'id' , 'name' , 'address' , 'phone_number' ); + } , + "transfers" => function ( $query ) { + $query->with( [ + 'user' => function ( $query ) { + $query->select( 'id' , 'name' , 'cell_number' ); + } , + 'user.medical_center' => function ( $query ) { + $query->select( 'id' , 'name' , 'address' , 'phone_number' ); + } + ] ); + } + ] ); + $user = auth( 'api' )->user(); + if ( $user->hasRole( 'User' ) ) { + $Items = $Items->where( "user_id" , $user->id ); + } elseif ( $user->hasRole( 'Supervisor' ) ) { + $Items = $Items->whereHas( 'user' , function ( $query ) use ( $user ) { + $query->where( 'medical_center_id' , $user->medical_center_id ); + } ); + } + + $Items = $Items->orderByDesc( 'id' )->paginate( 10 ); + + return ItemResource::collection( $Items ); + } + + public function getItems() + { + $Items = Item::where( "status" , 1 ) + ->where( "package_id" , null ) + ->orderByDesc( 'id' ) + ->get(); + return ItemResource::collection( $Items ); } public function show( Item $Item ) { - $Item->load( [ 'user' => function ( $query ) { - $query->select( 'id' , 'name' , 'medical_center_id' ); - } , + $Item->load( [ + 'user' , + 'package' , 'user.medical_center' => function ( $query ) { - $query->select( 'id' , 'name' ); + $query->select( 'id' , 'name' , 'address' , 'phone_number' ); } , "transfers" => function ( $query ) { - $query->with( [ 'user' => function ( $query ) { - $query->select( 'id' , 'name' , 'cell_number' , 'medical_center_id' ); - } ] ); + $query->with( [ + 'user' => function ( $query ) { + $query->select( 'id' , 'name' , 'cell_number' ); + } , + 'user.medical_center' => function ( $query ) { + $query->select( 'id' , 'name' , 'address' , 'phone_number' ); + } + ] ); } ] ); - $FilesPath = []; - if ( count( $Item->files ) ) { - foreach ( $Item->files as $Key => $File ) { - $FilesPath[] = $File->path; - } - $Item[ 'filesPath' ] = $FilesPath; - } - - return \MessageResponse::data( $Item ); + return ItemResource::make( $Item ); } public function store( StoreItemRequest $request ) { - $ItemData = [ + $Item = Item::create( [ 'name' => $request->name , 'size' => $request->size , 'unique_id' => $request->unique_id , @@ -94,122 +148,59 @@ class ItemController extends Controller 'note' => $request->note , 'udi' => $request->udi , 'user_id' => auth( 'api' )->user()->id , - ]; - $ItemObj = Item::create( $ItemData ); + 'creator_id' => auth( 'api' )->user()->id + ] ); - ///////////////////////////////////////////////////////////////////////////Images - $Images = Media::whereNull( 'model_id' )->where( 'batch_id' , $request->file_batch_id )->get(); - if ( $Images ) { - foreach ( $Images as $Image ) { - $NewPath = 'media' . '/Items' . '/' . $ItemObj->id . '/' . $Image->file_name; - Storage::disk( 'public' )->makeDirectory( 'Items' . '/' . $ItemObj->id ); - if ( \File::exists( public_path( $Image->path ) ) ) { - \File::move( public_path( $Image->path ) , public_path( $NewPath ) ); - } - $Image->model_id = $ItemObj->id; - $Image->path = $NewPath; - $Image->save(); - } - } - ///////////////////////////////////////////////////////////////////////////Images + MediaHelper::moveMediaTo( $Item ); - return \MessageResponse::success( trans( 'messages.success' ) ); + return MessageResponse::success( trans( 'messages.success' ) ); } public function edit( Item $Item ) { - $FilesPath = []; - if ( count( $Item->files ) ) { - foreach ( $Item->files as $Key => $file ) { - $FilesPath[] = $file; - } - $Item[ 'filesPath' ] = $FilesPath; - } else { - $Item[ 'filesPath' ] = []; - } - return \MessageResponse::data( $Item ); + return ItemResource::make( $Item ); } public function update( StoreItemRequest $request , Item $Item ) { - $Item->update( $request->all() ); - return \MessageResponse::success( trans( 'messages.success' ) ); + $Item->update( [ + 'name' => $request->name , + 'size' => $request->size , + 'unique_id' => $request->unique_id , + 'specific' => $request->specific , + 'note' => $request->note , + 'udi' => $request->udi + ] ); + MediaHelper::moveMediaTo( $Item ); + return MessageResponse::success( trans( 'messages.success' ) ); } public function destroy( Item $Item ) { if ( ! auth( 'api' )->user()->can( 'delete' , $Item ) ) { - return \MessageResponse::error( trans( 'messages.access_denied' ) ); - } - if ( count( $Item->packages ) ) { - $Item->packages()->detach(); + return MessageResponse::error( trans( 'messages.access_denied' ) ); } $Item->delete(); - return \MessageResponse::success( trans( 'messages.success' ) ); - } - - public function getItems() - { - $user = auth( 'api' )->user(); - - $Items = Item::when( $user->cant( 'showAll' , Item::class ) , function ( $query ) use ( $user ) { - if ( $user->hasRole( 'Supervisor' ) or $user->hasRole( 'User' ) ) { - $query->whereHas( 'user' , function ( $query ) use ( $user ) { - $query->where( 'medical_center_id' , $user->medical_center_id ); - } ); - } - } ) - ->with( [ 'user' => function ( $query ) { - $query->select( 'id' , 'name' , 'medical_center_id' ); - } , - 'user.medical_center' => function ( $query ) { - $query->select( 'id' , 'name' ); - } , - "transfers" => function ( $query ) { - $query->with( [ 'user' => function ( $query ) { - $query->select( 'id' , 'name' , 'cell_number' , 'medical_center_id' ); - } ] ); - } - ] ) - ->orderByDesc( 'id' ) - ->get(); - return \MessageResponse::data( $Items ); - } - - public function showItem( Item $Item ) - { - $Item->load( [ 'user' => function ( $query ) { - $query->select( 'id' , 'name' , 'medical_center_id' ); - } , - 'user.medical_center' => function ( $query ) { - $query->select( 'id' , 'name' ); - } , - "transfers" => function ( $query ) { - $query->with( [ 'user' => function ( $query ) { - $query->select( 'id' , 'name' , 'cell_number' , 'medical_center_id' ); - } ] ); - } - ] ); - return \MessageResponse::data( $Item ); + return MessageResponse::success( trans( 'messages.success' ) ); } public function changeStatus( Item $Item ) { if ( auth( 'api' )->user()->cant( 'changeStatus' , Item::class ) ) { - return \MessageResponse::error( trans( 'messages.access_denied' ) ); + return MessageResponse::error( trans( 'messages.access_denied' ) ); } $Item->status = ! $Item->status; $Item->save(); - return \MessageResponse::data( $Item ); + return ItemResource::make( $Item ); } public function changeRepair( Item $Item ) { if ( auth( 'api' )->user()->cant( 'changeRepair' , Item::class ) ) { - return \MessageResponse::error( trans( 'messages.access_denied' ) ); + return MessageResponse::error( trans( 'messages.access_denied' ) ); } $Item->repair = ! $Item->repair; $Item->save(); - return \MessageResponse::data( $Item ); + return ItemResource::make( $Item ); } } diff --git a/app/Http/Controllers/Media/DestroyMedia.php b/app/Http/Controllers/Media/DestroyMedia.php new file mode 100644 index 00000000..7bbb092e --- /dev/null +++ b/app/Http/Controllers/Media/DestroyMedia.php @@ -0,0 +1,16 @@ +delete(); + return MessageResponse::success( null , trans( 'messages.success' ) ); + } +} diff --git a/app/Http/Controllers/Media/StoreMedia.php b/app/Http/Controllers/Media/StoreMedia.php new file mode 100644 index 00000000..9231ebf9 --- /dev/null +++ b/app/Http/Controllers/Media/StoreMedia.php @@ -0,0 +1,33 @@ +validate($request, [ + 'batch_id' => 'required|max:40', + 'file' => 'required|mimes:jpeg,jpg,bmp,png,pdf' + ], [ + 'required' => trans('validations.required'), + 'max' => trans('validations.max', ['number' => 255]), + 'mimes' => trans('validations.mimes', ['types' => 'jpeg,jpg,bmp,png']), + ]); + $fakeModel = FakeModel::firstOrCreate(['batch_id' => $request->input('batch_id')]); + $media = $fakeModel->addMedia($request->file('file'))->toMediaCollection('temp_medias'); + + return response()->json( + Responser::success( + 'فایل با موفقیت بارگزاری گردید', + null, + ['id' => $media->id, 'url' => $media->getUrl()] + ) + ); + } +} diff --git a/app/Http/Controllers/PackageController.php b/app/Http/Controllers/PackageController.php index 11e17600..b7817afc 100644 --- a/app/Http/Controllers/PackageController.php +++ b/app/Http/Controllers/PackageController.php @@ -3,27 +3,19 @@ namespace App\Http\Controllers; use App\Http\Requests\StorePackageRequest; +use App\Http\Resources\PackageResource; use App\Item; use App\Package; use Illuminate\Http\Request; -use Illuminate\Support\Facades\DB; +use Packages\Messaging\src\Facades\MessageResponse; class PackageController extends Controller { public function index( Request $request ) { - $user = auth( 'api' )->user(); - - $Packages = Package::when( $user->cant( 'showAll' , Package::class ) , function ( $query ) use ( $user ) { - if ( $user->hasRole( 'Supervisor' ) or $user->hasRole( 'User' ) ) { - $query->whereHas( 'user' , function ( $query ) use ( $user ) { - $query->where( 'medical_center_id' , $user->medical_center_id ); - } ); - } + $Packages = Package::when( $request->has( 'name' ) && $request->name != '' , function ( $query ) use ( $request ) { + $query->where( 'name' , 'LIKE' , '%' . $request->name . '%' ); } ) - ->when( $request->has( 'name' ) && $request->name != '' , function ( $query ) use ( $request ) { - $query->where( 'name' , 'LIKE' , '%' . $request->name . '%' ); - } ) ->when( $request->has( 'package_id' ) && $request->package_id != '' , function ( $query ) use ( $request ) { $query->where( 'id' , $request->package_id ); } ) @@ -32,38 +24,94 @@ class PackageController extends Controller $query->where( 'medical_center_id' , $request->medical_center_id ); } ); } ) - ->with( [ 'user' => function ( $query ) { - $query->select( 'id' , 'name' , 'medical_center_id' ); - } , + ->with( [ + 'user' , 'user.medical_center' => function ( $query ) { - $query->select( 'id' , 'name' ); - } ] ) - ->orderByDesc( 'id' ) - ->paginate( 10 ); + $query->select( 'id' , 'name' , 'address' , 'phone_number' ); + } , + ] ); - return \MessageResponse::data( $Packages ); + $user = auth( 'api' )->user(); + if ( $user->hasRole( 'User' ) or $user->hasRole( 'Supervisor' ) ) { + $Packages = $Packages->whereHas( 'user' , function ( $query ) use ( $user ) { + $query->where( 'medical_center_id' , $user->medical_center_id ); + } ); + } + + $Packages = $Packages->orderByDesc( 'id' )->paginate( 10 ); + + return PackageResource::collection( $Packages ); } - public function create() + public function myPackages( Request $request ) { + $Packages = Package::when( $request->has( 'name' ) && $request->name != '' , function ( $query ) use ( $request ) { + $query->where( 'name' , 'LIKE' , '%' . $request->name . '%' ); + } ) + ->when( $request->has( 'package_id' ) && $request->package_id != '' , function ( $query ) use ( $request ) { + $query->where( 'id' , $request->package_id ); + } ) + ->when( $request->has( 'medical_center_id' ) && $request->medical_center_id != '' && $request->medical_center_id != 'undefined' , function ( $query ) use ( $request ) { + $query->whereHas( 'user' , function ( $query ) use ( $request ) { + $query->where( 'medical_center_id' , $request->medical_center_id ); + } ); + } ) + ->with( [ + 'user' , + 'user.medical_center' => function ( $query ) { + $query->select( 'id' , 'name' , 'address' , 'phone_number' ); + } , + "transfers" => function ( $query ) { + $query->with( [ + 'user' => function ( $query ) { + $query->select( 'id' , 'name' , 'cell_number' ); + } , + 'user.medical_center' => function ( $query ) { + $query->select( 'id' , 'name' , 'address' , 'phone_number' ); + } + ] ); + } + ] ); + + $user = auth( 'api' )->user(); + if ( $user->hasRole( 'User' ) ) { + $Packages = $Packages->where( "user_id" , $user->id ); + } elseif ( $user->hasRole( 'Supervisor' ) ) { + $Packages = $Packages->whereHas( 'user' , function ( $query ) use ( $user ) { + $query->where( 'medical_center_id' , $user->medical_center_id ); + } ); + } + + $Packages = $Packages->orderByDesc( 'id' )->get(); + + return PackageResource::collection( $Packages ); + } + + public function getPackages() + { + $Packages = Package::orderByDesc( 'id' )->get(); + return PackageResource::collection( $Packages ); } public function show( Package $Package ) { - $Package->load( [ 'user' => function ( $query ) { - $query->select( 'id' , 'name' , 'medical_center_id' ); - } , + $Package->load( [ + 'user' , 'user.medical_center' => function ( $query ) { - $query->select( 'id' , 'name' ); + $query->select( 'id' , 'name' , 'address' , 'phone_number' ); } , - 'items' , "transfers" => function ( $query ) { - $query->with( [ 'user' => function ( $query ) { - $query->select( 'id' , 'name' , 'cell_number' , 'medical_center_id' ); - } ] ); + $query->with( [ + 'user' => function ( $query ) { + $query->select( 'id' , 'name' , 'cell_number' ); + } , + 'user.medical_center' => function ( $query ) { + $query->select( 'id' , 'name' , 'address' , 'phone_number' ); + } + ] ); } ] ); - return \MessageResponse::data( $Package ); + return PackageResource::make( $Package ); } public function store( StorePackageRequest $request ) @@ -71,129 +119,63 @@ class PackageController extends Controller $PackageData = [ 'name' => $request->name , 'note' => $request->note , - 'user_id' => auth( 'api' )->user()->id , 'verified' => 'NotVerified' , + 'user_id' => auth( 'api' )->user()->id , + 'creator_id' => auth( 'api' )->user()->id ]; - $PackageObj = Package::create( $PackageData ); + $Package = Package::create( $PackageData ); foreach ( $request->items as $itemId ) { $item = Item::where( "id" , $itemId )->first(); if ( $item ) { - $item->packages()->detach(); - $PackageObj->items()->attach( $item->id , [ 'count' => 1 ] ); + $item->update( [ + "package_id" => $Package->id + ] ); } } - return \MessageResponse::success( trans( 'messages.success' ) ); + return MessageResponse::success( trans( 'messages.success' ) ); } public function edit( Package $Package ) { - $Items = []; $Package->load( 'items' ); - foreach ( $Package->items as $item ) { - for ( $i = 0 ; $i < $item->pivot->count ; $i++ ) { - $Items[] = (object) array( 'id' => $item->id , 'name' => $item->name ); - } - } - unset( $Package->items ); - $Package->items = $Items; - return \MessageResponse::data( $Package ); + return PackageResource::make( $Package ); } public function update( StorePackageRequest $request , Package $Package ) { $Package->update( $request->except( [ 'items' ] ) ); - $Items = []; - $count = 1; - foreach ( $request->items as $key => $item ) { - $itemOld = $Package->items()->where("item_id",$item[ 'id' ])->first(); - if ( $itemOld ) { - $Items[ $item[ 'id' ] ] = $itemOld->pivot->count + 1; - } else { - $Items[ $item[ 'id' ] ] = $count; - } - } - $Package->items()->detach(); - foreach ( $Items as $Item => $Count ) { - $item = Item::where( "id" , array( $Item ) )->first(); + foreach ( $request->items as $itemId ) { + $item = Item::where( "id" , $itemId )->first(); if ( $item ) { - $item->packages()->detach(); - $Package->items()->attach( array( $item->id ) , [ 'count' => $Count ] ); + $item->update( [ + "package_id" => $Package->id + ] ); } } - return \MessageResponse::success( trans( 'messages.success' ) ); + return MessageResponse::success( trans( 'messages.success' ) ); } public function destroy( Package $Package ) { if ( auth( 'api' )->user()->cant( 'delete' , $Package ) ) { - return \MessageResponse::error( trans( 'messages.access_denied' ) ); + return MessageResponse::error( trans( 'messages.access_denied' ) ); } if ( count( $Package->items ) ) { - $Package->items()->detach(); + foreach ( $Package->items as $itemId ) { + $item = Item::where( "id" , $itemId )->first(); + if ( $item ) { + $item->update( [ + "package_id" => null + ] ); + } + } } if ( count( $Package->labels ) ) { $Package->labels()->delete(); } $Package->delete(); - return \MessageResponse::success( trans( 'messages.success' ) ); - } - - public function verifyPackage( Package $Package ) - { - if ( auth( 'api' )->user()->cant( 'verifyPackage' , $Package ) ) { - return \MessageResponse::error( trans( 'You dont have permission' ) ); - } - if ( $Package->verified == 'Verified' ) { - $Package->verified = 'NotVerified'; - } else { - $Package->verified = 'Verified'; - } - $Package->save(); - $Package = $Package->load( 'user' ); - return \MessageResponse::success( trans( 'messages.success' ) , null , $Package ); - } - - public function getPackages() - { - $user = auth( 'api' )->user(); - - $Packages = Package::when( $user->cant( 'showAll' , Package::class ) , function ( $query ) use ( $user ) { - if ( $user->hasRole( 'Supervisor' ) or $user->hasRole( 'User' ) ) { - $query->whereHas( 'user' , function ( $query ) use ( $user ) { - $query->where( 'medical_center_id' , $user->medical_center_id ); - } ); - } - } ) - ->with( [ 'user' => function ( $query ) { - $query->select( 'id' , 'name' , 'medical_center_id' ); - } , - 'user.medical_center' => function ( $query ) { - $query->select( 'id' , 'name' ); - } ] ) - ->orderByDesc( 'id' ) - ->get(); - - return \MessageResponse::data( $Packages ); - - } - - public function showPackage( Package $Package ) - { - $Package->load( [ 'user' => function ( $query ) { - $query->select( 'id' , 'name' , 'medical_center_id' ); - } , - 'user.medical_center' => function ( $query ) { - $query->select( 'id' , 'name' ); - } , - 'items' , - "transfers" => function ( $query ) { - $query->with( [ 'user' => function ( $query ) { - $query->select( 'id' , 'name' , 'cell_number' , 'medical_center_id' ); - } ] ); - } - ] ); - return \MessageResponse::data( $Package ); + return MessageResponse::success( trans( 'messages.success' ) ); } } diff --git a/app/Http/Controllers/TestResultController.php b/app/Http/Controllers/TestResultController.php index ce020006..00595f18 100644 --- a/app/Http/Controllers/TestResultController.php +++ b/app/Http/Controllers/TestResultController.php @@ -1,484 +1,442 @@ user(); - public function index( Request $request ) - { - $user = auth( 'api' )->user(); + if ( $user->hasRole( 'Supervisor|User' ) ) { + $medical_center_id = $user->medical_center_id; + } elseif ( $request->has( 'medicalCenter_id' ) && $request->medicalCenter_id != '' && $request->medicalCenter_id != 'undefined' ) { + $medical_center_id = $request->medicalCenter_id; + } else { + $medical_center_id = null; + } - if ( $user->hasRole( 'Supervisor|User' ) ) { - $medical_center_id = $user->medical_center_id; - } elseif ( $request->has( 'medicalCenter_id' ) && $request->medicalCenter_id != '' && $request->medicalCenter_id != 'undefined' ) { - $medical_center_id = $request->medicalCenter_id; - } else { - $medical_center_id = null; - } + if ( $user->hasRole( 'User' ) ) { + $user_name = $user->name; + } elseif ( $request->has( 'user_name' ) && $request->user_name ) { + $user_name = $request->user_name; + } else { + $user_name = null; + } - if ( $user->hasRole( 'User' ) ) { - $user_name = $user->name; - } elseif ( $request->has( 'user_name' ) && $request->user_name ) { - $user_name = $request->user_name; - } else { - $user_name = null; - } - - $TestResult = TestResult::when( $request->has( 'verified' ) , function ( $query ) use ( $request ) { - return $query->where( 'verified' , $request->verified )->orWhere('verified' , "None" ); + $TestResult = TestResult::when( $request->has( 'verified' ) , function ( $query ) use ( $request ) { + return $query->where( 'verified' , $request->verified )->orWhere( 'verified' , "None" ); + } ) + ->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' ); + $upTo = ( $request->upToPicker ) ? date( $request->upToPicker . ' 23:59:59' ) : date( 'Y-m-d' . ' 23:59:59' ); + return $query->whereBetween( 'created_at' , [ $from , $upTo ] ); } ) - ->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' ); - $upTo = ( $request->upToPicker ) ? date( $request->upToPicker . ' 23:59:59' ) : date( 'Y-m-d' . ' 23:59:59' ); - return $query->whereBetween( 'created_at' , [ $from , $upTo ] ); - } ) - ->when( $request->has( 'testType_id' ) && $request->testType_id , function ( $query ) use ( $request ) { - $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 ) { - if ( $request->device_label != 'undefined' ) { - $query->whereHas( 'input_values' , function ( $query ) use ( $request ) { - $query->whereHas( 'input' , function ( $query ) use ( $request ) { - $query->where( 'name' , $request->device_label ); - } )->where( 'value' , $request->device_id ); - } ); - } else { - $query->where( function ( $query ) use ( $request ) { - $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 ) { - $query->where( function ( $query ) use ( $request ) { - $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( 'testType_id' ) && $request->testType_id , function ( $query ) use ( $request ) { + $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 ) { + if ( $request->device_label != 'undefined' ) { $query->whereHas( 'input_values' , function ( $query ) use ( $request ) { $query->whereHas( 'input' , function ( $query ) use ( $request ) { $query->where( 'name' , $request->device_label ); - } ); + } )->where( 'value' , $request->device_id ); } ); - } ) - ->when( $user_name , function ( $query ) use ( $user_name ) { - $query->whereHas( 'user' , function ( $query ) use ( $user_name ) { - $query->where( 'name' , 'LIKE' , '%' . $user_name . '%' ); + } else { + $query->where( function ( $query ) use ( $request ) { + $query->where( 'id' , $request->device_id ); } ); - } ) - ->when( $medical_center_id , function ( $query ) use ( $medical_center_id ) { - $query->whereHas( 'user' , function ( $query ) use ( $medical_center_id ) { - $query->where( 'medical_center_id' , $medical_center_id ); - } ); - } ) - ->with( [ 'user' => function ( $query ) { - $query->select( 'id' , 'name' , 'medical_center_id' ); - } , - 'user.medical_center' => function ( $query ) { - $query->select( 'id' , 'name' ); - } , - 'test_type' => function ( $query ) { - $query->select( 'id' , 'name' ); - } ] ) - ->orderByDesc( 'id' )->paginate( 10 ); - - return \MessageResponse::data( $TestResult ); - } - - public function create() - { - // - } - - public function store( StoreTestResultRequest $request ) - { - try { - $return_value = \DB::transaction( function () use ( $request ) { - - $TestResult = [ - 'user_id' => auth( 'api' )->user()->id , - 'cycle_number' => $request->cycle_number , - 'date' => $request->date , - 'test_type_id' => $request->test_type_id , - 'result' => $request->result , - 'verified' => 'None' , - ]; - $TestResultObj = TestResult::create( $TestResult ); - $TestResultInfo = $request->all(); - - $Inputs = Input::with( 'options' , 'children' , 'children.options' )->whereNull( 'parent_id' )->where( 'test_type_id' , $request->test_type_id )->get(); - - ///////////////////////////////////////////////////////////////////////////Inputs - foreach ( $Inputs as $Input ) { - if ( $Input[ 'type' ] != 'Form' ) { - $Value = $TestResultInfo[ $Input->name . '_' . $Input->id ]; - if ( $Input[ 'type' ] == 'Checkbox' || $Input[ 'type' ] == 'Select' || $Input[ 'type' ] == 'Radiobutton' ) { - - foreach ( $Input->options as $Option ) {//--2 - 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 ] ); - } - if ( $Input[ 'type' ] == 'Radiobutton' && $Option->id == $Value ) { - $InputValueObj = InputValue::create( [ 'test_result_id' => $TestResultObj->id , 'input_id' => $Input->id , 'option_id' => $Option->id ] ); - } - } - - } else { - $InputValueObj = InputValue::create( [ 'test_result_id' => $TestResultObj->id , 'input_id' => $Input->id , 'value' => $Value ] ); - } - } else { - foreach ( $Input->children as $InputChild ) { - $Value = $TestResultInfo[ $InputChild->name . '_' . $InputChild->id ]; - - if ( $InputChild[ 'type' ] == 'Checkbox' || $InputChild[ 'type' ] == 'Select' || $InputChild[ 'type' ] == 'Radiobutton' ) { - - foreach ( $InputChild->options as $Option ) {//--2 - 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 ] ); - } - if ( $InputChild[ 'type' ] == 'Radiobutton' && $Option->id == $Value ) { - $InputValueObj = InputValue::create( [ 'test_result_id' => $TestResultObj->id , 'input_id' => $InputChild->id , 'option_id' => $Option->id ] ); - } - } - } else { - $InputValueObj = InputValue::create( [ 'test_result_id' => $TestResultObj->id , 'input_id' => $InputChild->id , 'value' => $Value ] ); - } - - } - - } - } - ///////////////////////////////////////////////////////////////////////////Inputs - ///////////////////////////////////////////////////////////////////////////Images - $Images = Media::whereNull( 'model_id' )->where( 'batch_id' , $request->file_batch_id )->get(); - if ( $Images ) { - foreach ( $Images as $Image ) { - $NewPath = 'media' . '/TestResults' . '/' . $TestResultObj->id . '/' . $Image->file_name; - Storage::disk( 'public' )->makeDirectory( 'TestResults' . '/' . $TestResultObj->id ); - if ( \File::exists( public_path( $Image->path ) ) ) { - \File::move( public_path( $Image->path ) , public_path( $NewPath ) ); - } - $Image->model_id = $TestResultObj->id; - $Image->path = $NewPath; - $Image->save(); - } - } - ///////////////////////////////////////////////////////////////////////////Images - - } ); - } catch ( \Exception $e ) { - return response()->json( $e->getMessage() , 441 ); - } - return \MessageResponse::success( null , trans( 'messages.create' ) ); - - } - - public function show( $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 = []; - foreach ( $TestResult->input_values as $value ) { - $input = $value->input; - - if ( $input->parent_id != null && $input->parent[ 'type' ] == 'Form' ) { - //----------------------------------------------------------------------FormType - 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(); - $options = []; - foreach ( $input_options as $input_option ) { - $options[] = $input_option->option->title; - $input_values[ $input->name ] = $options; - } - - $children[ $input->parent->name ] = $input_values; - $TestResult[ 'children' ] = $children; - } else { - - $children[ $input->parent->name ][ $input->name ] = $value->value; - $TestResult[ 'children' ] = $children; - } - //-----------------------------------------------------------------------FormType - } else { - //-----------------------------------------------------------------------Anothertype - 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(); - $options = []; - foreach ( $input_options as $input_option ) { - $options[] = $input_option->option->title; - } - - $values[ $input->name ] = $options; - $TestResult[ 'options' ] = $values; - } else { - $inputs[ $input->name ] = $value->value; - $TestResult[ 'inputs' ] = $inputs; - } - //-----------------------------------------------------------------------Anothertype } - } - - $FilesPath = []; - if ( count( $TestResult->files ) ) { - foreach ( $TestResult->files as $Key => $File ) { - $FilesPath[] = $File->path; - } - $TestResult[ 'filesPath' ] = $FilesPath; - } - $TestResult[ 'device_label' ] = $TestResult->test_type->device_label; - return \MessageResponse::data( $TestResult ); - } - - public function edit( TestResult $TestResult ) - { - foreach ( $TestResult->input_values as $key => $value ) { - $input = $value->input; - 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(); - if ( $input[ 'type' ] == 'Radiobutton' ) { - $TestResult[ $input->name . '_' . $input->id ] = $input_options[ 0 ]; - } else { - $TestResult[ $input->name . '_' . $input->id ] = $input_options; - } - } else { - $TestResult[ $input->name . '_' . $input->id ] = $value->value; - } - } - - $FilesPath = []; - - if ( count( $TestResult->files ) ) { - foreach ( $TestResult->files as $Key => $file ) { - $FilesPath[] = $file; - } - $TestResult[ 'filesPath' ] = $FilesPath; - } else { - $TestResult[ 'filesPath' ] = []; - } - - return \MessageResponse::data( $TestResult ); - } - - public static function storage_path( $path ) - { - if ( starts_with( $path , 'media/' ) ) { - $path = substr( $path , 6 ); - } - return $path; - } - - public function update( StoreTestResultRequest $request , TestResult $TestResult ) - { - $TestResultData = [ - 'cycle_number' => $request->cycle_number , - 'date' => $request->date , - 'test_type_id' => $request->test_type_id , - 'result' => $request->result , - // 'verified' => 'NotVerified', - ]; - $TestResult->update( $TestResultData ); - $TestResultInfo = $request->all(); - - $Inputs = Input::with( 'options' , 'children' , 'children.options' )->whereNull( 'parent_id' )->where( 'test_type_id' , $request->test_type_id )->get(); - - foreach ( $Inputs as $Input ) { - if ( $Input[ 'type' ] != 'Form' ) { - $Value = $TestResultInfo[ $Input->name . '_' . $Input->id ]; - 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(); - - foreach ( $Input->options as $Option ) {//--2 - 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 ] ); - } - if ( $Input[ 'type' ] == 'Radiobutton' && $Option->id == $Value ) { - $InputValueObj = InputValue::create( [ 'test_result_id' => $TestResult->id , 'input_id' => $Input->id , 'option_id' => $Option->id ] ); - } - } - } else { - $InputValueObj = InputValue::where( 'test_result_id' , $TestResult->id )->where( 'input_id' , $Input[ 'id' ] )->update( [ 'value' => $Value ] ); - } - } else { - foreach ( $Input->children as $InputChild ) { - - $Value = $TestResultInfo[ $InputChild->name . '_' . $InputChild->id ]; - - 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(); - - foreach ( $InputChild->options as $Option ) {//--2 - 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 ] ); - } - if ( $InputChild[ 'type' ] == 'Radiobutton' && $Option->id == $Value ) { - $InputValueObj = InputValue::create( [ 'test_result_id' => $TestResult->id , 'input_id' => $InputChild->id , 'option_id' => $Option->id ] ); - } - } - } else { - $InputValueObj = InputValue::where( 'test_result_id' , $TestResult->id )->where( 'input_id' , $InputChild[ 'id' ] )->update( [ 'value' => $Value ] ); - } - } - } - } - /////////////////////////////////////////////////////////////////////Images - return \MessageResponse::success( null , trans( 'messages.update' ) ); - } - - public function destroy( TestResult $TestResult ) - { - if ( ! auth( 'api' )->user()->can( 'delete' , $TestResult ) ) { - return \MessageResponse::error( trans( 'messages.access_denied' ) ); - } - if ( count( $TestResult->input_values ) ) { - InputValue::where( 'test_result_id' , $TestResult->id )->get()->each->delete(); - } - if ( count( $TestResult->files ) ) { - foreach ( $TestResult->files as $file ) { - Storage::disk( 'public' )->delete( static::storage_path( $file->path ) ); - Media::where( 'id' , $file->id )->delete(); - } - } - $TestResult->delete(); - return \MessageResponse::success( null , trans( 'messages.success' ) ); - } - - public function verifyTestResult( TestResult $TestResult , $Value ) - { - if ( auth( 'api' )->user()->cant( 'verifyTestResult' , $TestResult ) ) { - return \MessageResponse::error( trans( 'You dont have permission or this test result belongs to another medical center' ) ); - } - - $TestResult->verified = $Value; - $TestResult->save(); - $TestResult = $TestResult->load( 'user.medical_center' ); - return \MessageResponse::success( trans( 'messages.success' ) , null , $TestResult ); - } - - public function listFilterItems() - { - $user = auth( 'api' )->user(); - $MedicalCenter = MedicalCenter::when( ! $user->hasRole( 'Admin' ) , function ( $query ) use ( $user ) { - $query->where( 'id' , $user->medical_center_id ); - } )->select( 'name' , 'id' )->get()->toArray(); - - $TestType = TestType::select( 'name' , 'id' )->get()->toArray(); - return \MessageResponse::data( [ - 'MedicalCenters' => $MedicalCenter , - 'TestTypes' => $TestType - ] ); - } - - public function chart( Request $request ) - { - $user = auth( 'api' )->user(); - if ( $user->hasRole( 'User' ) ) { - $userId = $user->id; - } elseif ( $request->has( 'userId' ) && $request->userId ) { - $userId = $request->userId; - } else { - $userId = null; - } - if ( $user->hasRole( 'Admin' ) && $request->has( 'medicalCenterId' ) && $request->medicalCenterId ) { - $medicalCenterId = $request->medicalCenterId; - } else { - $medicalCenterId = $user->medical_center_id; - } - - - $TestResults = TestResult:: - when( $userId , function ( $query ) use ( $userId ) { - $query->where( 'user_id' , $userId ); } ) - ->when( $medicalCenterId , function ( $query ) use ( $medicalCenterId ) { - $query->whereHas( 'user' , function ( $query ) use ( $medicalCenterId ) { - $query->where( 'medical_center_id' , $medicalCenterId ); + ->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( '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 ) { + $query->whereHas( 'input_values' , function ( $query ) use ( $request ) { + $query->whereHas( 'input' , function ( $query ) use ( $request ) { + $query->where( 'name' , $request->device_label ); } ); - } ) - ->when( $request->has( 'testTypeId' ) && $request->testTypeId , function ( $query ) use ( $request ) { - $query->where( 'test_type_id' , $request->testTypeId ); - } ) - ->when( $request->has( 'result' ) && $request->result , function ( $query ) use ( $request ) { - $query->where( 'result' , $request->result ); - } ) - ->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' ); - $upTo = ( $request->upToPicker ) ? date( $request->upToPicker . ' 23:59:59' ) : date( 'Y-m-d' . ' 23:59:59' ); - return $query->whereBetween( 'created_at' , [ $from , $upTo ] ); - } ) - ->when( $request->has( 'verify' ) && $request->verify , function ( $query ) use ( $request ) { - $query->where( 'verified' , $request->verify ); - } )->select( 'result' )->get()->groupBy( 'result' ); - $AcceptCount = ( isset( $TestResults[ 'Accept' ] ) ) ? $TestResults[ 'Accept' ]->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 ] ] ); - } - - 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 ); - $options = []; - foreach ( $TestResult->input_values as $value ) { - $input = $value->input; - - if ( $input->parent_id != null && $input->parent[ 'type' ] == 'Form' ) { - //----------------------------------------------------------------------FormType - 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(); - $options = []; - foreach ( $input_options as $input_option ) { - $options[] = $input_option->option->title; - $input_values[ $input->name ] = $options; - } - - $children[ $input->parent->name ] = $input_values; - $TestResult[ 'children' ] = $children; - } else { - - $children[ $input->parent->name ][ $input->name ] = $value->value; - $TestResult[ 'children' ] = $children; - } - //-----------------------------------------------------------------------FormType - } else { - //-----------------------------------------------------------------------Anothertype - 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(); - $options = []; - foreach ( $input_options as $input_option ) { - $options[] = $input_option->option->title; - } - - $values[ $input->name ] = $options; - $TestResult[ 'options' ] = $values; - } else { - $inputs[ $input->name ] = $value->value; - $TestResult[ 'inputs' ] = $inputs; - } - //-----------------------------------------------------------------------Anothertype - } - } - - $FilesPath = []; - if ( count( $TestResult->files ) ) { - foreach ( $TestResult->files as $Key => $File ) { - $FilesPath[] = $File->path; - } - $TestResult[ 'filesPath' ] = $FilesPath; - } - - $TestResult[ 'device_label' ] = $TestResult->test_type->device_label; - return \MessageResponse::data( $TestResult ); - } + } ); + } ) + ->when( $user_name , function ( $query ) use ( $user_name ) { + $query->whereHas( 'user' , function ( $query ) use ( $user_name ) { + $query->where( 'name' , 'LIKE' , '%' . $user_name . '%' ); + } ); + } ) + ->when( $medical_center_id , function ( $query ) use ( $medical_center_id ) { + $query->whereHas( 'user' , function ( $query ) use ( $medical_center_id ) { + $query->where( 'medical_center_id' , $medical_center_id ); + } ); + } ) + ->with( [ + 'user' , + 'user.medical_center' => function ( $query ) { + $query->select( 'id' , 'name' , 'address' , 'phone_number' ); + } , + 'test_type' => function ( $query ) { + $query->select( 'id' , 'name' ); + } ] ) + ->orderByDesc( 'id' )->paginate( 10 ); + return TestResultResource::collection( $TestResult ); } + + public function store( StoreTestResultRequest $request ) + { + try { + DB::transaction( function () use ( $request ) { + + $TestResult = [ + 'user_id' => auth( 'api' )->user()->id , + 'cycle_number' => $request->cycle_number , + 'date' => $request->date , + 'test_type_id' => $request->test_type_id , + 'result' => $request->result , + 'verified' => 'None' , + ]; + $TestResultObj = TestResult::create( $TestResult ); + $TestResultInfo = $request->all(); + + $Inputs = Input::with( 'options' , 'children' , 'children.options' )->whereNull( 'parent_id' )->where( 'test_type_id' , $request->test_type_id )->get(); + + ///////////////////////////////////////////////////////////////////////////Inputs + foreach ( $Inputs as $Input ) { + if ( $Input[ 'type' ] != 'Form' ) { + $Value = $TestResultInfo[ $Input->name . '_' . $Input->id ]; + if ( $Input[ 'type' ] == 'Checkbox' || $Input[ 'type' ] == 'Select' || $Input[ 'type' ] == 'Radiobutton' ) { + + foreach ( $Input->options as $Option ) {//--2 + 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 ] ); + } + if ( $Input[ 'type' ] == 'Radiobutton' && $Option->id == $Value ) { + $InputValueObj = InputValue::create( [ 'test_result_id' => $TestResultObj->id , 'input_id' => $Input->id , 'option_id' => $Option->id ] ); + } + } + + } else { + $InputValueObj = InputValue::create( [ 'test_result_id' => $TestResultObj->id , 'input_id' => $Input->id , 'value' => $Value ] ); + } + } else { + foreach ( $Input->children as $InputChild ) { + $Value = $TestResultInfo[ $InputChild->name . '_' . $InputChild->id ]; + + if ( $InputChild[ 'type' ] == 'Checkbox' || $InputChild[ 'type' ] == 'Select' || $InputChild[ 'type' ] == 'Radiobutton' ) { + + foreach ( $InputChild->options as $Option ) {//--2 + 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 ] ); + } + if ( $InputChild[ 'type' ] == 'Radiobutton' && $Option->id == $Value ) { + $InputValueObj = InputValue::create( [ 'test_result_id' => $TestResultObj->id , 'input_id' => $InputChild->id , 'option_id' => $Option->id ] ); + } + } + } else { + $InputValueObj = InputValue::create( [ 'test_result_id' => $TestResultObj->id , 'input_id' => $InputChild->id , 'value' => $Value ] ); + } + + } + + } + } + ///////////////////////////////////////////////////////////////////////////Inputs + + MediaHelper::moveMediaTo( $TestResultObj ); + + } ); + } catch ( \Exception $e ) { + return response()->json( $e->getMessage() , 441 ); + } + return MessageResponse::success( null , trans( 'messages.create' ) ); + } + + public function show( $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 = []; + foreach ( $TestResult->input_values as $value ) { + $input = $value->input; + + if ( $input->parent_id != null && $input->parent[ 'type' ] == 'Form' ) { + //----------------------------------------------------------------------FormType + 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(); + $options = []; + foreach ( $input_options as $input_option ) { + $options[] = $input_option->option->title; + $input_values[ $input->name ] = $options; + } + + $children[ $input->parent->name ] = $input_values; + $TestResult[ 'children' ] = $children; + } else { + + $children[ $input->parent->name ][ $input->name ] = $value->value; + $TestResult[ 'children' ] = $children; + } + //-----------------------------------------------------------------------FormType + } else { + //-----------------------------------------------------------------------Anothertype + 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(); + $options = []; + foreach ( $input_options as $input_option ) { + $options[] = $input_option->option->title; + } + + $values[ $input->name ] = $options; + $TestResult[ 'options' ] = $values; + } else { + $inputs[ $input->name ] = $value->value; + $TestResult[ 'inputs' ] = $inputs; + } + //-----------------------------------------------------------------------Anothertype + } + } + + $TestResult[ 'device_label' ] = $TestResult->test_type->device_label; + + return TestResultResource::make( $TestResult ); + } + + public function edit( TestResult $TestResult ) + { + foreach ( $TestResult->input_values as $key => $value ) { + $input = $value->input; + 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(); + if ( $input[ 'type' ] == 'Radiobutton' ) { + $TestResult[ $input->name . '_' . $input->id ] = $input_options[ 0 ]; + } else { + $TestResult[ $input->name . '_' . $input->id ] = $input_options; + } + } else { + $TestResult[ $input->name . '_' . $input->id ] = $value->value; + } + } + + return TestResultResource::make( $TestResult ); + } + + public static function storage_path( $path ) + { + if ( starts_with( $path , 'media/' ) ) { + $path = substr( $path , 6 ); + } + return $path; + } + + public function update( StoreTestResultRequest $request , TestResult $TestResult ) + { + $TestResultData = [ + 'cycle_number' => $request->cycle_number , + 'date' => $request->date , + 'test_type_id' => $request->test_type_id , + 'result' => $request->result , + // 'verified' => 'NotVerified', + ]; + $TestResult->update( $TestResultData ); + $TestResultInfo = $request->all(); + + $Inputs = Input::with( 'options' , 'children' , 'children.options' )->whereNull( 'parent_id' )->where( 'test_type_id' , $request->test_type_id )->get(); + + foreach ( $Inputs as $Input ) { + if ( $Input[ 'type' ] != 'Form' ) { + $Value = $TestResultInfo[ $Input->name . '_' . $Input->id ]; + 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(); + + foreach ( $Input->options as $Option ) {//--2 + 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 ] ); + } + if ( $Input[ 'type' ] == 'Radiobutton' && $Option->id == $Value ) { + $InputValueObj = InputValue::create( [ 'test_result_id' => $TestResult->id , 'input_id' => $Input->id , 'option_id' => $Option->id ] ); + } + } + } else { + $InputValueObj = InputValue::where( 'test_result_id' , $TestResult->id )->where( 'input_id' , $Input[ 'id' ] )->update( [ 'value' => $Value ] ); + } + } else { + foreach ( $Input->children as $InputChild ) { + + $Value = $TestResultInfo[ $InputChild->name . '_' . $InputChild->id ]; + + 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(); + + foreach ( $InputChild->options as $Option ) {//--2 + 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 ] ); + } + if ( $InputChild[ 'type' ] == 'Radiobutton' && $Option->id == $Value ) { + $InputValueObj = InputValue::create( [ 'test_result_id' => $TestResult->id , 'input_id' => $InputChild->id , 'option_id' => $Option->id ] ); + } + } + } else { + $InputValueObj = InputValue::where( 'test_result_id' , $TestResult->id )->where( 'input_id' , $InputChild[ 'id' ] )->update( [ 'value' => $Value ] ); + } + } + } + } + /////////////////////////////////////////////////////////////////////Images + + return MessageResponse::success( null , trans( 'messages.update' ) ); + } + + public function destroy( TestResult $TestResult ) + { + if ( ! auth( 'api' )->user()->can( 'delete' , $TestResult ) ) { + return MessageResponse::error( trans( 'messages.access_denied' ) ); + } + + if ( count( $TestResult->input_values ) ) { + InputValue::where( 'test_result_id' , $TestResult->id )->get()->each->delete(); + } + + $TestResult->delete(); + + return MessageResponse::success( null , trans( 'messages.success' ) ); + } + + public function verifyTestResult( TestResult $TestResult , $Value ) + { + if ( auth( 'api' )->user()->cant( 'verifyTestResult' , $TestResult ) ) { + return MessageResponse::error( trans( 'You dont have permission or this test result belongs to another medical center' ) ); + } + + $TestResult->verified = $Value; + $TestResult->save(); + $TestResult = $TestResult->load( 'user.medical_center' ); + return MessageResponse::success( trans( 'messages.success' ) , null , $TestResult ); + } + + public function listFilterItems() + { + $user = auth( 'api' )->user(); + $MedicalCenter = MedicalCenter::when( ! $user->hasRole( 'Admin' ) , function ( $query ) use ( $user ) { + $query->where( 'id' , $user->medical_center_id ); + } )->select( 'name' , 'id' )->get()->toArray(); + + $TestType = TestType::select( 'name' , 'id' )->get()->toArray(); + return MessageResponse::data( [ + 'MedicalCenters' => $MedicalCenter , + 'TestTypes' => $TestType + ] ); + } + + public function chart( Request $request ) + { + $user = auth( 'api' )->user(); + if ( $user->hasRole( 'User' ) ) { + $userId = $user->id; + } elseif ( $request->has( 'userId' ) && $request->userId ) { + $userId = $request->userId; + } else { + $userId = null; + } + if ( $user->hasRole( 'Admin' ) && $request->has( 'medicalCenterId' ) && $request->medicalCenterId ) { + $medicalCenterId = $request->medicalCenterId; + } else { + $medicalCenterId = $user->medical_center_id; + } + + + $TestResults = TestResult::when( $userId , function ( $query ) use ( $userId ) { + $query->where( 'user_id' , $userId ); + } ) + ->when( $medicalCenterId , function ( $query ) use ( $medicalCenterId ) { + $query->whereHas( 'user' , function ( $query ) use ( $medicalCenterId ) { + $query->where( 'medical_center_id' , $medicalCenterId ); + } ); + } ) + ->when( $request->has( 'testTypeId' ) && $request->testTypeId , function ( $query ) use ( $request ) { + $query->where( 'test_type_id' , $request->testTypeId ); + } ) + ->when( $request->has( 'result' ) && $request->result , function ( $query ) use ( $request ) { + $query->where( 'result' , $request->result ); + } ) + ->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' ); + $upTo = ( $request->upToPicker ) ? date( $request->upToPicker . ' 23:59:59' ) : date( 'Y-m-d' . ' 23:59:59' ); + return $query->whereBetween( 'created_at' , [ $from , $upTo ] ); + } ) + ->when( $request->has( 'verify' ) && $request->verify , function ( $query ) use ( $request ) { + $query->where( 'verified' , $request->verify ); + } )->select( 'result' )->get()->groupBy( 'result' ); + $AcceptCount = ( isset( $TestResults[ 'Accept' ] ) ) ? $TestResults[ 'Accept' ]->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 ] ] ); + } + + 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 ); + $options = []; + foreach ( $TestResult->input_values as $value ) { + $input = $value->input; + + if ( $input->parent_id != null && $input->parent[ 'type' ] == 'Form' ) { + //----------------------------------------------------------------------FormType + 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(); + $options = []; + foreach ( $input_options as $input_option ) { + $options[] = $input_option->option->title; + $input_values[ $input->name ] = $options; + } + + $children[ $input->parent->name ] = $input_values; + $TestResult[ 'children' ] = $children; + } else { + + $children[ $input->parent->name ][ $input->name ] = $value->value; + $TestResult[ 'children' ] = $children; + } + //-----------------------------------------------------------------------FormType + } else { + //-----------------------------------------------------------------------Anothertype + 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(); + $options = []; + foreach ( $input_options as $input_option ) { + $options[] = $input_option->option->title; + } + + $values[ $input->name ] = $options; + $TestResult[ 'options' ] = $values; + } else { + $inputs[ $input->name ] = $value->value; + $TestResult[ 'inputs' ] = $inputs; + } + //-----------------------------------------------------------------------Anothertype + } + } + + $TestResult[ 'device_label' ] = $TestResult->test_type->device_label; + return MessageResponse::data( $TestResult ); + } + +} diff --git a/app/Http/Controllers/TransferItemController.php b/app/Http/Controllers/TransferItemController.php index fbd76bff..304c4649 100644 --- a/app/Http/Controllers/TransferItemController.php +++ b/app/Http/Controllers/TransferItemController.php @@ -4,18 +4,38 @@ namespace App\Http\Controllers; use App\Http\Requests\StoreTransferChangeStatusRequest; use App\Http\Requests\StoreTransferRequest; +use App\Http\Resources\TransferResource; use App\Item; -use App\Policies\TransferItemPolicy; use App\Transfer; use Carbon\Carbon; -use Illuminate\Http\Request; +use Packages\Messaging\src\Facades\MessageResponse; class TransferItemController extends Controller { + public function getSuspendedTransfer() + { + $data = Transfer::where( "transferable_type" , "App\\Item" ) + ->where( "status" , "suspended" ) + ->with( [ "user" , "transferable" , "transferable.user" ] ); + + $user = auth( 'api' )->user(); + if ( $user->hasRole( 'User' ) ) { + $data = $data->where( "user_id" , $user->id ); + } elseif ( $user->hasRole( 'Supervisor' ) ) { + $data = $data->whereHas( 'transferable.user' , function ( $query ) use ( $user ) { + $query->where( 'medical_center_id' , $user->medical_center_id ); + } ); + } + + $data = $data->get(); + + return TransferResource::collection($data); + } + public function changeStatus( StoreTransferChangeStatusRequest $request , Transfer $Transfer ) { if ( auth( 'api' )->user()->cant( 'changeStatus' , [ Transfer::class , $Transfer ] ) ) { - return \MessageResponse::error( trans( 'messages.access_denied' ) ); + return MessageResponse::error( trans( 'messages.access_denied' ) ); } if ( $Transfer->status == "suspended" ) { if ( $request->status == "approved" ) { @@ -27,15 +47,15 @@ class TransferItemController extends Controller $Transfer->update( [ "status" => $request->status ] ); } } else { - return \MessageResponse::error( trans( 'messages.change_status_denied_transfer' ) ); + return MessageResponse::error( trans( 'messages.change_status_denied_transfer' ) ); } - return \MessageResponse::success( trans( 'messages.success' ) ); + return MessageResponse::success( trans( 'messages.success' ) ); } public function transfer( StoreTransferRequest $request , Item $Item ) { if ( auth( 'api' )->user()->cant( 'transferItem' , [ Transfer::class , $Item ] ) ) { - return \MessageResponse::error( trans( 'messages.access_denied' ) ); + return MessageResponse::error( trans( 'messages.access_denied' ) ); } if ( $Item->user_id != $request->user_id ) { $Item->transfers()->create( [ @@ -44,99 +64,8 @@ class TransferItemController extends Controller "status" => "suspended" ] ); } else { - return \MessageResponse::error( trans( 'messages.user_denied_transfer' ) ); + return MessageResponse::error( trans( 'messages.user_denied_transfer' ) ); } - return \MessageResponse::success( trans( 'messages.success' ) ); - } - - public function mySuspendedTransfer() - { - $data = Transfer::where( "transferable_type" , "App\\Item" )->where( "user_id" , auth()->id() )->where( "status" , "suspended" )->with( [ "transferable" ] )->get(); - return \MessageResponse::data( $data ); - } - - public function suspendedTransfer() - { - if ( auth( 'api' )->user()->cant( 'suspendedTransfer' , Transfer::class ) ) { - return \MessageResponse::error( trans( 'messages.access_denied' ) ); - } - $data = Transfer::where( "transferable_type" , "App\\Item" )->where( "status" , "suspended" )->with( [ "user" , "transferable" ] )->get(); - return \MessageResponse::data( $data ); - } - - public function items( Request $request ) - { - if ( auth( 'api' )->user()->cant( 'items' , [Transfer::class] ) ) { - return \MessageResponse::error( trans( 'messages.access_denied' ) ); - } - $user = auth()->user(); - $data = Item::whereHas( 'user' , function ( $query ) use ( $user ) { - $query->where( 'medical_center_id' , $user->medical_center_id ); - } ) - ->when( $request->has( 'name' ) && $request->name != '' , function ( $query ) use ( $request ) { - $query->where( 'name' , 'LIKE' , '%' . $request->name . '%' ); - } ) - ->when( $request->has( 'udi' ) && $request->udi != '' , function ( $query ) use ( $request ) { - $query->where( 'udi' , 'LIKE' , '%' . $request->udi . '%' ); - } ) - ->when( $request->has( 'size' ) && $request->size != '' , function ( $query ) use ( $request ) { - $query->where( 'size' , $request->size ); - } ) - ->when( $request->has( 'item_id' ) && $request->item_id != '' , function ( $query ) use ( $request ) { - $query->where( 'id' , $request->item_id ); - } ) - ->when( $request->has( 'specific' ) && $request->specific != '' , function ( $query ) use ( $request ) { - $query->where( 'specific' , $request->specific ); - } ) - ->with( [ 'user' => function ( $query ) { - $query->select( 'id' , 'name' , 'medical_center_id' ); - } , - 'user.medical_center' => function ( $query ) { - $query->select( 'id' , 'name' ); - } , - "transfers" => function ( $query ) { - $query->with( [ 'user' => function ( $query ) { - $query->select( 'id' , 'name' , 'medical_center_id' ); - } ] ); - } - ] ) - ->orderByDesc( 'id' ) - ->paginate( 10 ); - return \MessageResponse::data( $data ); - } - - public function myItems( Request $request ) - { - $data = Item::where( 'user_id' , auth()->id() ) - ->when( $request->has( 'name' ) && $request->name != '' , function ( $query ) use ( $request ) { - $query->where( 'name' , 'LIKE' , '%' . $request->name . '%' ); - } ) - ->when( $request->has( 'udi' ) && $request->udi != '' , function ( $query ) use ( $request ) { - $query->where( 'udi' , 'LIKE' , '%' . $request->udi . '%' ); - } ) - ->when( $request->has( 'size' ) && $request->size != '' , function ( $query ) use ( $request ) { - $query->where( 'size' , $request->size ); - } ) - ->when( $request->has( 'item_id' ) && $request->item_id != '' , function ( $query ) use ( $request ) { - $query->where( 'id' , $request->item_id ); - } ) - ->when( $request->has( 'specific' ) && $request->specific != '' , function ( $query ) use ( $request ) { - $query->where( 'specific' , $request->specific ); - } ) - ->with( [ 'user' => function ( $query ) { - $query->select( 'id' , 'name' , 'medical_center_id' ); - } , - 'user.medical_center' => function ( $query ) { - $query->select( 'id' , 'name' ); - } , - "transfers" => function ( $query ) { - $query->with( [ 'user' => function ( $query ) { - $query->select( 'id' , 'name' , 'medical_center_id' ); - } ] ); - } - ] ) - ->orderByDesc( 'id' ) - ->paginate( 10 ); - return \MessageResponse::data( $data ); + return MessageResponse::success( trans( 'messages.success' ) ); } } diff --git a/app/Http/Controllers/TransferPackageController.php b/app/Http/Controllers/TransferPackageController.php index 1e839bff..53b460f0 100644 --- a/app/Http/Controllers/TransferPackageController.php +++ b/app/Http/Controllers/TransferPackageController.php @@ -4,18 +4,38 @@ namespace App\Http\Controllers; use App\Http\Requests\StoreTransferChangeStatusRequest; use App\Http\Requests\StoreTransferRequest; +use App\Http\Resources\TransferResource; use App\Package; -use App\Policies\TransferPackagePolicy; use App\Transfer; use Carbon\Carbon; -use Illuminate\Http\Request; +use Packages\Messaging\src\Facades\MessageResponse; class TransferPackageController extends Controller { + public function getSuspendedTransfer() + { + $data = Transfer::where( "transferable_type" , "App\\Package" ) + ->where( "status" , "suspended" ) + ->with( [ "user" , "transferable" , "transferable.user" ] ); + + $user = auth( 'api' )->user(); + if ( $user->hasRole( 'User' ) ) { + $data = $data->where( "user_id" , $user->id ); + } elseif ( $user->hasRole( 'Supervisor' ) ) { + $data = $data->whereHas( 'transferable.user' , function ( $query ) use ( $user ) { + $query->where( 'medical_center_id' , $user->medical_center_id ); + } ); + } + + $data = $data->get(); + + return TransferResource::collection($data); + } + public function changeStatus( StoreTransferChangeStatusRequest $request , Transfer $Transfer ) { if ( auth( 'api' )->user()->cant( 'changeStatus' , [ Transfer::class , $Transfer ] ) ) { - return \MessageResponse::error( trans( 'messages.access_denied' ) ); + return MessageResponse::error( trans( 'messages.access_denied' ) ); } if ( $Transfer->status == "suspended" ) { if ( $request->status == "approved" ) { @@ -23,7 +43,6 @@ class TransferPackageController extends Controller if ( $package->transferActive ) $package->transferActive()->update( [ "to_date" => Carbon::now() ] ); $Transfer->update( [ "status" => $request->status ] ); $package->update( [ "user_id" => $Transfer->user_id ] ); - foreach ( $package->items as $item ) { $item->update( [ "user_id" => $Transfer->user_id ] ); } @@ -31,15 +50,15 @@ class TransferPackageController extends Controller $Transfer->update( [ "status" => $request->status ] ); } } else { - return \MessageResponse::error( trans( 'messages.change_status_denied_transfer' ) ); + return MessageResponse::error( trans( 'messages.change_status_denied_transfer' ) ); } - return \MessageResponse::success( trans( 'messages.success' ) ); + return MessageResponse::success( trans( 'messages.success' ) ); } public function transfer( StoreTransferRequest $request , Package $Package ) { if ( auth( 'api' )->user()->cant( 'transferPackage' , [ Transfer::class , $Package ] ) ) { - return \MessageResponse::error( trans( 'messages.access_denied' ) ); + return MessageResponse::error( trans( 'messages.access_denied' ) ); } if ( $Package->user_id != $request->user_id ) { $Package->transfers()->create( [ @@ -48,79 +67,8 @@ class TransferPackageController extends Controller "status" => "suspended" ] ); } else { - return \MessageResponse::error( trans( 'messages.user_denied_transfer' ) ); + return MessageResponse::error( trans( 'messages.user_denied_transfer' ) ); } - return \MessageResponse::success( trans( 'messages.success' ) ); - } - - public function mySuspendedTransfer() - { - $data = Transfer::where( "transferable_type" , "App\\Package" )->where( "user_id" , auth()->id() )->where( "status" , "suspended" )->with( [ "transferable" ] )->get(); - return \MessageResponse::data( $data ); - } - - public function suspendedTransfer() - { - if ( auth( 'api' )->user()->cant( 'suspendedTransfer' , Transfer::class ) ) { - return \MessageResponse::error( trans( 'messages.access_denied' ) ); - } - $data = Transfer::where( "transferable_type" , "App\\Package" )->where( "status" , "suspended" )->with( [ "user" , "transferable" ] )->get(); - return \MessageResponse::data( $data ); - } - - public function packages( Request $request ) - { - if ( auth( 'api' )->user()->cant( 'packages' , Transfer::class ) ) { - return \MessageResponse::error( trans( 'messages.access_denied' ) ); - } - $user = auth()->user(); - $data = Package::whereHas( 'user' , function ( $query ) use ( $user ) { - $query->where( 'medical_center_id' , $user->medical_center_id ); - } ) - ->when( $request->has( 'name' ) && $request->name != '' , function ( $query ) use ( $request ) { - $query->where( 'name' , 'LIKE' , '%' . $request->name . '%' ); - } ) - ->when( $request->has( 'package_id' ) && $request->package_id != '' , function ( $query ) use ( $request ) { - $query->where( 'id' , $request->package_id ); - } ) - ->when( $request->has( 'medical_center_id' ) && $request->medical_center_id != '' && $request->medical_center_id != 'undefined' , function ( $query ) use ( $request ) { - $query->whereHas( 'user' , function ( $query ) use ( $request ) { - $query->where( 'medical_center_id' , $request->medical_center_id ); - } ); - } ) - ->with( [ 'user' => function ( $query ) { - $query->select( 'id' , 'name' , 'medical_center_id' ); - } , - 'user.medical_center' => function ( $query ) { - $query->select( 'id' , 'name' ); - } ] ) - ->orderByDesc( 'id' ) - ->get(); - return \MessageResponse::data( $data ); - } - - public function myPackages( Request $request ) - { - $data = Package::where( 'user_id' , auth()->id() ) - ->when( $request->has( 'name' ) && $request->name != '' , function ( $query ) use ( $request ) { - $query->where( 'name' , 'LIKE' , '%' . $request->name . '%' ); - } ) - ->when( $request->has( 'package_id' ) && $request->package_id != '' , function ( $query ) use ( $request ) { - $query->where( 'id' , $request->package_id ); - } ) - ->when( $request->has( 'medical_center_id' ) && $request->medical_center_id != '' && $request->medical_center_id != 'undefined' , function ( $query ) use ( $request ) { - $query->whereHas( 'user' , function ( $query ) use ( $request ) { - $query->where( 'medical_center_id' , $request->medical_center_id ); - } ); - } ) - ->with( [ 'user' => function ( $query ) { - $query->select( 'id' , 'name' , 'medical_center_id' ); - } , - 'user.medical_center' => function ( $query ) { - $query->select( 'id' , 'name' ); - } ] ) - ->orderByDesc( 'id' ) - ->get(); - return \MessageResponse::data( $data ); + return MessageResponse::success( trans( 'messages.success' ) ); } } diff --git a/app/Http/Controllers/UploadController.php b/app/Http/Controllers/UploadController.php deleted file mode 100644 index f1c3e9e9..00000000 --- a/app/Http/Controllers/UploadController.php +++ /dev/null @@ -1,118 +0,0 @@ -file('file')->getMimeType(), 0, 12 ) == 'application/'){ - $FileType = 'document'; - } - - $modelType = Str::ucfirst($request->model_type); - if ($request->model_id !== null && is_numeric($request->model_id)) { - $Model = 'App\\'.$modelType; - $Object = $Model::findOrFail($request->model_id); - if ($Object) { - if($FileType == 'image'){ - $Image = $request->file('file'); - $Manager = new ImageManager(array('driver' => 'imagick')); - $InterventionImage = $Manager->make($Image); - $Mime = explode('/', $InterventionImage->mime()); - - $FileName = time().'.'.$Mime[1]; - $Path = 'media'.'/TestResults'.'/'.$Object->id .'/'.$FileName; - - Storage::disk('public')->makeDirectory('TestResults'.'/'.$Object->id); - $InterventionImage->save(public_path($Path)); - } - else if($FileType == 'document'){ - $UploadedFile = $request->file('file'); - $FileName = time().'_'.$request->file('file')->getClientOriginalName(); - $Path = 'media'.'/TestResults'.'/'.$Object->id; - Storage::disk('public')->makeDirectory('TestResults'.'/'.$Object->id); - $UploadedFile->move($Path, $FileName); - $Path = $Path . '/' . $FileName; - } - - $MediaData = [ - 'model_id' => $Object->id, - 'batch_id' => $request->batch_id, - 'model_type' => 'App\\'.$modelType, - 'path' => $Path, - 'user_id' => auth('api')->user()->id, - 'file_name' => $FileName, - 'file_type' => $FileType - ]; - $Media = Media::create($MediaData); - } - } - else { - if($FileType == 'image'){ - $Image = $request->file('file'); - $Manager = new ImageManager(array('driver' => 'imagick')); - $InterventionImage = $Manager->make($Image); - $Mime = explode('/', $InterventionImage->mime()); - - $FileName = time().'.'.$Mime[1]; - $Path = 'media'.'/Temp'.'/'.$request->batch_id .'/'.$FileName; - - Storage::disk('public')->makeDirectory('Temp'.'/'.$request->batch_id); - $InterventionImage->save(public_path($Path)); - } - else if($FileType == 'document'){ - $UploadedFile = $request->file('file'); - $FileName = time().'_'.$request->file('file')->getClientOriginalName(); - $Path = 'media'.'/Temp'.'/'.$request->batch_id; - Storage::disk('public')->makeDirectory('Temp'.'/'.$request->batch_id); - $UploadedFile->move($Path, $FileName); - $Path = $Path . '/' . $FileName; - } - - $MediaData = [ - 'model_id' => null, - 'batch_id' => $request->batch_id, - 'model_type' => 'App\\'.$modelType, - 'path' => $Path, - 'user_id' => auth('api')->user()->id, - 'file_name' => $FileName, - 'file_type' => $FileType - ]; - $Media = Media::create($MediaData); - } - return \MessageResponse::success(trans('messages.success_message'), null, $Media); - } - - public function deleteFile(Request $request) - { - if ($request->model_id != null && is_numeric($request->model_id)) { - $Media = Media::findOrFail($request->media_id); - if($Media){ - if (\File::exists(public_path($Media->path))) { - \File::delete(public_path($Media->path)); - } - $Media->delete(); - } - } - else { - $Media = Media::findOrFail($request->media_id); - if($Media){ - if(\File::exists(public_path($Media->path))){ - \File::delete(public_path($Media->path)); - } - $Media->delete(); - } - } - return \MessageResponse::success(trans('messages.success_message')); - } -} diff --git a/app/Http/Resources/ItemResource.php b/app/Http/Resources/ItemResource.php new file mode 100644 index 00000000..f93507a5 --- /dev/null +++ b/app/Http/Resources/ItemResource.php @@ -0,0 +1,39 @@ + $this->id, + 'name' => $this->name, + 'udi' => $this->udi, + 'size' => $this->size, + 'specific' => $this->specific, + 'repair' => $this->repair, + 'status' => $this->status, + 'creator_id' => $this->creator_id, + 'creator' => UserResource::make($this->whenLoaded('creator')), + 'user_id' => $this->user_id, + 'user' => UserResource::make($this->whenLoaded('user')), + 'package' => PackageResource::make($this->whenLoaded('package')), + 'transfers' => TransferResource::collection($this->whenLoaded('transfers')), + 'files' => MediaResource::collection($this->media), + 'thumbnail' => $this->getFirstMediaUrl('main_images', 'thumbnail'), + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at + ]; + } +} diff --git a/app/Http/Resources/MedicalCenterResource.php b/app/Http/Resources/MedicalCenterResource.php new file mode 100644 index 00000000..3e09d63b --- /dev/null +++ b/app/Http/Resources/MedicalCenterResource.php @@ -0,0 +1,29 @@ + $this->id , + 'name' => $this->name , + 'address' => $this->address , + 'phone_number' => $this->phone_number , + 'city' => $this->when( $this->city , $this->city ), + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at + ]; + } +} diff --git a/app/Http/Resources/PackageResource.php b/app/Http/Resources/PackageResource.php new file mode 100644 index 00000000..2b2a119a --- /dev/null +++ b/app/Http/Resources/PackageResource.php @@ -0,0 +1,34 @@ + $this->id, + 'name' => $this->name, + 'note' => $this->note, + 'verified' => $this->verified, + 'creator_id' => $this->creator_id, + 'creator' => UserResource::make($this->whenLoaded('creator')), + 'user_id' => $this->user_id, + 'user' => UserResource::make($this->whenLoaded('user')), + 'items' => ItemResource::collection($this->whenLoaded('items')), + 'transfers' => TransferResource::collection($this->whenLoaded('transfers')), + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at + ]; + } +} diff --git a/app/Http/Resources/TestResultResource.php b/app/Http/Resources/TestResultResource.php new file mode 100644 index 00000000..1dc5acfa --- /dev/null +++ b/app/Http/Resources/TestResultResource.php @@ -0,0 +1,42 @@ + $this->id , + 'info' => $this->info , + 'cycle_number' => $this->cycle_number , + 'date' => $this->date , + 'result' => $this->result , + 'description' => $this->description , + 'verified' => $this->verified , + 'device_id' => $this->device_id , + 'user_id' => $this->user_id , + 'test_type_id' => $this->test_type_id , + 'test_type' => $this->when( $this->test_type , $this->test_type ) , + 'inputs' => $this->when( $this->inputs , $this->inputs ) , + 'options' => $this->when( $this->options , $this->options ) , + 'device_label' => $this->when( $this->device_label , $this->device_label ) , + 'input_values' => $this->when( $this->input_values , $this->input_values ) , + 'user' => UserResource::make( $this->whenLoaded( 'user' ) ) , + 'files' => MediaResource::collection( $this->media ) , + 'thumbnail' => $this->getFirstMediaUrl( 'main_images' , 'thumbnail' ) , + 'created_at' => $this->created_at , + 'updated_at' => $this->updated_at + ]; + } +} diff --git a/app/Http/Resources/TransferResource.php b/app/Http/Resources/TransferResource.php new file mode 100644 index 00000000..7c48e898 --- /dev/null +++ b/app/Http/Resources/TransferResource.php @@ -0,0 +1,41 @@ + $this->id, + 'from_date' => $this->from_date, + 'to_date' => $this->to_date, + 'status' => $this->status, + 'user_id' => $this->user_id, + 'user' => UserResource::make($this->whenLoaded('user')), + 'transferable' => $this->resourceFinder(), + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at + ]; + } + + private function resourceFinder() + { + if ($this->whenLoaded('transferable')) { + if ($this->transferable_type == "App\\Package"){ + return PackageResource::make($this->transferable); + }elseif($this->transferable_type == "App\\Item"){ + return ItemResource::make($this->transferable); + } + } + } +} diff --git a/app/Http/Resources/UserResource.php b/app/Http/Resources/UserResource.php new file mode 100644 index 00000000..3d6a027c --- /dev/null +++ b/app/Http/Resources/UserResource.php @@ -0,0 +1,30 @@ + $this->id, + 'name' => $this->name, + 'email' => $this->email, + 'status' => $this->status, + 'address' => $this->address, + 'gender' => $this->gender, + 'medical_center' => MedicalCenterResource::make($this->whenLoaded('medical_center')), + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at + ]; + } +} diff --git a/app/Input.php b/app/Input.php index b60b2ef8..15dd2941 100644 --- a/app/Input.php +++ b/app/Input.php @@ -7,18 +7,22 @@ use Illuminate\Database\Eloquent\Model; class Input extends Model { public $fillable = ['name','type','size','test_type_id','parent_id','require_scanner']; + public function test_type() { return $this->belongsTo('App\TestType'); } + public function parent() { return $this->belongsTo('App\Input', 'parent_id'); } + public function children() { return $this->hasMany('App\Input', 'parent_id'); } + public function options() { return $this->hasMany('App\Option'); diff --git a/app/Item.php b/app/Item.php index 8ad9d58d..d0c698be 100644 --- a/app/Item.php +++ b/app/Item.php @@ -1,35 +1,56 @@ belongsToMany( 'App\Package' , 'item_package' )->withPivot( 'count' ); - } - - public function user() - { - return $this->belongsTo( 'App\User' ); - } - - public function files() - { - return $this->morphMany( 'App\Media' , 'model' ); - } - - public function transfers() - { - return $this->morphMany( 'App\Transfer' , "transferable" )->where( "status" ,"approved" ); - } - - public function transferActive() - { - return $this->morphMany( 'App\Transfer' , "transferable" )->where( "status" ,"approved" )->whereNull( "to_date" ); - } + return $this->belongsTo( 'App\Package' ); } + + public function user() + { + return $this->belongsTo( 'App\User' ); + } + + public function creator() + { + return $this->belongsTo( 'App\User' , "creator_id" ); + } + + public function transfers() + { + return $this->morphMany( 'App\Transfer' , "transferable" )->where( "status" , "approved" ); + } + + public function transferActive() + { + return $this->morphMany( 'App\Transfer' , "transferable" )->where( "status" , "approved" )->whereNull( "to_date" ); + } + + public function registerMediaCollections() + { + $this->addMediaCollection( 'main_images' ) + ->useFallbackUrl( '/images/default_pastry.jpg' ) + ->useFallbackPath( public_path( '/images/default_pastry.jpg' ) ); + } + + public function registerMediaConversions( Media $media = null ): void + { + $this->addMediaConversion( 'thumbnail' ) + ->width( 480 ) + ->height( 640 ) + ->nonQueued() + ->performOnCollections( 'main_images' ); + } +} diff --git a/app/MedicalCenter.php b/app/MedicalCenter.php index e4c511f5..cce31edf 100644 --- a/app/MedicalCenter.php +++ b/app/MedicalCenter.php @@ -7,10 +7,12 @@ use Illuminate\Database\Eloquent\Model; class MedicalCenter extends Model { public $fillable = ['name', 'city_id', 'address', 'phone_number']; + public function users() { return $this->hasMany('App\User'); } + public function city() { return $this->belongsTo('App\City'); diff --git a/app/Package.php b/app/Package.php index 7eade699..5b6e5d9d 100644 --- a/app/Package.php +++ b/app/Package.php @@ -1,35 +1,35 @@ belongsTo( 'App\User' ); - } - - public function items() - { - return $this->belongsToMany( 'App\Item' , 'item_package' )->withPivot( 'count' ); - } - - public function labels() - { - return $this->hasMany( 'App\Label' ); - } - - public function transfers() - { - return $this->morphMany( 'App\Transfer' , "transferable" )->where( "status" ,"approved" ); - } - - public function transferActive() - { - return $this->morphMany( 'App\Transfer' , "transferable" )->where( "status" ,"approved" )->whereNull( "to_date" ); - } + return $this->belongsTo( 'App\User' ); } + + public function items() + { + return $this->hasMany( 'App\Item' ); + } + + public function labels() + { + return $this->hasMany( 'App\Label' ); + } + + public function transfers() + { + return $this->morphMany( 'App\Transfer' , "transferable" )->where( "status" , "approved" ); + } + + public function transferActive() + { + return $this->morphMany( 'App\Transfer' , "transferable" )->where( "status" , "approved" )->whereNull( "to_date" ); + } +} diff --git a/app/Policies/ItemPolicy.php b/app/Policies/ItemPolicy.php index fd81a6ee..22b771ee 100644 --- a/app/Policies/ItemPolicy.php +++ b/app/Policies/ItemPolicy.php @@ -7,38 +7,44 @@ use App\Item; class ItemPolicy { - public function showAll(User $User) + public function showAll( User $User ) { - if($User->hasRole('Admin')) - return true; - } - public function delete(User $User, Item $Item) - { - if($User->hasRole('Admin') || ($User->hasRole('Supervisor') && $Item->user->medical_center_id == $User->medical_center_id)) + if ( $User->hasRole( 'Admin' ) ) return true; } - public function update(User $User, Item $Item) + public function delete( User $User , Item $Item ) { - if($User->hasRole('Admin') || ($User->hasRole('Supervisor') && $Item->user->medical_center_id == $User->medical_center_id)) + if ( $User->hasRole( 'Admin' ) ) { + return true; + } elseif ( $User->hasRole( 'Supervisor' ) ) { + if ($Item->status == 0){ + return true; + } + } + } + + public function update( User $User , Item $Item ) + { + if ( $User->hasRole( 'Admin' ) || ( $User->hasRole( 'Supervisor' ) && $Item->user->medical_center_id == $User->medical_center_id ) ) return true; } - public function store(User $User) + public function store( User $User ) { - if($User->hasRole('Admin') || $User->hasRole('Supervisor')) + if ( $User->hasRole( 'Admin' ) || $User->hasRole( 'Supervisor' ) ) return true; } - public function changeStatus(User $User) + public function changeStatus( User $User ) { - if($User->hasRole('Admin|Supervisor')) + if ( $User->hasRole( 'Admin|Supervisor' ) ) return true; } - public function changeRepair(User $User) + public function changeRepair( User $User ) { - if($User->hasRole('Admin|Supervisor')) + if ( $User->hasRole( 'Admin|Supervisor' ) ) return true; } } diff --git a/app/Policies/PackagePolicy.php b/app/Policies/PackagePolicy.php index b1bce8d7..d632346a 100644 --- a/app/Policies/PackagePolicy.php +++ b/app/Policies/PackagePolicy.php @@ -13,6 +13,7 @@ class PackagePolicy if($User->hasRole('Admin')) return true; } + public function delete(User $User, Package $Package) { if($User->hasRole('Admin') || ($User->hasRole('Supervisor') && $Package->user->medical_center_id == $User->medical_center_id)) diff --git a/app/Policies/TransferPolicy.php b/app/Policies/TransferPolicy.php index 8d3b147e..63a1e2a6 100644 --- a/app/Policies/TransferPolicy.php +++ b/app/Policies/TransferPolicy.php @@ -15,38 +15,38 @@ class TransferPolicy return true; } - public function suspendedTransfer( User $User ) - { - if ( $User->hasRole( 'Admin|Supervisor' ) ) - return true; - } - - - //Item public function transferItem( User $User , Item $Item ) { - if ( $User->hasRole( 'Admin|Supervisor' ) || $Item->user_id == $User->id ) + if ( $User->hasRole( 'Admin' ) ) { return true; + } else { + if ( $User->hasRole( 'Supervisor' ) ) { + if ( $Item->user->medical_center_id == $User->medical_center_id && $Item->package_id == null ) { + return true; + } + } else { + if ( $Item->user_id == $User->id && $Item->package_id == null ) { + return true; + } + } + } } - public function items( User $User ) - { - if ( $User->hasRole( 'Admin|Supervisor' ) ) - return true; - } - - - //package public function transferPackage( User $User , Package $Package ) { - if ( $User->hasRole( 'Admin|Supervisor' ) || $Package->user_id == $User->id ) - return true; - } - - public function packages( User $User ) - { - if ( $User->hasRole( 'Admin|Supervisor' ) ) + if ( $User->hasRole( 'Admin' ) ) { return true; + } else { + if ( $User->hasRole( 'Supervisor' ) ) { + if ( $Package->user->medical_center_id == $User->medical_center_id) { + return true; + } + } else { + if ( $Package->user_id == $User->id) { + return true; + } + } + } } } diff --git a/app/Services/Media/HasMediaTrait.php b/app/Services/Media/HasMediaTrait.php new file mode 100644 index 00000000..9ef0ea55 --- /dev/null +++ b/app/Services/Media/HasMediaTrait.php @@ -0,0 +1,21 @@ +morphOne(Media::class, 'model')->where('collection_name', 'main_image'); + } + + public function main_images() + { + return $this->morphMany(Media::class, 'model')->where('collection_name', 'main_images'); + } +} diff --git a/app/Services/Media/Media.php b/app/Services/Media/Media.php new file mode 100644 index 00000000..520e2713 --- /dev/null +++ b/app/Services/Media/Media.php @@ -0,0 +1,24 @@ +getUrl('thumbnail'); + } + + public function assign($model, $collectionName) + { + $this->collection_name = $collectionName; + $model->media()->save($this); + } +} diff --git a/app/Services/Media/MediaHelper.php b/app/Services/Media/MediaHelper.php new file mode 100644 index 00000000..3cd5b49e --- /dev/null +++ b/app/Services/Media/MediaHelper.php @@ -0,0 +1,58 @@ +validate([ + 'batch_id' => 'nullable|string', + ]); + + if ($fakeModel = FakeModel::where('batch_id', request('batch_id'))->first()) { + foreach ($fakeModel->getMedia('temp_medias') as $media) { + $media->move($model , 'main_images'); + } + $fakeModel->delete(); + } + + } + +// public static function moveTinyMCEMediaTo($model) +// { +// +// request()->validate([ +// 'tinymce_batch_id' => 'nullable|string', +// ]); +// +// if ($fakeModel = FakeModel::where('batch_id', request('tinymce_batch_id'))->first()) { +// foreach ($fakeModel->getMedia('temp_files') as $media) { +// if (substr($media->mime_type, 0, 5) == 'image') { +// $media->assign($model, 'tinymce_images'); +// } else { +// $media->assign($model, 'tinymce_files'); +// } +// } +// $fakeModel->delete(); +// } +// +// } +// +// public static function loadMedia($model, ...$collections) +// { +// $model->loadMissing(['media' => function ($query) use ($collections) { +// $query->select('id', 'model_type', 'model_id', 'collection_name', 'file_name', 'mime_type', 'size', 'disk', 'order_column'); +// if (!empty($collections)) { +// $query->whereIn('collection_name', $collections); +// } +// }]); +// if ($model->media) { +// foreach ($model->media as $media) { +// $media->address = $media->getUrl(); +// } +// } +// } +} diff --git a/app/Services/Media/Resources/MediaResource.php b/app/Services/Media/Resources/MediaResource.php new file mode 100644 index 00000000..467dc332 --- /dev/null +++ b/app/Services/Media/Resources/MediaResource.php @@ -0,0 +1,26 @@ + $this->id, + 'collection_name' => $this->collection_name, + 'thumbnail' => $this->getUrl('thumbnail'), + 'mime_type' => $this->mime_type, + 'file_name' => $this->file_name, + 'size' => $this->size, + ]; + } +} diff --git a/app/Services/Responser.php b/app/Services/Responser.php new file mode 100644 index 00000000..282e2c7e --- /dev/null +++ b/app/Services/Responser.php @@ -0,0 +1,32 @@ + $data, + 'message' => [ + 'title' => $title, + 'content' => $content + ] + ]; + } + + public static function error($errors = null, $data = []) { + $errors = $errors ?: [trans('messages.failed') => trans('core::messages.failed_message')]; + return [ + 'data' => $data, + 'errors' => $errors, + ]; + } + + public static function data($data) { + return [ + 'data' => $data, + ]; + } +} diff --git a/app/TestResult.php b/app/TestResult.php index 8d692822..1a205880 100644 --- a/app/TestResult.php +++ b/app/TestResult.php @@ -3,28 +3,44 @@ namespace App; use Illuminate\Database\Eloquent\Model; +use Spatie\MediaLibrary\HasMedia\HasMedia; +use Spatie\MediaLibrary\HasMedia\HasMediaTrait; +use Spatie\MediaLibrary\Models\Media; -class TestResult extends Model +class TestResult extends Model implements HasMedia { + use HasMediaTrait; + public $fillable = ['result','verified','test_type_id','user_id','device_id', 'cycle_number', 'date']; + public function test_type() { return $this->belongsTo('App\TestType'); } + public function user() { return $this->belongsTo('App\User'); } + public function input_values() { return $this->hasMany('App\InputValue'); } - public function files() + + public function registerMediaCollections() { - return $this->morphMany('App\Media', 'model'); + $this->addMediaCollection( 'main_images' ) + ->useFallbackUrl( '/images/default_pastry.jpg' ) + ->useFallbackPath( public_path( '/images/default_pastry.jpg' ) ); } - public function TitleImage() + + public function registerMediaConversions( Media $media = null ): void { - return $this->morphToMany('App\Gallery', 'uploadable')->wherePivot('image_role', 'TitleImage'); + $this->addMediaConversion( 'thumbnail' ) + ->width( 480 ) + ->height( 640 ) + ->nonQueued() + ->performOnCollections( 'main_images' ); } } diff --git a/composer.json b/composer.json index 504f66b7..e52772b0 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,7 @@ "php": "^7.1.3", "fideloper/proxy": "^4.0", "intervention/image": "^2.5", + "spatie/laravel-medialibrary": "^7.0", "kalnoy/nestedset": "^5.0", "laravel/framework": "5.8.*", "laravel/passport": "^7.2", diff --git a/composer.lock b/composer.lock index 1e49d2c3..5c33844d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2b9574f82cbc6eb42672e5157a6691dc", + "content-hash": "e62c7cf9e2bd01b8713fded1ca182bac", "packages": [ { "name": "clue/stream-filter", @@ -1960,17 +1960,87 @@ "time": "2022-10-04T09:16:37+00:00" }, { - "name": "league/mime-type-detection", - "version": "1.13.0", + "name": "league/glide", + "version": "1.7.2", "source": { "type": "git", - "url": "https://github.com/thephpleague/mime-type-detection.git", - "reference": "a6dfb1194a2946fcdc1f38219445234f65b35c96" + "url": "https://github.com/thephpleague/glide.git", + "reference": "8dba756ada0b8e525bf6f1f7d1bd83c1e99e124e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/a6dfb1194a2946fcdc1f38219445234f65b35c96", - "reference": "a6dfb1194a2946fcdc1f38219445234f65b35c96", + "url": "https://api.github.com/repos/thephpleague/glide/zipball/8dba756ada0b8e525bf6f1f7d1bd83c1e99e124e", + "reference": "8dba756ada0b8e525bf6f1f7d1bd83c1e99e124e", + "shasum": "" + }, + "require": { + "intervention/image": "^2.4", + "league/flysystem": "^1.0", + "php": "^7.2|^8.0", + "psr/http-message": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^1.3.3", + "phpunit/php-token-stream": "^3.1|^4.0", + "phpunit/phpunit": "^8.5|^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Glide\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Reinink", + "email": "jonathan@reinink.ca", + "homepage": "http://reinink.ca" + }, + { + "name": "Titouan Galopin", + "email": "galopintitouan@gmail.com", + "homepage": "https://titouangalopin.com" + } + ], + "description": "Wonderfully easy on-demand image manipulation library with an HTTP based API.", + "homepage": "http://glide.thephpleague.com", + "keywords": [ + "ImageMagick", + "editing", + "gd", + "image", + "imagick", + "league", + "manipulation", + "processing" + ], + "support": { + "issues": "https://github.com/thephpleague/glide/issues", + "source": "https://github.com/thephpleague/glide/tree/1.7.2" + }, + "time": "2023-02-14T06:26:04+00:00" + }, + { + "name": "league/mime-type-detection", + "version": "1.14.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/mime-type-detection.git", + "reference": "b6a5854368533df0295c5761a0253656a2e52d9e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/b6a5854368533df0295c5761a0253656a2e52d9e", + "reference": "b6a5854368533df0295c5761a0253656a2e52d9e", "shasum": "" }, "require": { @@ -2001,7 +2071,7 @@ "description": "Mime-type detection for Flysystem", "support": { "issues": "https://github.com/thephpleague/mime-type-detection/issues", - "source": "https://github.com/thephpleague/mime-type-detection/tree/1.13.0" + "source": "https://github.com/thephpleague/mime-type-detection/tree/1.14.0" }, "funding": [ { @@ -2013,7 +2083,7 @@ "type": "tidelift" } ], - "time": "2023-08-05T12:09:49+00:00" + "time": "2023-10-17T14:13:20+00:00" }, { "name": "league/oauth2-server", @@ -2586,16 +2656,16 @@ }, { "name": "nesbot/carbon", - "version": "2.69.0", + "version": "2.71.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "4308217830e4ca445583a37d1bf4aff4153fa81c" + "reference": "98276233188583f2ff845a0f992a235472d9466a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/4308217830e4ca445583a37d1bf4aff4153fa81c", - "reference": "4308217830e4ca445583a37d1bf4aff4153fa81c", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/98276233188583f2ff845a0f992a235472d9466a", + "reference": "98276233188583f2ff845a0f992a235472d9466a", "shasum": "" }, "require": { @@ -2688,7 +2758,7 @@ "type": "tidelift" } ], - "time": "2023-08-03T09:00:52+00:00" + "time": "2023-09-25T11:31:05+00:00" }, { "name": "nikic/php-parser", @@ -2748,16 +2818,16 @@ }, { "name": "nyholm/psr7", - "version": "1.8.0", + "version": "1.8.1", "source": { "type": "git", "url": "https://github.com/Nyholm/psr7.git", - "reference": "3cb4d163b58589e47b35103e8e5e6a6a475b47be" + "reference": "aa5fc277a4f5508013d571341ade0c3886d4d00e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Nyholm/psr7/zipball/3cb4d163b58589e47b35103e8e5e6a6a475b47be", - "reference": "3cb4d163b58589e47b35103e8e5e6a6a475b47be", + "url": "https://api.github.com/repos/Nyholm/psr7/zipball/aa5fc277a4f5508013d571341ade0c3886d4d00e", + "reference": "aa5fc277a4f5508013d571341ade0c3886d4d00e", "shasum": "" }, "require": { @@ -2810,7 +2880,7 @@ ], "support": { "issues": "https://github.com/Nyholm/psr7/issues", - "source": "https://github.com/Nyholm/psr7/tree/1.8.0" + "source": "https://github.com/Nyholm/psr7/tree/1.8.1" }, "funding": [ { @@ -2822,7 +2892,7 @@ "type": "github" } ], - "time": "2023-05-02T11:26:24+00:00" + "time": "2023-11-13T09:31:12+00:00" }, { "name": "opis/closure", @@ -2941,16 +3011,16 @@ }, { "name": "php-http/client-common", - "version": "2.7.0", + "version": "2.7.1", "source": { "type": "git", "url": "https://github.com/php-http/client-common.git", - "reference": "880509727a447474d2a71b7d7fa5d268ddd3db4b" + "reference": "1e19c059b0e4d5f717bf5d524d616165aeab0612" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-http/client-common/zipball/880509727a447474d2a71b7d7fa5d268ddd3db4b", - "reference": "880509727a447474d2a71b7d7fa5d268ddd3db4b", + "url": "https://api.github.com/repos/php-http/client-common/zipball/1e19c059b0e4d5f717bf5d524d616165aeab0612", + "reference": "1e19c059b0e4d5f717bf5d524d616165aeab0612", "shasum": "" }, "require": { @@ -2960,7 +3030,7 @@ "psr/http-client": "^1.0", "psr/http-factory": "^1.0", "psr/http-message": "^1.0 || ^2.0", - "symfony/options-resolver": "~4.0.15 || ~4.1.9 || ^4.2.1 || ^5.0 || ^6.0", + "symfony/options-resolver": "~4.0.15 || ~4.1.9 || ^4.2.1 || ^5.0 || ^6.0 || ^7.0", "symfony/polyfill-php80": "^1.17" }, "require-dev": { @@ -3004,9 +3074,9 @@ ], "support": { "issues": "https://github.com/php-http/client-common/issues", - "source": "https://github.com/php-http/client-common/tree/2.7.0" + "source": "https://github.com/php-http/client-common/tree/2.7.1" }, - "time": "2023-05-17T06:46:59+00:00" + "time": "2023-11-30T10:31:25+00:00" }, { "name": "php-http/discovery", @@ -3265,31 +3335,26 @@ }, { "name": "php-http/promise", - "version": "1.1.0", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/php-http/promise.git", - "reference": "4c4c1f9b7289a2ec57cde7f1e9762a5789506f88" + "reference": "44a67cb59f708f826f3bec35f22030b3edb90119" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-http/promise/zipball/4c4c1f9b7289a2ec57cde7f1e9762a5789506f88", - "reference": "4c4c1f9b7289a2ec57cde7f1e9762a5789506f88", + "url": "https://api.github.com/repos/php-http/promise/zipball/44a67cb59f708f826f3bec35f22030b3edb90119", + "reference": "44a67cb59f708f826f3bec35f22030b3edb90119", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, "require-dev": { - "friends-of-phpspec/phpspec-code-coverage": "^4.3.2", - "phpspec/phpspec": "^5.1.2 || ^6.2" + "friends-of-phpspec/phpspec-code-coverage": "^4.3.2 || ^6.3", + "phpspec/phpspec": "^5.1.2 || ^6.2 || ^7.4" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, "autoload": { "psr-4": { "Http\\Promise\\": "src/" @@ -3316,9 +3381,9 @@ ], "support": { "issues": "https://github.com/php-http/promise/issues", - "source": "https://github.com/php-http/promise/tree/1.1.0" + "source": "https://github.com/php-http/promise/tree/1.2.1" }, - "time": "2020-07-07T09:29:14+00:00" + "time": "2023-11-08T12:57:08+00:00" }, { "name": "phpoffice/phpspreadsheet", @@ -3427,16 +3492,16 @@ }, { "name": "phpoption/phpoption", - "version": "1.9.1", + "version": "1.9.2", "source": { "type": "git", "url": "https://github.com/schmittjoh/php-option.git", - "reference": "dd3a383e599f49777d8b628dadbb90cae435b87e" + "reference": "80735db690fe4fc5c76dfa7f9b770634285fa820" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/dd3a383e599f49777d8b628dadbb90cae435b87e", - "reference": "dd3a383e599f49777d8b628dadbb90cae435b87e", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/80735db690fe4fc5c76dfa7f9b770634285fa820", + "reference": "80735db690fe4fc5c76dfa7f9b770634285fa820", "shasum": "" }, "require": { @@ -3444,7 +3509,7 @@ }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", - "phpunit/phpunit": "^8.5.32 || ^9.6.3 || ^10.0.12" + "phpunit/phpunit": "^8.5.34 || ^9.6.13 || ^10.4.2" }, "type": "library", "extra": { @@ -3486,7 +3551,7 @@ ], "support": { "issues": "https://github.com/schmittjoh/php-option/issues", - "source": "https://github.com/schmittjoh/php-option/tree/1.9.1" + "source": "https://github.com/schmittjoh/php-option/tree/1.9.2" }, "funding": [ { @@ -3498,20 +3563,20 @@ "type": "tidelift" } ], - "time": "2023-02-25T19:38:58+00:00" + "time": "2023-11-12T21:59:55+00:00" }, { "name": "phpseclib/phpseclib", - "version": "2.0.44", + "version": "2.0.45", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "149f608243f8133c61926aae26ce67d2b22b37e5" + "reference": "28d8f438a0064c9de80857e3270d071495544640" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/149f608243f8133c61926aae26ce67d2b22b37e5", - "reference": "149f608243f8133c61926aae26ce67d2b22b37e5", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/28d8f438a0064c9de80857e3270d071495544640", + "reference": "28d8f438a0064c9de80857e3270d071495544640", "shasum": "" }, "require": { @@ -3592,7 +3657,7 @@ ], "support": { "issues": "https://github.com/phpseclib/phpseclib/issues", - "source": "https://github.com/phpseclib/phpseclib/tree/2.0.44" + "source": "https://github.com/phpseclib/phpseclib/tree/2.0.45" }, "funding": [ { @@ -3608,7 +3673,7 @@ "type": "tidelift" } ], - "time": "2023-06-13T08:41:47+00:00" + "time": "2023-09-15T20:55:47+00:00" }, { "name": "psr/clock", @@ -3708,16 +3773,16 @@ }, { "name": "psr/http-client", - "version": "1.0.2", + "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/php-fig/http-client.git", - "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31" + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-client/zipball/0955afe48220520692d2d09f7ab7e0f93ffd6a31", - "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", "shasum": "" }, "require": { @@ -3754,9 +3819,9 @@ "psr-18" ], "support": { - "source": "https://github.com/php-fig/http-client/tree/1.0.2" + "source": "https://github.com/php-fig/http-client" }, - "time": "2023-04-10T20:12:12+00:00" + "time": "2023-09-23T14:17:50+00:00" }, { "name": "psr/http-factory", @@ -4248,16 +4313,16 @@ }, { "name": "sentry/sentry", - "version": "3.21.0", + "version": "3.22.1", "source": { "type": "git", "url": "https://github.com/getsentry/sentry-php.git", - "reference": "624aafc22b84b089ffa43b71fb01e0096505ec4f" + "reference": "8859631ba5ab15bc1af420b0eeed19ecc6c9d81d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/624aafc22b84b089ffa43b71fb01e0096505ec4f", - "reference": "624aafc22b84b089ffa43b71fb01e0096505ec4f", + "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/8859631ba5ab15bc1af420b0eeed19ecc6c9d81d", + "reference": "8859631ba5ab15bc1af420b0eeed19ecc6c9d81d", "shasum": "" }, "require": { @@ -4275,7 +4340,7 @@ "psr/http-factory": "^1.0", "psr/http-factory-implementation": "^1.0", "psr/log": "^1.0|^2.0|^3.0", - "symfony/options-resolver": "^3.4.43|^4.4.30|^5.0.11|^6.0", + "symfony/options-resolver": "^3.4.43|^4.4.30|^5.0.11|^6.0|^7.0", "symfony/polyfill-php80": "^1.17" }, "conflict": { @@ -4332,7 +4397,7 @@ ], "support": { "issues": "https://github.com/getsentry/sentry-php/issues", - "source": "https://github.com/getsentry/sentry-php/tree/3.21.0" + "source": "https://github.com/getsentry/sentry-php/tree/3.22.1" }, "funding": [ { @@ -4344,7 +4409,7 @@ "type": "custom" } ], - "time": "2023-07-31T15:31:24+00:00" + "time": "2023-11-13T11:47:28+00:00" }, { "name": "sentry/sentry-laravel", @@ -4434,6 +4499,230 @@ ], "time": "2022-10-13T09:21:29+00:00" }, + { + "name": "spatie/image", + "version": "1.10.6", + "source": { + "type": "git", + "url": "https://github.com/spatie/image.git", + "reference": "897e819848096ea8eee8ed4a3531c6166f9a99e0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/image/zipball/897e819848096ea8eee8ed4a3531c6166f9a99e0", + "reference": "897e819848096ea8eee8ed4a3531c6166f9a99e0", + "shasum": "" + }, + "require": { + "ext-exif": "*", + "ext-json": "*", + "ext-mbstring": "*", + "league/glide": "^1.6", + "php": "^7.2|^8.0", + "spatie/image-optimizer": "^1.1", + "spatie/temporary-directory": "^1.0|^2.0", + "symfony/process": "^3.0|^4.0|^5.0|^6.0" + }, + "require-dev": { + "phpunit/phpunit": "^8.5.21|^9.5.4", + "symfony/var-dumper": "^4.0|^5.0|^6.0", + "vimeo/psalm": "^4.6" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\Image\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Manipulate images with an expressive API", + "homepage": "https://github.com/spatie/image", + "keywords": [ + "image", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/image/issues", + "source": "https://github.com/spatie/image/tree/1.10.6" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + }, + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2021-12-21T10:01:09+00:00" + }, + { + "name": "spatie/image-optimizer", + "version": "1.7.2", + "source": { + "type": "git", + "url": "https://github.com/spatie/image-optimizer.git", + "reference": "62f7463483d1bd975f6f06025d89d42a29608fe1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/image-optimizer/zipball/62f7463483d1bd975f6f06025d89d42a29608fe1", + "reference": "62f7463483d1bd975f6f06025d89d42a29608fe1", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "php": "^7.3|^8.0", + "psr/log": "^1.0 | ^2.0 | ^3.0", + "symfony/process": "^4.2|^5.0|^6.0|^7.0" + }, + "require-dev": { + "pestphp/pest": "^1.21", + "phpunit/phpunit": "^8.5.21|^9.4.4", + "symfony/var-dumper": "^4.2|^5.0|^6.0|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\ImageOptimizer\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Easily optimize images using PHP", + "homepage": "https://github.com/spatie/image-optimizer", + "keywords": [ + "image-optimizer", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/image-optimizer/issues", + "source": "https://github.com/spatie/image-optimizer/tree/1.7.2" + }, + "time": "2023-11-03T10:08:02+00:00" + }, + { + "name": "spatie/laravel-medialibrary", + "version": "7.20.0", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-medialibrary.git", + "reference": "d650ef5163f5285b7fcc647d789f80f194f3bdb2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-medialibrary/zipball/d650ef5163f5285b7fcc647d789f80f194f3bdb2", + "reference": "d650ef5163f5285b7fcc647d789f80f194f3bdb2", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "ext-json": "*", + "illuminate/bus": "~5.8.35|^6.0|^7.0|^8.0", + "illuminate/console": "~5.8.35|^6.0|^7.0|^8.0", + "illuminate/database": "~5.8.35|^6.0|^7.0|^8.0", + "illuminate/pipeline": "~5.8.35|^6.0|^7.0|^8.0", + "illuminate/support": "~5.8.35|^6.0|^7.0|^8.0", + "league/flysystem": "^1.0.8", + "maennchen/zipstream-php": "^1.0|^2.0", + "php": "^7.2|^8.0", + "spatie/image": "^1.4.0", + "spatie/pdf-to-image": "^2.0", + "spatie/temporary-directory": "^1.1", + "symfony/console": "^4.4|^5.1" + }, + "conflict": { + "php-ffmpeg/php-ffmpeg": "<0.6.1" + }, + "require-dev": { + "doctrine/dbal": "^2.5.2", + "ext-pdo_sqlite": "*", + "guzzlehttp/guzzle": "^6.3|^7.0.1", + "league/flysystem-aws-s3-v3": "^1.0.13", + "mockery/mockery": "^1.0", + "orchestra/testbench": "^3.8|^4.0|^5.0|^6.0", + "phpunit/phpunit": "^8.0|^9.0", + "spatie/phpunit-snapshot-assertions": "^4.0" + }, + "suggest": { + "league/flysystem-aws-s3-v3": "Required to use AWS S3 file storage", + "php-ffmpeg/php-ffmpeg": "Required for generating video thumbnails" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Spatie\\MediaLibrary\\MediaLibraryServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Spatie\\MediaLibrary\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://murze.be", + "role": "Developer" + } + ], + "description": "Associate files with Eloquent models", + "homepage": "https://github.com/spatie/laravel-medialibrary", + "keywords": [ + "cms", + "conversion", + "downloads", + "images", + "laravel", + "laravel-medialibrary", + "media", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/laravel-medialibrary/issues", + "source": "https://github.com/spatie/laravel-medialibrary/tree/7.20.0" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + }, + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2021-05-26T16:48:02+00:00" + }, { "name": "spatie/laravel-permission", "version": "2.38.0", @@ -4506,6 +4795,117 @@ }, "time": "2019-09-02T17:12:21+00:00" }, + { + "name": "spatie/pdf-to-image", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/spatie/pdf-to-image.git", + "reference": "9b8d5bae5b77f6023e87b2401028e52b7addbd48" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/pdf-to-image/zipball/9b8d5bae5b77f6023e87b2401028e52b7addbd48", + "reference": "9b8d5bae5b77f6023e87b2401028e52b7addbd48", + "shasum": "" + }, + "require": { + "ext-imagick": "*", + "php": "^7.2|^8.0" + }, + "require-dev": { + "pestphp/pest": "^1.21" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\PdfToImage\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Convert a pdf to an image", + "homepage": "https://github.com/spatie/pdf-to-image", + "keywords": [ + "convert", + "image", + "pdf", + "pdf-to-image", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/pdf-to-image/issues", + "source": "https://github.com/spatie/pdf-to-image/tree/2.2.0" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2022-03-08T07:52:26+00:00" + }, + { + "name": "spatie/temporary-directory", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/spatie/temporary-directory.git", + "reference": "f517729b3793bca58f847c5fd383ec16f03ffec6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/temporary-directory/zipball/f517729b3793bca58f847c5fd383ec16f03ffec6", + "reference": "f517729b3793bca58f847c5fd383ec16f03ffec6", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^8.0|^9.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\TemporaryDirectory\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alex Vanderbist", + "email": "alex@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Easily create, use and destroy temporary directories", + "homepage": "https://github.com/spatie/temporary-directory", + "keywords": [ + "php", + "spatie", + "temporary-directory" + ], + "support": { + "issues": "https://github.com/spatie/temporary-directory/issues", + "source": "https://github.com/spatie/temporary-directory/tree/1.3.0" + }, + "time": "2020-11-09T15:54:21+00:00" + }, { "name": "swiftmailer/swiftmailer", "version": "v6.3.0", @@ -5028,16 +5428,16 @@ }, { "name": "symfony/event-dispatcher-contracts", - "version": "v1.1.13", + "version": "v1.10.0", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "1d5cd762abaa6b2a4169d3e77610193a7157129e" + "reference": "761c8b8387cfe5f8026594a75fdf0a4e83ba6974" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/1d5cd762abaa6b2a4169d3e77610193a7157129e", - "reference": "1d5cd762abaa6b2a4169d3e77610193a7157129e", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/761c8b8387cfe5f8026594a75fdf0a4e83ba6974", + "reference": "761c8b8387cfe5f8026594a75fdf0a4e83ba6974", "shasum": "" }, "require": { @@ -5087,7 +5487,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v1.1.13" + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v1.10.0" }, "funding": [ { @@ -5103,7 +5503,7 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:41:36+00:00" + "time": "2022-07-20T09:59:04+00:00" }, { "name": "symfony/finder", @@ -5169,16 +5569,16 @@ }, { "name": "symfony/http-client", - "version": "v5.4.26", + "version": "v5.4.31", "source": { "type": "git", "url": "https://github.com/symfony/http-client.git", - "reference": "19d48ef7f38e5057ed1789a503cd3eccef039bce" + "reference": "6cdf6cdf48101454f014a9ab4e0905f0b902389d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client/zipball/19d48ef7f38e5057ed1789a503cd3eccef039bce", - "reference": "19d48ef7f38e5057ed1789a503cd3eccef039bce", + "url": "https://api.github.com/repos/symfony/http-client/zipball/6cdf6cdf48101454f014a9ab4e0905f0b902389d", + "reference": "6cdf6cdf48101454f014a9ab4e0905f0b902389d", "shasum": "" }, "require": { @@ -5240,7 +5640,7 @@ "http" ], "support": { - "source": "https://github.com/symfony/http-client/tree/v5.4.26" + "source": "https://github.com/symfony/http-client/tree/v5.4.31" }, "funding": [ { @@ -5256,7 +5656,7 @@ "type": "tidelift" } ], - "time": "2023-07-03T12:14:50+00:00" + "time": "2023-10-29T12:33:05+00:00" }, { "name": "symfony/http-client-contracts", @@ -5406,16 +5806,16 @@ }, { "name": "symfony/http-kernel", - "version": "v4.4.50", + "version": "v4.4.51", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "aa6df6c045f034aa13ac752fc234bb300b9488ef" + "reference": "ad8ab192cb619ff7285c95d28c69b36d718416c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/aa6df6c045f034aa13ac752fc234bb300b9488ef", - "reference": "aa6df6c045f034aa13ac752fc234bb300b9488ef", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/ad8ab192cb619ff7285c95d28c69b36d718416c7", + "reference": "ad8ab192cb619ff7285c95d28c69b36d718416c7", "shasum": "" }, "require": { @@ -5490,7 +5890,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v4.4.50" + "source": "https://github.com/symfony/http-kernel/tree/v4.4.51" }, "funding": [ { @@ -5506,7 +5906,7 @@ "type": "tidelift" } ], - "time": "2023-02-01T08:01:31+00:00" + "time": "2023-11-10T13:31:29+00:00" }, { "name": "symfony/mime", @@ -7152,16 +7552,16 @@ }, { "name": "doctrine/deprecations", - "version": "v1.1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3" + "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", - "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/4f2d4f2836e7ec4e7a8625e75c6aa916004db931", + "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931", "shasum": "" }, "require": { @@ -7193,9 +7593,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/v1.1.1" + "source": "https://github.com/doctrine/deprecations/tree/1.1.2" }, - "time": "2023-06-03T09:27:29+00:00" + "time": "2023-09-27T20:04:15+00:00" }, { "name": "doctrine/instantiator", @@ -7269,16 +7669,16 @@ }, { "name": "filp/whoops", - "version": "2.15.3", + "version": "2.15.4", "source": { "type": "git", "url": "https://github.com/filp/whoops.git", - "reference": "c83e88a30524f9360b11f585f71e6b17313b7187" + "reference": "a139776fa3f5985a50b509f2a02ff0f709d2a546" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filp/whoops/zipball/c83e88a30524f9360b11f585f71e6b17313b7187", - "reference": "c83e88a30524f9360b11f585f71e6b17313b7187", + "url": "https://api.github.com/repos/filp/whoops/zipball/a139776fa3f5985a50b509f2a02ff0f709d2a546", + "reference": "a139776fa3f5985a50b509f2a02ff0f709d2a546", "shasum": "" }, "require": { @@ -7328,7 +7728,7 @@ ], "support": { "issues": "https://github.com/filp/whoops/issues", - "source": "https://github.com/filp/whoops/tree/2.15.3" + "source": "https://github.com/filp/whoops/tree/2.15.4" }, "funding": [ { @@ -7336,7 +7736,7 @@ "type": "github" } ], - "time": "2023-07-13T12:00:00+00:00" + "time": "2023-11-03T12:00:00+00:00" }, { "name": "fzaninotto/faker", @@ -7988,16 +8388,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.23.1", + "version": "1.24.4", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "846ae76eef31c6d7790fac9bc399ecee45160b26" + "reference": "6bd0c26f3786cd9b7c359675cb789e35a8e07496" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/846ae76eef31c6d7790fac9bc399ecee45160b26", - "reference": "846ae76eef31c6d7790fac9bc399ecee45160b26", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6bd0c26f3786cd9b7c359675cb789e35a8e07496", + "reference": "6bd0c26f3786cd9b7c359675cb789e35a8e07496", "shasum": "" }, "require": { @@ -8029,9 +8429,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.23.1" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.4" }, - "time": "2023-08-03T16:32:59+00:00" + "time": "2023-11-26T18:29:22+00:00" }, { "name": "phpunit/php-code-coverage", @@ -9078,16 +9478,16 @@ }, { "name": "theseer/tokenizer", - "version": "1.2.1", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" + "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/b2ad5003ca10d4ee50a12da31de12a5774ba6b96", + "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96", "shasum": "" }, "require": { @@ -9116,7 +9516,7 @@ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "support": { "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/1.2.1" + "source": "https://github.com/theseer/tokenizer/tree/1.2.2" }, "funding": [ { @@ -9124,7 +9524,7 @@ "type": "github" } ], - "time": "2021-07-28T10:34:58+00:00" + "time": "2023-11-20T00:12:19+00:00" }, { "name": "webmozart/assert", diff --git a/config/filesystems.php b/config/filesystems.php index c6f3c6d0..b1df2e7d 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -55,13 +55,21 @@ return [ 'visibility' => 'public', ], - 's3' => [ + 'media' => [ 'driver' => 's3', 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION'), 'bucket' => env('AWS_BUCKET'), 'url' => env('AWS_URL'), + 'endpoint' => env('AWS_ENDPOINT'), + 'root' => 'media', + 'use_path_style_endpoint' => true, + ], + + 'media-dev' => [ + 'driver' => 'local', + 'root' => public_path('media'), ], ], diff --git a/config/medialibrary.php b/config/medialibrary.php new file mode 100644 index 00000000..a8957028 --- /dev/null +++ b/config/medialibrary.php @@ -0,0 +1,156 @@ + env('MEDIA_DISK', 'public'), + + /* + * The maximum file size of an item in bytes. + * Adding a larger file will result in an exception. + */ + 'max_file_size' => 1024 * 1024 * 10, + + /* + * This queue will be used to generate derived and responsive images. + * Leave empty to use the default queue. + */ + 'queue_name' => '', + + /* + * The fully qualified class name of the media model. + */ + 'media_model' => Spatie\MediaLibrary\Models\Media::class, + + 's3' => [ + /* + * The domain that should be prepended when generating urls. + */ + 'domain' => 'https://'.env('AWS_BUCKET').'.s3.amazonaws.com', + ], + + '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 20% + * smaller than the previous one. More info in the documentation. + * + * 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 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 medialibrary will use a tiny blurred jpg image. + */ + 'tiny_placeholder_generator' => Spatie\MediaLibrary\ResponsiveImages\TinyPlaceholderGenerator\Blurred::class, + ], + + /* + * When urls to files get generated, this class will be called. Leave empty + * if your files are stored locally above the site root or on s3. + */ + 'url_generator' => null, + + /* + * Whether to activate versioning when urls to files get generated. + * When activated, this attaches a ?v=xx query string to the URL. + */ + 'version_urls' => false, + + /* + * The class that contains the strategy for determining a media file's path. + */ + 'path_generator' => null, + + /* + * Medialibrary will try to optimize all converted images by removing + * metadata and applying a little bit of compression. These are + * the optimizers that will be used by default. + */ + 'image_optimizers' => [ + Spatie\ImageOptimizer\Optimizers\Jpegoptim::class => [ + '--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 + ], + Spatie\ImageOptimizer\Optimizers\Pngquant::class => [ + '--force', // required parameter for this package + ], + Spatie\ImageOptimizer\Optimizers\Optipng::class => [ + '-i0', // this will result in a non-interlaced, progressive scanned image + '-o2', // this set the optimization level to two (multiple IDAT compression trials) + '-quiet', // required parameter for this package + ], + Spatie\ImageOptimizer\Optimizers\Svgo::class => [ + '--disable=cleanupIDs', // disabling because it is known to cause troubles + ], + Spatie\ImageOptimizer\Optimizers\Gifsicle::class => [ + '-b', // required parameter for this package + '-O3', // this produces the slowest but best results + ], + ], + + /* + * These generators will be used to create an image of media files. + */ + 'image_generators' => [ + Spatie\MediaLibrary\ImageGenerators\FileTypes\Image::class, + Spatie\MediaLibrary\ImageGenerators\FileTypes\Webp::class, + Spatie\MediaLibrary\ImageGenerators\FileTypes\Pdf::class, + Spatie\MediaLibrary\ImageGenerators\FileTypes\Svg::class, + Spatie\MediaLibrary\ImageGenerators\FileTypes\Video::class, + ], + + /* + * The engine that should perform the image conversions. + * Should be either `gd` or `imagick`. + */ + 'image_driver' => env('IMAGE_DRIVER', 'gd'), + + /* + * FFMPEG & FFProbe binaries paths, only used if you try to generate video + * thumbnails and have installed the php-ffmpeg/php-ffmpeg composer + * dependency. + */ + 'ffmpeg_path' => env('FFMPEG_PATH', '/usr/bin/ffmpeg'), + '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 + * your custom jobs extend the ones provided by the package. + */ + 'jobs' => [ + 'perform_conversions' => Spatie\MediaLibrary\Jobs\PerformConversions::class, + 'generate_responsive_images' => Spatie\MediaLibrary\Jobs\GenerateResponsiveImages::class, + ], +]; diff --git a/database/migrations/2023_12_02_140423_create_media_table.php b/database/migrations/2023_12_02_140423_create_media_table.php new file mode 100644 index 00000000..113ef3a3 --- /dev/null +++ b/database/migrations/2023_12_02_140423_create_media_table.php @@ -0,0 +1,39 @@ +bigIncrements('id'); + $table->morphs('model'); + $table->string('collection_name'); + $table->string('name'); + $table->string('file_name'); + $table->string('mime_type')->nullable(); + $table->string('disk'); + $table->unsignedBigInteger('size'); + $table->json('manipulations'); + $table->json('custom_properties'); + $table->json('responsive_images'); + $table->unsignedInteger('order_column')->nullable(); + $table->nullableTimestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down() + { + Schema::dropIfExists('media'); + } +} diff --git a/database/migrations/2023_12_02_150039_create_fake_models_table.php b/database/migrations/2023_12_02_150039_create_fake_models_table.php new file mode 100644 index 00000000..fb82a4c2 --- /dev/null +++ b/database/migrations/2023_12_02_150039_create_fake_models_table.php @@ -0,0 +1,31 @@ +bigIncrements('id'); + $table->string('batch_id' , 255); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('fake_models'); + } +} diff --git a/database/migrations/2023_12_04_124700_update_items_table3.php b/database/migrations/2023_12_04_124700_update_items_table3.php new file mode 100644 index 00000000..07f83607 --- /dev/null +++ b/database/migrations/2023_12_04_124700_update_items_table3.php @@ -0,0 +1,32 @@ +unsignedBigInteger('creator_id'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('items', function (Blueprint $table) { + $table->dropColumn('creator_id'); + }); + } +} diff --git a/database/migrations/2023_12_04_124700_update_packages_table3.php b/database/migrations/2023_12_04_124700_update_packages_table3.php new file mode 100644 index 00000000..823d7e39 --- /dev/null +++ b/database/migrations/2023_12_04_124700_update_packages_table3.php @@ -0,0 +1,32 @@ +unsignedBigInteger('creator_id'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('packages', function (Blueprint $table) { + $table->dropColumn('creator_id'); + }); + } +} diff --git a/database/migrations/2023_12_05_124700_update_items_table4.php b/database/migrations/2023_12_05_124700_update_items_table4.php new file mode 100644 index 00000000..ed4ca9d9 --- /dev/null +++ b/database/migrations/2023_12_05_124700_update_items_table4.php @@ -0,0 +1,33 @@ +unsignedBigInteger('package_id')->nullable()->after("id"); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('items', function (Blueprint $table) { + $table->dropColumn('package_id'); + }); + } +} diff --git a/public/media/Items/33/1700553010.png b/public/media/Items/33/1700553010.png deleted file mode 100644 index fb71f51e..00000000 Binary files a/public/media/Items/33/1700553010.png and /dev/null differ diff --git a/public/media/Items/33/1700553073.png b/public/media/Items/33/1700553073.png deleted file mode 100644 index 87c3c1da..00000000 Binary files a/public/media/Items/33/1700553073.png and /dev/null differ diff --git a/public/media/Items/34/1693305589.jpeg b/public/media/Items/34/1693305589.jpeg deleted file mode 100644 index 30d14776..00000000 Binary files a/public/media/Items/34/1693305589.jpeg and /dev/null differ diff --git a/public/media/Items/34/1700553613.png b/public/media/Items/34/1700553613.png deleted file mode 100644 index dc4ea450..00000000 Binary files a/public/media/Items/34/1700553613.png and /dev/null differ diff --git a/public/media/Items/35/1693307644.jpeg b/public/media/Items/35/1693307644.jpeg deleted file mode 100644 index 30d14776..00000000 Binary files a/public/media/Items/35/1693307644.jpeg and /dev/null differ diff --git a/public/media/Temp/1700552241.png b/public/media/Temp/1700552241.png deleted file mode 100644 index b1ab9f80..00000000 Binary files a/public/media/Temp/1700552241.png and /dev/null differ diff --git a/public/media/Temp/5315849221/1693301702.jpeg b/public/media/Temp/5315849221/1693301702.jpeg deleted file mode 100644 index 30d14776..00000000 Binary files a/public/media/Temp/5315849221/1693301702.jpeg and /dev/null differ diff --git a/public/media/Temp/7388614130/1693305526.jpeg b/public/media/Temp/7388614130/1693305526.jpeg deleted file mode 100644 index 30d14776..00000000 Binary files a/public/media/Temp/7388614130/1693305526.jpeg and /dev/null differ diff --git a/public/media/Temp/7940270458/1693305106.jpeg b/public/media/Temp/7940270458/1693305106.jpeg deleted file mode 100644 index 30d14776..00000000 Binary files a/public/media/Temp/7940270458/1693305106.jpeg and /dev/null differ diff --git a/public/media/TestResults/1/1700552213.png b/public/media/TestResults/1/1700552213.png deleted file mode 100644 index 96fba955..00000000 Binary files a/public/media/TestResults/1/1700552213.png and /dev/null differ diff --git a/public/media/TestResults/1/1700552280.png b/public/media/TestResults/1/1700552280.png deleted file mode 100644 index 0cfb5141..00000000 Binary files a/public/media/TestResults/1/1700552280.png and /dev/null differ diff --git a/public/media/TestResults/1/1700552290.png b/public/media/TestResults/1/1700552290.png deleted file mode 100644 index 7e482bd4..00000000 Binary files a/public/media/TestResults/1/1700552290.png and /dev/null differ diff --git a/public/media/TestResults/1/1701353894.png b/public/media/TestResults/1/1701353894.png deleted file mode 100644 index bd1755cf..00000000 Binary files a/public/media/TestResults/1/1701353894.png and /dev/null differ diff --git a/public/media/TestResults/262/1693387378.jpeg b/public/media/TestResults/262/1693387378.jpeg deleted file mode 100644 index 30d14776..00000000 Binary files a/public/media/TestResults/262/1693387378.jpeg and /dev/null differ diff --git a/public/media/TestResults/294/1693305542.jpeg b/public/media/TestResults/294/1693305542.jpeg deleted file mode 100644 index 30d14776..00000000 Binary files a/public/media/TestResults/294/1693305542.jpeg and /dev/null differ diff --git a/public/media/TestResults/295/1693387486.jpeg b/public/media/TestResults/295/1693387486.jpeg deleted file mode 100644 index 30d14776..00000000 Binary files a/public/media/TestResults/295/1693387486.jpeg and /dev/null differ diff --git a/public/media/TestResults/296/1693387829.jpeg b/public/media/TestResults/296/1693387829.jpeg deleted file mode 100644 index 30d14776..00000000 Binary files a/public/media/TestResults/296/1693387829.jpeg and /dev/null differ diff --git a/public/media/TestResults/297/1693389024.jpeg b/public/media/TestResults/297/1693389024.jpeg deleted file mode 100644 index 30d14776..00000000 Binary files a/public/media/TestResults/297/1693389024.jpeg and /dev/null differ diff --git a/public/media/TestResults/34/1693307064.jpeg b/public/media/TestResults/34/1693307064.jpeg deleted file mode 100644 index 30d14776..00000000 Binary files a/public/media/TestResults/34/1693307064.jpeg and /dev/null differ diff --git a/public/media/TestResults/35/1693307658.jpeg b/public/media/TestResults/35/1693307658.jpeg deleted file mode 100644 index 30d14776..00000000 Binary files a/public/media/TestResults/35/1693307658.jpeg and /dev/null differ diff --git a/public/media/TestResults/79/1591704182.png b/public/media/TestResults/79/1591704182.png deleted file mode 100644 index 6415ee73..00000000 Binary files a/public/media/TestResults/79/1591704182.png and /dev/null differ diff --git a/public/media/TestResults/79/1591704272.jpeg b/public/media/TestResults/79/1591704272.jpeg deleted file mode 100644 index 15c7f4d9..00000000 Binary files a/public/media/TestResults/79/1591704272.jpeg and /dev/null differ diff --git a/public/media/TestResults/79/1591706622.jpeg b/public/media/TestResults/79/1591706622.jpeg deleted file mode 100644 index 80520094..00000000 Binary files a/public/media/TestResults/79/1591706622.jpeg and /dev/null differ diff --git a/public/media/TestResults/82/1593887700.jpeg b/public/media/TestResults/82/1593887700.jpeg deleted file mode 100644 index 15c7f4d9..00000000 Binary files a/public/media/TestResults/82/1593887700.jpeg and /dev/null differ diff --git a/routes/api.php b/routes/api.php index 6d1c46b6..1b5a8049 100644 --- a/routes/api.php +++ b/routes/api.php @@ -24,20 +24,14 @@ Route::group(['namespace' => 'Api'],function () { Route::middleware('auth:api')->group(function () { - Route::get('/TestResults/ListFilterItems', 'TestResultController@listFilterItems'); - Route::post('/TestResults/Verify/{TestResult}/{Value}', 'TestResultController@verifyTestResult'); Route::get('TestTypes/ListNames', 'TestTypeController@listNames'); Route::post('/TestTypes/Barcode/{TestType}', 'TestTypeController@generateBarcode'); Route::resource('TestTypes', 'TestTypeController'); - Route::resource('TestResults', 'TestResultController' , ['except' => 'show']); Route::resource('MedicalCenters', 'MedicalCenterController'); Route::post('/GetInputs', 'TestTypeController@getInputs'); - Route::post('/TestResults/chart', 'TestResultController@chart'); // Route::get('/TestTypes/All', 'TestTypeController@AllTestTypes'); // Route::get('/MedicalCenters/All', 'MedicalCenterController@listMedicalCenters'); - Route::post('/TestResult/QRCode/{TestResult}', 'BarCodeController@generateQRcode'); - Route::get('/GetInfo', 'UserController@getInfo'); Route::get('Users/MedicalCenter/{MedicalCenter}', 'UserController@getByMedicalCenter'); Route::post('Users/ChangeStatus/{User}', 'UserController@changeStatus'); @@ -46,18 +40,10 @@ Route::middleware('auth:api')->group(function () { Route::get('users/search', 'UserController@searchUser'); Route::resource('Users', 'UserController'); - Route::resource('Items', 'ItemController'); - Route::post('Items/ChangeStatus/{Item}', 'ItemController@changeStatus'); - Route::post('Items/ChangeRepair/{Item}', 'ItemController@changeRepair'); - - Route::resource('Packages', 'PackageController')->except(['showPackage']); Route::resource('Labels', 'LabelController'); Route::resource('Messages', 'MessageController'); Route::delete('Messages/User/{User}', 'MessageController@destroyUserMessages'); - Route::post('/Package/Verify/{Package}', 'PackageController@verifyPackage'); - Route::get('/GetItems', 'ItemController@getItems'); - Route::get('/GetPackages', 'PackageController@getPackages'); Route::get('/GetLabels', 'LabelController@getLabels'); Route::get('/GetCities', 'MedicalCenterController@getCities'); @@ -65,28 +51,45 @@ Route::middleware('auth:api')->group(function () { Route::get('TestTypes/AllArchivedTestTypes', 'TestTypeController@allArchivedTestTypes'); - Route::post('UploadFile', 'UploadController@uploadFile'); - Route::post('DeleteFile', 'UploadController@deleteFile'); -//transfer item - Route::get('transfer-items', 'TransferItemController@items'); - Route::get('transfer-my-items', 'TransferItemController@myItems'); - Route::get('suspended-transfer-items', 'TransferItemController@suspendedTransfer'); - Route::get('my-suspended-transfer-items', 'TransferItemController@mySuspendedTransfer'); + //TestResults + Route::resource('TestResults', 'TestResultController' , ['except' => 'show']); + Route::get('/TestResults/ListFilterItems', 'TestResultController@listFilterItems'); + Route::post('/TestResults/Verify/{TestResult}/{Value}', 'TestResultController@verifyTestResult'); + Route::post('/TestResults/chart', 'TestResultController@chart'); + Route::post('/TestResult/QRCode/{TestResult}', 'BarCodeController@generateQRcode'); + + //Item + Route::resource('Items', 'ItemController'); + Route::get('/MyItems', 'ItemController@myItems'); + Route::get('/GetItems', 'ItemController@getItems'); + Route::post('Items/ChangeStatus/{Item}', 'ItemController@changeStatus'); + Route::post('Items/ChangeRepair/{Item}', 'ItemController@changeRepair'); + + //Transfer Item + Route::get('suspended-transfer-items', 'TransferItemController@getSuspendedTransfer'); Route::post('transfer-items/{Item}', 'TransferItemController@transfer'); Route::post('transfer-items/ChangeStatus/{Transfer}', 'TransferItemController@changeStatus'); -//transfer package - Route::get('transfer-packages', 'TransferPackageController@packages'); - Route::get('transfer-my-packages', 'TransferPackageController@myPackages'); - Route::get('suspended-transfer-packages', 'TransferPackageController@suspendedTransfer'); - Route::get('my-suspended-transfer-packages', 'TransferPackageController@mySuspendedTransfer'); + //Package + Route::resource('Packages', 'PackageController'); + Route::get('/MyPackages', 'PackageController@myPackages'); + Route::get('/GetPackages', 'PackageController@getPackages'); + + //transfer package + Route::get('suspended-transfer-packages', 'TransferPackageController@getSuspendedTransfer'); Route::post('transfer-packages/{Package}', 'TransferPackageController@transfer'); Route::post('transfer-packages/ChangeStatus/{Transfer}', 'TransferPackageController@changeStatus'); -//export + //export Route::get('export/items', 'ExportController@items'); Route::get('export/packages', 'ExportController@packages'); + + //Media + Route::namespace('Media')->group(function () { + Route::post('store_media', 'StoreMedia'); + Route::delete('destroy_media/{media}', 'DestroyMedia'); + }); }); Route::post('/BarCode/{Code}/{Type?}', 'BarCodeController@generateBarcode');