Browse Source

Update ProfileSponsorController

Daniel Supernault 5 năm trước cách đây
mục cha
commit
bd61a921e8
1 tập tin đã thay đổi với 3 bổ sung2 xóa
  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);
 	}
 }