Skip to content

Commit

Permalink
use incrementing ids for team ids
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Sep 6, 2020
1 parent 49e57d4 commit 71b67f1
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 6 additions & 6 deletions src/Http/Controllers/Inertia/TeamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions src/Http/Controllers/Inertia/TeamMemberController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
*/
Expand All @@ -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
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/Livewire/TeamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
14 changes: 0 additions & 14 deletions src/Team.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
12 changes: 0 additions & 12 deletions stubs/app/Models/Team.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
}

0 comments on commit 71b67f1

Please sign in to comment.