Add create and show page for competition
This commit is contained in:
parent
1485f3daf5
commit
744308d0cb
10 changed files with 151 additions and 72 deletions
|
@ -39,14 +39,8 @@ class TournamentController extends Controller
|
|||
'description' => 'nullable|string',
|
||||
'location' => 'nullable|string|max:255',
|
||||
'start_date' => 'required|date',
|
||||
'end_date' => 'required|date|after_or_equal:start_date',
|
||||
'registration_deadline' => 'nullable|date|before_or_equal:start_date',
|
||||
'max_teams' => 'nullable|integer|min:2',
|
||||
'status' => 'required|in:draft,public,private',
|
||||
'team_ids' => 'nullable|array',
|
||||
'team_ids.*' => 'exists:teams,id',
|
||||
'field_ids' => 'nullable|array',
|
||||
'field_ids.*' => 'exists:fields,id',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
@ -59,23 +53,11 @@ class TournamentController extends Controller
|
|||
$tournament->description = $request->description;
|
||||
$tournament->location = $request->location;
|
||||
$tournament->start_date = $request->start_date;
|
||||
$tournament->end_date = $request->end_date;
|
||||
$tournament->registration_deadline = $request->registration_deadline;
|
||||
$tournament->max_teams = $request->max_teams;
|
||||
$tournament->status = $request->status;
|
||||
$tournament->owner = Auth::id();
|
||||
$tournament->save();
|
||||
|
||||
// Associate teams with the tournament
|
||||
if ($request->has('team_ids') && is_array($request->team_ids)) {
|
||||
$tournament->teams()->attach($request->team_ids, ['status' => 'confirmed']);
|
||||
}
|
||||
|
||||
// Associate fields with the tournament
|
||||
if ($request->has('field_ids') && is_array($request->field_ids)) {
|
||||
$tournament->fields()->attach($request->field_ids);
|
||||
}
|
||||
|
||||
// Create a default scheduling mode
|
||||
$schedulingMode = new SchedulingMode();
|
||||
$schedulingMode->competition_id = $tournament->id;
|
||||
|
|
|
@ -20,7 +20,6 @@ class Competition extends Model
|
|||
'name',
|
||||
'description',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'status',
|
||||
'location',
|
||||
'max_teams',
|
||||
|
|
|
@ -4,7 +4,9 @@ namespace App\Providers;
|
|||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
|
@ -65,5 +67,15 @@ class AppServiceProvider extends ServiceProvider
|
|||
|
||||
return false;
|
||||
});
|
||||
|
||||
DB::listen(function ($query) {
|
||||
Log::info(
|
||||
$query->sql,
|
||||
[
|
||||
'bindings' => $query->bindings,
|
||||
'time' => $query->time,
|
||||
]
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue