2018-03-18 00:35:34 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Awards;
|
|
|
|
|
2019-07-16 03:44:31 +08:00
|
|
|
use App\Contracts\Award;
|
2018-03-18 00:35:34 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Simple example of an awards class, where you can apply an award when a user
|
|
|
|
* has 100 flights. All award classes need to extend the AwardInterface
|
|
|
|
*/
|
2018-03-20 09:50:40 +08:00
|
|
|
class PilotFlightAwards extends Award
|
2018-03-18 00:35:34 +08:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Set the name of this award class to make it easier to see when
|
|
|
|
* assigning to a specific award
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-03-18 00:35:34 +08:00
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $name = 'Pilot Flights';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-03-18 00:35:34 +08:00
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $param_description = 'The number of flights at which to give this award';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If the user has over N flights, then we can give them this award. This method
|
|
|
|
* only needs to return a true or false of whether it should be awarded or not.
|
|
|
|
*
|
|
|
|
* If no parameter is passed in, just default it to 100. You should check if there
|
2018-03-18 07:38:09 +08:00
|
|
|
* is a parameter or not. You can call it whatever you want, since that would make
|
|
|
|
* sense with the $param_description.
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-03-18 07:38:09 +08:00
|
|
|
* @param int|null $number_of_flights The parameters passed in from the UI
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-03-18 00:35:34 +08:00
|
|
|
* @return bool
|
|
|
|
*/
|
2018-03-18 07:38:09 +08:00
|
|
|
public function check($number_of_flights = null): bool
|
2018-03-18 00:35:34 +08:00
|
|
|
{
|
2018-03-20 09:50:40 +08:00
|
|
|
if (!$number_of_flights) {
|
2018-03-18 07:38:09 +08:00
|
|
|
$number_of_flights = 100;
|
2018-03-18 00:35:34 +08:00
|
|
|
}
|
|
|
|
|
2018-03-18 07:38:09 +08:00
|
|
|
return $this->user->flights >= $number_of_flights;
|
2018-03-18 00:35:34 +08:00
|
|
|
}
|
|
|
|
}
|