<NME> UserGroup.php
<BEF> <?php

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

namespace App\Models;

/**
 * @property Group $group
 * @property int $group_id
 * @property int $group_leader
 * @property User $user
 * @property int $user_id
 * @property int $user_pending
 * @property array|null $playmodes
 */
class UserGroup extends Model
{
    public $timestamps = false;
    public $incrementing = false;

    protected $casts = [
        'user_pending' => 'boolean',
    ];
    protected $primaryKey = ':composite';
class UserGroup extends Model
{
    protected $table = 'phpbb_user_group';
    protected $primaryKey = 'group_id';
    public $timestamps = false;

    protected $casts = [
    }

    public function user()
    {
        return $this->belongsTo(User::class, 'user_id');
    }

    public function setPlaymodesAttribute(?array $value): void
    {
        $this->attributes['playmodes'] = $this->group->has_playmodes ? json_encode($value ?? []) : null;
    }

    public function getAttribute($key)
    {
        return match ($key) {
            'group_id',
            'user_id' => $this->getRawAttribute($key),

            'group_leader',
            'user_pending' => (bool) $this->getRawAttribute($key),

            'group' => app('groups')->byIdOrFail($this->group_id),
            'playmodes' => $this->getPlaymodes(),

            'user' => $this->getRelationValue($key),
        };
    }

    private function getPlaymodes(): ?array
    {
        if ($this->group->has_playmodes) {
            $value = $this->getRawAttribute('playmodes');

            return $value === null ? [] : json_decode($value, true);
        }

        return null;
    }
}

<MSG> Remove primaryKey from the model

The table has composite primary key which isn't supported by laravel.

<DFF> @@ -26,7 +26,6 @@ use Illuminate\Database\Eloquent\Model;
 class UserGroup extends Model
 {
     protected $table = 'phpbb_user_group';
-    protected $primaryKey = 'group_id';
     public $timestamps = false;
 
     protected $casts = [

{'addition_count': 0, 'commit_subject': 'Remove primaryKey from the model', 'deletion_count': 1, 'file_extension': '.php', 'lang': 'php', 'license': 'agpl-3.0', 'repo_name': 'ppy/osu-web'}