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

Adding a new AwardClass for Flight Time #869

Merged
merged 6 commits into from
Oct 13, 2020
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions modules/Awards/Awards/PilotHoursAwards.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace Modules\Awards\Awards;

use App\Contracts\Award;

/**
* All award classes need to extend Award and implement the check() method
* This award is based on the original PilotFlightAwards.php file but
* checks the Pilots Flight Time (In Minutes).
* This award means you can create an award for a pilot that completes any
* amount of flight time (In Minutes).
*
* See: https://docs.phpvms.net/developers/awards
*/
class PilotHoursAwards extends Award
{
/**
* Set the name of this award class to make it easier to see when
* assigning to a specific award
*
* @var string
*/
public $name = 'Pilot Flight Time';

/**
* The description to show under the parameters field, so the admin knows
* what the parameter actually controls. You can leave this blank if there
* isn't a parameter.
*
* @var string
*/
public $param_description = 'Amount of flight time in Minutes at which to give this award';

/**
* If the user has over N minutes of flights, then we can give them this award.
*
* If no parameter is passed in, just default it to 99999. You should check if there
* is a parameter or not. You can call it whatever you want, since that would make
* sense with the $param_description.
*
* @param int|null $flight_minutes The parameters passed in from the UI
*
* @return bool
*/
public function check($flight_minutes = null): bool
{
if (!$flight_minutes) {
nabeelio marked this conversation as resolved.
Show resolved Hide resolved
$flight_minutes = 99999;
}
if (!is_int($flight_minutes)) {
return false;
}

return $this->user->flight_time >= (int) $flight_minutes;
}
}