From 71b67f1e04f6c06741b910ff999aa6370b3ba970 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 4 Sep 2020 21:12:11 -0500 Subject: [PATCH] use incrementing ids for team ids --- .../2020_05_21_100000_create_teams_table.php | 2 +- .../2020_05_21_200000_create_team_user_table.php | 2 +- src/Http/Controllers/Inertia/TeamController.php | 12 ++++++------ .../Controllers/Inertia/TeamMemberController.php | 6 +++--- src/Http/Controllers/Livewire/TeamController.php | 4 ++-- src/Team.php | 14 -------------- stubs/app/Models/Team.php | 12 ------------ 7 files changed, 13 insertions(+), 39 deletions(-) diff --git a/database/migrations/2020_05_21_100000_create_teams_table.php b/database/migrations/2020_05_21_100000_create_teams_table.php index 84799c3f1..6a41190c5 100644 --- a/database/migrations/2020_05_21_100000_create_teams_table.php +++ b/database/migrations/2020_05_21_100000_create_teams_table.php @@ -14,7 +14,7 @@ class CreateTeamsTable extends Migration public function up() { Schema::create('teams', function (Blueprint $table) { - $table->uuid('id')->primary(); + $table->id(); $table->foreignId('user_id')->index(); $table->string('name'); $table->boolean('personal_team'); diff --git a/database/migrations/2020_05_21_200000_create_team_user_table.php b/database/migrations/2020_05_21_200000_create_team_user_table.php index a3c6ef869..a9b4e956d 100644 --- a/database/migrations/2020_05_21_200000_create_team_user_table.php +++ b/database/migrations/2020_05_21_200000_create_team_user_table.php @@ -15,7 +15,7 @@ public function up() { Schema::create('team_user', function (Blueprint $table) { $table->id(); - $table->uuid('team_id'); + $table->foreignId('team_id'); $table->foreignId('user_id'); $table->string('role')->nullable(); $table->timestamps(); diff --git a/src/Http/Controllers/Inertia/TeamController.php b/src/Http/Controllers/Inertia/TeamController.php index 0082acbad..dfef721e0 100644 --- a/src/Http/Controllers/Inertia/TeamController.php +++ b/src/Http/Controllers/Inertia/TeamController.php @@ -18,10 +18,10 @@ class TeamController extends Controller * Show the team management screen. * * @param \Illuminate\Http\Request $request - * @param string $teamId + * @param mixed $teamId * @return \Inertia\Response */ - public function show(Request $request, string $teamId) + public function show(Request $request, $teamId) { $team = Jetstream::newTeamModel()->findOrFail($teamId); @@ -71,10 +71,10 @@ public function store(Request $request) * Update the given team's name. * * @param \Illuminate\Http\Request $request - * @param string $teamId + * @param mixed $teamId * @return \Illuminate\Http\RedirectResponse */ - public function update(Request $request, string $teamId) + public function update(Request $request, $teamId) { $team = Jetstream::newTeamModel()->findOrFail($teamId); @@ -87,10 +87,10 @@ public function update(Request $request, string $teamId) * Delete the given team. * * @param \Illuminate\Http\Request $request - * @param string $teamId + * @param mixed $teamId * @return \Illuminate\Http\RedirectResponse */ - public function destroy(Request $request, string $teamId) + public function destroy(Request $request, $teamId) { $team = Jetstream::newTeamModel()->findOrFail($teamId); diff --git a/src/Http/Controllers/Inertia/TeamMemberController.php b/src/Http/Controllers/Inertia/TeamMemberController.php index f1688c610..898c7fe71 100644 --- a/src/Http/Controllers/Inertia/TeamMemberController.php +++ b/src/Http/Controllers/Inertia/TeamMemberController.php @@ -15,7 +15,7 @@ class TeamMemberController extends Controller * Add a new team member to a team. * * @param \Illuminate\Http\Request $request - * @param string $teamId + * @param mixed $teamId * @return \Illuminate\Http\RedirectResponse */ public function store(Request $request, $teamId) @@ -36,7 +36,7 @@ public function store(Request $request, $teamId) * Update the given team member's role. * * @param \Illuminate\Http\Request $request - * @param string $teamId + * @param mixed $teamId * @param int $userId * @return \Illuminate\Http\RedirectResponse */ @@ -56,7 +56,7 @@ public function update(Request $request, $teamId, $userId) * Remove the given user from the given team. * * @param \Illuminate\Http\Request $request - * @param string $teamId + * @param mixed $teamId * @param int $userId * @return \Illuminate\Http\RedirectResponse */ diff --git a/src/Http/Controllers/Livewire/TeamController.php b/src/Http/Controllers/Livewire/TeamController.php index 9bf54c114..db60b2f56 100644 --- a/src/Http/Controllers/Livewire/TeamController.php +++ b/src/Http/Controllers/Livewire/TeamController.php @@ -12,10 +12,10 @@ class TeamController extends Controller * Show the team management screen. * * @param \Illuminate\Http\Request $request - * @param string $teamId + * @param mixed $teamId * @return \Illuminate\View\View */ - public function show(Request $request, string $teamId) + public function show(Request $request, $teamId) { $team = Jetstream::newTeamModel()->findOrFail($teamId); diff --git a/src/Team.php b/src/Team.php index 9a2a242e0..40dab97ff 100644 --- a/src/Team.php +++ b/src/Team.php @@ -6,20 +6,6 @@ abstract class Team extends Model { - /** - * The "type" of the primary key ID. - * - * @var string - */ - protected $keyType = 'string'; - - /** - * Indicates if the IDs are auto-incrementing. - * - * @var bool - */ - public $incrementing = false; - /** * Get the owner of the team. */ diff --git a/stubs/app/Models/Team.php b/stubs/app/Models/Team.php index 0fffbe14d..fcf699f7b 100644 --- a/stubs/app/Models/Team.php +++ b/stubs/app/Models/Team.php @@ -40,16 +40,4 @@ class Team extends JetstreamTeam 'updated' => TeamUpdated::class, 'deleted' => TeamDeleted::class, ]; - - /** - * Handle the model "booted" event. - * - * @return void - */ - public static function booted() - { - static::creating(function ($model) { - $model->id = $model->id ?: (string) Str::orderedUuid(); - }); - } }