Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,320 changed files
with
114,524 additions
and
102,856 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<code_scheme name="PHPVMS" version="173"> | ||
<option name="RIGHT_MARGIN" value="100" /> | ||
<PHPCodeStyleSettings> | ||
<option name="ALIGN_KEY_VALUE_PAIRS" value="true" /> | ||
<option name="LOWER_CASE_BOOLEAN_CONST" value="true" /> | ||
<option name="LOWER_CASE_NULL_CONST" value="true" /> | ||
<option name="ALIGN_CLASS_CONSTANTS" value="true" /> | ||
<option name="FORCE_SHORT_DECLARATION_ARRAY_STYLE" value="true" /> | ||
</PHPCodeStyleSettings> | ||
<XML> | ||
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" /> | ||
</XML> | ||
<codeStyleSettings language="JAVA"> | ||
<indentOptions> | ||
<option name="CONTINUATION_INDENT_SIZE" value="4" /> | ||
</indentOptions> | ||
</codeStyleSettings> | ||
<codeStyleSettings language="JSON"> | ||
<indentOptions> | ||
<option name="INDENT_SIZE" value="4" /> | ||
</indentOptions> | ||
</codeStyleSettings> | ||
<codeStyleSettings language="PHP"> | ||
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" /> | ||
<option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" /> | ||
</codeStyleSettings> | ||
</code_scheme> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace App\Awards; | ||
|
||
use App\Interfaces\Award; | ||
|
||
/** | ||
* 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 | ||
* @package App\Awards | ||
*/ | ||
class PilotFlightAwards 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 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. | ||
* @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 | ||
* is a parameter or not. You can call it whatever you want, since that would make | ||
* sense with the $param_description. | ||
* @param int|null $number_of_flights The parameters passed in from the UI | ||
* @return bool | ||
*/ | ||
public function check($number_of_flights = null): bool | ||
{ | ||
if (!$number_of_flights) { | ||
$number_of_flights = 100; | ||
} | ||
|
||
return $this->user->flights >= $number_of_flights; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?php | ||
|
||
namespace App\Console; | ||
|
||
use Log; | ||
use Symfony\Component\Process\Process; | ||
|
||
/** | ||
* Class BaseCommand | ||
* @package App\Console | ||
*/ | ||
abstract class Command extends \Illuminate\Console\Command | ||
{ | ||
/** | ||
* @return mixed | ||
*/ | ||
abstract public function handle(); | ||
|
||
/** | ||
* Splice the logger and replace the active handlers with | ||
* the handlers from the "cron" stack in config/logging.php | ||
* | ||
* Close out any of the existing handlers so we don't leave | ||
* file descriptors leaking around | ||
* | ||
* @param string $channel_name Channel name to grab the handlers from | ||
*/ | ||
public function redirectLoggingToStdout($channel_name): void | ||
{ | ||
$logger = app(\Illuminate\Log\Logger::class); | ||
|
||
// Close the existing loggers | ||
try { | ||
$handlers = $logger->getHandlers(); | ||
foreach ($handlers as $handler) { | ||
$handler->close(); | ||
} | ||
} catch (\Exception $e) { | ||
$this->error('Error closing handlers: '.$e->getMessage()); | ||
} | ||
|
||
// Open the handlers for the channel name, | ||
// and then set them to the main logger | ||
try { | ||
$logger->setHandlers( | ||
Log::channel($channel_name)->getHandlers() | ||
); | ||
} catch (\Exception $e) { | ||
$this->error('Couldn\'t splice the logger: '.$e->getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Streaming file reader | ||
* @param $filename | ||
* @return \Generator | ||
*/ | ||
public function readFile($filename): ?\Generator | ||
{ | ||
$fp = fopen($filename, 'rb'); | ||
while (($line = fgets($fp)) !== false) { | ||
$line = rtrim($line, "\r\n"); | ||
if ($line[0] === ';') { | ||
continue; | ||
} | ||
|
||
yield $line; | ||
} | ||
|
||
fclose($fp); | ||
} | ||
|
||
/** | ||
* @param $cmd | ||
* @param bool $return | ||
* @return string | ||
* @throws \Symfony\Component\Process\Exception\RuntimeException | ||
* @throws \Symfony\Component\Process\Exception\LogicException | ||
*/ | ||
public function runCommand($cmd, $return = false, $verbose = true): string | ||
{ | ||
if (\is_array($cmd)) { | ||
$cmd = join(' ', $cmd); | ||
} | ||
|
||
if ($verbose) { | ||
$this->info('Running "'.$cmd.'"'); | ||
} | ||
|
||
$val = ''; | ||
$process = new Process($cmd); | ||
$process->run(function ($type, $buffer) use ($return, &$val) { | ||
if ($return) { | ||
$val .= $buffer; | ||
} else { | ||
echo $buffer; | ||
} | ||
}); | ||
|
||
return $val; | ||
} | ||
} |
Oops, something went wrong.