homepage and logo
This commit is contained in:
parent
c9d982669a
commit
ef6dadb148
12 changed files with 359 additions and 242 deletions
|
@ -3,13 +3,13 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Competition;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class CompetitionController extends Controller
|
||||
{
|
||||
|
||||
public static function getPublicCompetitions(int $skip = 0, int $take = 10): JsonResponse
|
||||
public static function getPublics(int $skip = 0, int $take = 10): JsonResponse
|
||||
{
|
||||
if ($skip < 0) {
|
||||
$skip = 0;
|
||||
|
@ -37,6 +37,35 @@ class CompetitionController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
public static function getUser(User $user, int $skip = 0, int $take = 10): JsonResponse
|
||||
{
|
||||
if ($skip < 0) {
|
||||
$skip = 0;
|
||||
}
|
||||
if ($take < 1 || $take > 100) {
|
||||
$take = 10;
|
||||
}
|
||||
|
||||
$query = Competition::where('owner', $user->id);
|
||||
|
||||
$competitions = $query->orderBy('start_date', 'desc')
|
||||
->skip($skip)
|
||||
->take($take)
|
||||
->get();
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
return response()->json([
|
||||
'data' => $competitions,
|
||||
'meta' => [
|
||||
'skip' => $skip,
|
||||
'take' => $take,
|
||||
'total' => $total,
|
||||
'hasMore' => ($skip + $take) < $total
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all public competitions/tournaments with pagination.
|
||||
*
|
||||
|
|
|
@ -25,6 +25,7 @@ class Competition extends Model
|
|||
'location',
|
||||
'max_teams',
|
||||
'current_scheduling_mode_id',
|
||||
'owner',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue