Skip to content

Add $guarded to UserStatus model to fix bookmarklet mass assignment error#1000

Merged
slime-hatena merged 4 commits intodevelopfrom
copilot/fix-46584016-143313092-c80ed2d5-f0b4-4179-936b-46f1a79e3f17
Nov 3, 2025
Merged

Add $guarded to UserStatus model to fix bookmarklet mass assignment error#1000
slime-hatena merged 4 commits intodevelopfrom
copilot/fix-46584016-143313092-c80ed2d5-f0b4-4179-936b-46f1a79e3f17

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 3, 2025

The UserStatus model was missing mass assignment protection, causing MassAssignmentException when the bookmarklet attempted to create user status records.

Changes

  • Added $guarded = ['id'] property to UserStatus model to protect only the auto-increment id field from mass assignment
  • This allows all other fields (user_id, trophy, level, name, battle_point, rating, rating_max, money, total_money, total_play, comment, friend_code, unique_id, created_at, updated_at) to be mass assigned
  • Follows the blacklist approach consistent with other models in the codebase (ApplicationVersion, CharacterFriendly, MusicData, etc.)
class UserStatus extends Model
{
    protected $table = "user_status";

    protected $guarded = ['id'];

This approach is more maintainable than listing all fillable fields and aligns with the project's established pattern.

[!WARNING]

Original prompt

This section details on the original issue you should resolve

<filter_complete></filter_complete>

<issue_title>ブックマークレット実行時 Add [user_id] to fillable property to allow mass assignment on [App\UserStatus].</issue_title>
<issue_description>0.21.2...0.22.0#diff-3532fb886064a45a3c08a87d82e6d3cf52b8a4332fa8967857c8bd7ba971f5a1L11
多分これ
消しちゃダメ 気づかなかった…</issue_description>

Comments on the Issue (you are @copilot in this section)

Original prompt

This section details on the original issue you should resolve

<issue_title>ブックマークレット実行時 Add [user_id] to fillable property to allow mass assignment on [App\UserStatus].</issue_title>
<issue_description>0.21.2...0.22.0#diff-3532fb886064a45a3c08a87d82e6d3cf52b8a4332fa8967857c8bd7ba971f5a1L11
多分これ
消しちゃダメ 気づかなかった…</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: slime-hatena <11350340+slime-hatena@users.noreply.github.com>
@slime-hatena
Copy link
Copy Markdown
Member

@copilot 逆にしてほしい Guard id

Copilot AI changed the title [WIP] ブックマークレット実行時 Add [user_id] to fillable property to allow mass assignment on [App\UserStatus]. Add $fillable to UserStatus model to fix bookmarklet mass assignment error Nov 3, 2025
Copilot AI requested a review from slime-hatena November 3, 2025 03:23
Co-authored-by: slime-hatena <11350340+slime-hatena@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Nov 3, 2025

@copilot 逆にしてほしい Guard id

Changed to use $guarded = ['id'] instead of $fillable array. This matches the pattern used by other models in the codebase. (7bf30c3)

Copilot AI changed the title Add $fillable to UserStatus model to fix bookmarklet mass assignment error Add $guarded to UserStatus model to fix bookmarklet mass assignment error Nov 3, 2025
@github-actions github-actions bot added the Scope: Application Edited Application files label Nov 3, 2025
@slime-hatena slime-hatena added the Type: Bug Bug or Bug fixes label Nov 3, 2025
@slime-hatena slime-hatena marked this pull request as ready for review November 3, 2025 16:52
Copilot AI review requested due to automatic review settings November 3, 2025 16:52
@slime-hatena slime-hatena merged commit 5d5a436 into develop Nov 3, 2025
1 check passed
@slime-hatena slime-hatena deleted the copilot/fix-46584016-143313092-c80ed2d5-f0b4-4179-936b-46f1a79e3f17 branch November 3, 2025 16:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds mass assignment protection to the UserStatus model by introducing the $guarded property to protect the id field from being mass-assigned.

  • Added protected $guarded = ['id']; to the UserStatus model to align with Laravel security best practices

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Application Edited Application files Type: Bug Bug or Bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ブックマークレット実行時 Add [user_id] to fillable property to allow mass assignment on [App\UserStatus].

3 participants