fix issue "user can create a package only from his items"

This commit is contained in:
Moradi
2025-02-27 14:46:14 +03:30
parent a4392b74c9
commit 9bf95438b7
+4 -4
View File
@@ -111,13 +111,13 @@ class ItemController extends Controller
public function getItems() public function getItems()
{ {
$user = auth()->user(); $userId = auth('api')->user()->id;
$medicalCenterId = optional(optional($user)->medical_center)->id; // $medicalCenterId = optional(optional($user)->medical_center)->id;
$userIds = User::where('medical_center_id', $medicalCenterId)->pluck('id')->toArray(); // $userIds = User::where('medical_center_id', $medicalCenterId)->pluck('id')->toArray();
$Items = Item::where( "status" , StatusTypeEnum::APPROVED ) $Items = Item::where( "status" , StatusTypeEnum::APPROVED )
->where( "package_id" , null ) ->where( "package_id" , null )
->whereIn('creator_id', $userIds) ->whereIn('creator_id', $userId)
->orderByDesc( 'id' ) ->orderByDesc( 'id' )
->isNotRepaired() ->isNotRepaired()
->get(); ->get();