@@ -429,35 +429,44 @@ public function appload(Request $request): ?string
429429 return null ;
430430 }
431431
432- $ output ['config ' ] = null ;
433- $ output ['custom ' ] = null ;
434-
435432 $ app = Application::single ($ appid );
433+
434+ if (!$ app ) {
435+ return response ()->json (['error ' => 'Application not found. ' ], 404 );
436+ }
437+
436438 $ output = (array )$ app ;
437439
438440 $ appdetails = Application::getApp ($ appid );
439441
442+ if (!$ appdetails ) {
443+ return response ()->json (['error ' => 'Application details not found. ' ], 404 );
444+ }
445+
440446 if ((bool )$ app ->enhanced === true ) {
441447 $ item = $ itemId ? Item::find ($ itemId ) : Item::where ('appid ' , $ appid )->first ();
442- // if(!isset($app->config)) { // class based config
443- $ output ['custom ' ] = className ($ appdetails ->name ) . '.config ' ;
444- $ output ['appvalue ' ] = $ item ->description ;
445- // }
448+
449+ if ($ item ) {
450+ $ output ['custom ' ] = className ($ appdetails ->name ) . '.config ' ;
451+ $ output ['appvalue ' ] = $ item ->description ;
452+ } else {
453+ // Ensure the app is installed if not found
454+ $ output ['custom ' ] = className ($ appdetails ->name ) . '.config ' ;
455+ $ output ['appvalue ' ] = null ;
456+ }
446457 }
447458
448459 $ output ['colour ' ] = ($ app ->tile_background == 'light ' ) ? '#fafbfc ' : '#161b1f ' ;
449460
450461 if (strpos ($ app ->icon , ':// ' ) !== false ) {
451462 $ output ['iconview ' ] = $ app ->icon ;
452463 } elseif (strpos ($ app ->icon , 'icons/ ' ) !== false ) {
453- // Private apps have the icon locally
454464 $ output ['iconview ' ] = URL ::to ('/ ' ) . '/storage/ ' . $ app ->icon ;
455465 $ output ['icon ' ] = str_replace ('icons/ ' , '' , $ output ['icon ' ]);
456466 } else {
457467 $ output ['iconview ' ] = config ('app.appsource ' ) . 'icons/ ' . $ app ->icon ;
458468 }
459469
460-
461470 return json_encode ($ output );
462471 }
463472
0 commit comments