@@ -31,7 +31,7 @@ public function index(Request $request, $object_type, $id): JsonResponse|array
3131 {
3232
3333 // Check the permissions to make sure the user can view the object
34- $ object = parent ::$ map_object_type [$ object_type ]::withTrashed ()->find ($ id );
34+ $ object = parent ::getMapObjectType () [$ object_type ]::withTrashed ()->find ($ id );
3535 $ this ->authorize ('files ' , $ object );
3636
3737 if (! $ object ) {
@@ -49,7 +49,7 @@ public function index(Request $request, $object_type, $id): JsonResponse|array
4949 'created_at ' ,
5050 ];
5151
52- $ uploads = parent ::$ map_object_type [$ object_type ]::withTrashed ()->find ($ id )->uploads ()
52+ $ uploads = parent ::getMapObjectType () [$ object_type ]::withTrashed ()->find ($ id )->uploads ()
5353 ->with ('adminuser ' );
5454
5555 $ limit = app ('api_limit_value ' );
@@ -97,29 +97,29 @@ public function store(UploadFileRequest $request, $object_type, $id): JsonRespon
9797 // to the object. `manageFiles` is stricter than `files` (used by
9898 // index/show below) so a read-only cascade like the one on
9999 // AssetModelPolicy does not accidentally grant write access.
100- $ object = parent ::$ map_object_type [$ object_type ]::withTrashed ()->find ($ id );
100+ $ object = parent ::getMapObjectType () [$ object_type ]::withTrashed ()->find ($ id );
101101 $ this ->authorize ('manageFiles ' , $ object );
102102
103103 if (! $ object ) {
104104 return response ()->json (Helper::formatStandardApiResponse ('error ' , null , trans ('general.file_upload_status.invalid_object ' )));
105105 }
106106
107107 // If the file storage directory doesn't exist, create it
108- if (! Storage::exists (parent ::$ map_storage_path [$ object_type ])) {
109- Storage::makeDirectory (parent ::$ map_storage_path [$ object_type ], 775 );
108+ if (! Storage::exists (parent ::getMapStoragePath () [$ object_type ])) {
109+ Storage::makeDirectory (parent ::getMapStoragePath () [$ object_type ], 775 );
110110 }
111111
112112 if ($ request ->hasFile ('file ' )) {
113113 // Loop over the attached files and add them to the object
114114 foreach ($ request ->file ('file ' ) as $ file ) {
115- $ file_name = $ request ->handleFile (parent ::$ map_storage_path [$ object_type ], parent ::$ map_file_prefix [$ object_type ].'- ' .$ object ->id , $ file );
115+ $ file_name = $ request ->handleFile (parent ::getMapStoragePath () [$ object_type ], parent ::getMapFilePrefix () [$ object_type ].'- ' .$ object ->id , $ file );
116116 $ files [] = $ file_name ;
117117 $ object ->logUpload ($ file_name , $ request ->input ('notes ' ));
118118 }
119119
120120 if (isset ($ files )) {
121121 $ file_results = Actionlog::select ('action_logs.* ' )->where ('action_type ' , '= ' , 'uploaded ' )
122- ->where ('item_type ' , '= ' , parent ::$ map_object_type [$ object_type ])
122+ ->where ('item_type ' , '= ' , parent ::getMapObjectType () [$ object_type ])
123123 ->where ('item_id ' , '= ' , $ id )->whereIn ('filename ' , $ files )
124124 ->get ();
125125
@@ -147,25 +147,25 @@ public function store(UploadFileRequest $request, $object_type, $id): JsonRespon
147147 public function show ($ object_type , $ id , $ file_id ): JsonResponse |StreamedResponse |Storage |StorageHelper |BinaryFileResponse
148148 {
149149 // Check the permissions to make sure the user can view the object
150- $ object = parent ::$ map_object_type [$ object_type ]::withTrashed ()->find ($ id );
150+ $ object = parent ::getMapObjectType () [$ object_type ]::withTrashed ()->find ($ id );
151151 $ this ->authorize ('files ' , $ object );
152152
153153 if (! $ object ) {
154154 return response ()->json (Helper::formatStandardApiResponse ('error ' , null , trans ('general.file_upload_status.invalid_object ' )));
155155 }
156156
157157 // Check that the file being requested exists for the object
158- if (! $ log = Actionlog::whereNotNull ('filename ' )->where ('item_type ' , parent ::$ map_object_type [$ object_type ])->where ('item_id ' , $ object ->id )->find ($ file_id )
158+ if (! $ log = Actionlog::whereNotNull ('filename ' )->where ('item_type ' , parent ::getMapObjectType () [$ object_type ])->where ('item_id ' , $ object ->id )->find ($ file_id )
159159 ) {
160160 return response ()->json (Helper::formatStandardApiResponse ('error ' , null , trans ('general.file_upload_status.invalid_id ' )), 200 );
161161 }
162162
163- if (! Storage::exists (parent ::$ map_storage_path [$ object_type ].$ log ->filename )) {
163+ if (! Storage::exists (parent ::getMapStoragePath () [$ object_type ].$ log ->filename )) {
164164 return response ()->json (Helper::formatStandardApiResponse ('error ' , null , trans ('general.file_upload_status.file_not_found ' ), 200 ));
165165 }
166166
167167 if (request ('inline ' ) == 'true ' ) {
168- $ path = parent ::$ map_storage_path [$ object_type ];
168+ $ path = parent ::getMapStoragePath () [$ object_type ];
169169
170170 // Only allowlisted extensions may be served inline. Everything
171171 // else (including XML, which can pull an XSLT stylesheet and
@@ -180,7 +180,7 @@ public function show($object_type, $id, $file_id): JsonResponse|StreamedResponse
180180 ]);
181181 }
182182
183- return StorageHelper::downloader (parent ::$ map_storage_path [$ object_type ].$ log ->filename );
183+ return StorageHelper::downloader (parent ::getMapStoragePath () [$ object_type ].$ log ->filename );
184184
185185 }
186186
@@ -201,7 +201,7 @@ public function destroy($object_type, $id, $file_id): JsonResponse
201201
202202 // See store(): `manageFiles` is the strict write ability so a
203203 // read-only cascade in files() does not authorize deletion.
204- $ object = parent ::$ map_object_type [$ object_type ]::withTrashed ()->find ($ id );
204+ $ object = parent ::getMapObjectType () [$ object_type ]::withTrashed ()->find ($ id );
205205 $ this ->authorize ('manageFiles ' , $ object );
206206
207207 if (! $ object ) {
@@ -212,14 +212,14 @@ public function destroy($object_type, $id, $file_id): JsonResponse
212212 $ log = Actionlog::query ()
213213 ->where ('id ' , $ file_id )
214214 ->where ('action_type ' , 'uploaded ' )
215- ->where ('item_type ' , parent ::$ map_object_type [$ object_type ])
215+ ->where ('item_type ' , parent ::getMapObjectType () [$ object_type ])
216216 ->where ('item_id ' , $ object ->id )
217217 ->first ();
218218
219219 if ($ log ) {
220220 // Check the file actually exists, and delete it
221- if (Storage::exists (parent ::$ map_storage_path [$ object_type ].$ log ->filename )) {
222- Storage::delete (parent ::$ map_storage_path [$ object_type ].$ log ->filename );
221+ if (Storage::exists (parent ::getMapStoragePath () [$ object_type ].$ log ->filename )) {
222+ Storage::delete (parent ::getMapStoragePath () [$ object_type ].$ log ->filename );
223223 }
224224 // Delete the record of the file
225225 if ($ log ->logUploadDelete ($ object , $ log ->filename )) {
0 commit comments