This file contains hidden or 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
#!/bin/bash | |
echo "Installing dependencies..." | |
composer install --no-dev --optimize-autoloader | |
echo "Setting up .env..." | |
cp .env.example .env | |
echo "Generating application key..." | |
php artisan key:generate |
This file contains hidden or 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
<?php | |
function randomHex(): string { | |
return bin2hex(random_bytes(random_int(10, 20))); | |
} | |
$logTypes = ["INFO", "DEBUG", "WARNING", "ERROR", "CRITICAL"]; | |
$processes = ["sshd", "cron", "init", "systemd", "bash", "php", "nginx", "mysql", "firewalld", "python3", "node"]; | |
while (true) { | |
$timestamp = date("Y-m-d H:i:s"); |
This file contains hidden or 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
<?php | |
class Node { | |
public string $tag; | |
public array $children = []; | |
public function __construct(string $tag) { | |
$this->tag = $tag; | |
} | |
public function addChild(Node $child): void { |
This file contains hidden or 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
<?php | |
class PricingOptionTaxHelper { | |
/** | |
* Resolve the total amount for a pricing option. | |
*/ | |
public static function resolveTotal(PricingOption $pricingOption, bool $format = true): float { | |
$taxPlan = $pricingOption->taxPlan; | |
if ($taxPlan && $taxPlan->type===TaxPlanType::INCLUSIVE) { | |
$total = $pricingOption->price; |
This file contains hidden or 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
<?php | |
class ServiceResponse { | |
private ?string $message = null; | |
private ?bool $success = true; | |
private array $errors = []; | |
private ?ServiceResponse $previous = null; | |
private mixed $data = null; | |
// Getters |
This file contains hidden or 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
<?php | |
trait HasRoles { | |
// Assign a role to the user | |
public function assignRole(string $roleName): void { | |
$role = Role::where('name', $roleName)->first(); | |
if ($role && !$this->hasRole($roleName)) { | |
$this->roles()->attach($role->id); | |
} | |
} |