Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking out specific seats for licenses #5887

Merged
merged 1 commit into from
Jul 24, 2018

Conversation

Azerothian
Copy link
Contributor

When a user clicks checkout on the seat page in licences, it will specifically checkout that seat for the assigned user or asset.

relates to #4413

@Azerothian Azerothian requested a review from snipe as a code owner July 19, 2018 03:19
return redirect()->route('licenses.index')->with('error', 'There are no available seats for this license');
}
} else {
$licenseSeat = LicenseSeat::where('id', '=', $seatId)->first();
Copy link
Owner

Choose a reason for hiding this comment

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

We should probably confirm that the license seat belongs to the license ID we think it does here, no? And fail with an error if the seat ID doesn't match the license ID?

$licenseSeat = LicenseSeat::where('id', '=', $seatId)->first();
if (!$licenseSeat) {
return redirect()->route('licenses.index')->with('error', 'License seat is not available for checkout');
}
Copy link
Contributor

@dmeltzer dmeltzer Jul 19, 2018

Choose a reason for hiding this comment

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

This looks great--I wonder if it's cleaner to do something like:

$licenseSeat = LicenseSeat::find($seatId); // This will return null if seatId is null.
if (is_null($licenseSeat) {
    $licenseSeat = $license->freeSeat();
    if (!$licenseSeat) { return "No Available seats" }
}

Would seem to keep the logic a little cleaner... I know this predates you, but part of the logic above can be consensed as LicenseSeat::where('id', '=', $licenseSeat->id), which just seems silly :)

Copy link
Owner

Choose a reason for hiding this comment

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

@Azerothian Are you interesting in the rework @dmeltzer suggested here? I don't want to merge if you're working on that.

Copy link
Owner

Choose a reason for hiding this comment

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

(Also, Lok'tar ogar!)

Copy link
Contributor

@dmeltzer dmeltzer Jul 23, 2018

Choose a reason for hiding this comment

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

I reworked this method quite a bit in #5916. -- https://github.com/snipe/snipe-it/pull/5916/files#diff-150d5333297ece1729c0c3ef7c758630R56 Might be better to just merge here as-is and then I'll touch that when I rebase the monster.

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.

3 participants