Skip to content

Conversation

@MZanggl
Copy link
Contributor

@MZanggl MZanggl commented Oct 20, 2019

Proposed changes

Adds a little helper method to the Model instance to verify that two models are "the same".
Inspiration: https://laravel.com/docs/5.8/eloquent#comparing-models
Documentation PR: adonisjs/legacy-docs#382

Types of changes

What types of changes does your code introduce?

Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if appropriate)

@coveralls
Copy link

Coverage Status

Coverage increased (+0.002%) to 96.508% when pulling 5cd5aaa on MZanggl:feature/is into 6cd666d on adonisjs:develop.

@RomainLanz
Copy link
Member

I like that, nice one!

Waiting for @thetutlage to review it.

@thetutlage
Copy link
Member

May I know what use case it serves?

@MZanggl
Copy link
Contributor Author

MZanggl commented Jan 18, 2020

It's a convenience method, say for example in a user profile controller

class ProfileController {
  async show({ params, auth }) {
    const user = await User.firstOrFail(params.id)

    const canEdit = auth.user.is(user)
  }
}

@thetutlage
Copy link
Member

Okay, that kind of makes sense. Would you mind creating a PR for branch v6.1.3?

The develop branch has code that targets the v5 of the framework

@MZanggl MZanggl changed the base branch from develop to v6.1.3 January 20, 2020 12:22
@MZanggl
Copy link
Contributor Author

MZanggl commented Jan 20, 2020

I changed the base branch.

@thetutlage thetutlage closed this Jul 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants