Return value was placed in an array, this altered the response from the array which could break existing implementations
This commit is contained in:
parent
e8a4f3d97f
commit
2249738446
|
@ -7,14 +7,15 @@ use App\Models\Server;
|
|||
use Exception;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Spatie\QueryBuilder\QueryBuilder;
|
||||
|
||||
class ServerController extends Controller
|
||||
{
|
||||
const ALLOWED_INCLUDES = ['product', 'user'];
|
||||
const ALLOWED_FILTERS = ['name', 'suspended', 'identifier', 'pterodactyl_id', 'user_id', 'product_id'];
|
||||
public const ALLOWED_INCLUDES = ['product', 'user'];
|
||||
public const ALLOWED_FILTERS = ['name', 'suspended', 'identifier', 'pterodactyl_id', 'user_id', 'product_id'];
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
|
@ -35,7 +36,8 @@ class ServerController extends Controller
|
|||
* Display the specified resource.
|
||||
*
|
||||
* @param Server $server
|
||||
* @return Server|Collection
|
||||
*
|
||||
* @return Server|Collection|Model
|
||||
*/
|
||||
public function show(Server $server)
|
||||
{
|
||||
|
@ -43,7 +45,7 @@ class ServerController extends Controller
|
|||
->where('id', '=', $server->id)
|
||||
->allowedIncludes(self::ALLOWED_INCLUDES);
|
||||
|
||||
return $query->get();
|
||||
return $query->firstOrFail();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,6 +13,7 @@ use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
|||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\App;
|
||||
|
@ -47,7 +48,8 @@ class UserController extends Controller
|
|||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return User|Collection
|
||||
*
|
||||
* @return User|Builder|Collection|Model
|
||||
*/
|
||||
public function show(int $id)
|
||||
{
|
||||
|
@ -62,7 +64,7 @@ class UserController extends Controller
|
|||
$builder->where('id', '=', $id);
|
||||
});
|
||||
|
||||
return $query->get();
|
||||
return $query->firstOrFail();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
|
|||
use App\Models\Voucher;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
@ -63,7 +64,8 @@ class VoucherController extends Controller
|
|||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return Collection|Voucher
|
||||
*
|
||||
* @return Voucher|Collection|Model
|
||||
*/
|
||||
public function show(int $id)
|
||||
{
|
||||
|
@ -71,7 +73,7 @@ class VoucherController extends Controller
|
|||
->where('id', '=', $id)
|
||||
->allowedIncludes(self::ALLOWED_INCLUDES);
|
||||
|
||||
return $query->get();
|
||||
return $query->firstOrFail();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue