Explorar el Código

Update ProfileSponsorController

Daniel Supernault hace 6 años
padre
commit
bd61a921e8
Se han modificado 1 ficheros con 3 adiciones y 2 borrados
  1. 3 2
      app/Http/Controllers/ProfileSponsorController.php

+ 3 - 2
app/Http/Controllers/ProfileSponsorController.php

@@ -10,7 +10,8 @@ class ProfileSponsorController extends Controller
 {
 	public function get(Request $request, $id)
 	{
-		$res = ProfileSponsor::whereProfileId($id)->firstOrFail()->sponsors;
-		return response($res)->header('Content-Type', 'application/json');
+		$profile = ProfileSponsor::whereProfileId($id)->first();
+		$res = $profile ? $profile->sponsors : [];
+		return response()->json($res);
 	}
 }