Add all files

This commit is contained in:
root
2025-11-30 11:57:22 +01:00
parent 2ee51cac4f
commit 044271db3d
1476 changed files with 142544 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
<?php
namespace App\Console\Commands\Extension;
use App\Models\Extension;
use Illuminate\Console\Command;
use Illuminate\Contracts\Console\PromptsForMissingInput;
class Create extends Command implements PromptsForMissingInput
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:extension:create {name} {type} {--force}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new extension';
public function handle()
{
$name = $this->argument('name');
$type = $this->argument('type');
if (!in_array($type, ['server', 'gateway', 'other'])) {
$this->error('Invalid extension type. Valid types are: server, gateway, event');
return;
}
// Read stub file contents
$stub = file_get_contents(__DIR__ . '/stubs/' . $type . '.stub');
// Replace placeholders with actual values
$stub = str_replace('{{ class }}', ucfirst($name), $stub);
$stub = str_replace('{{ namespace }}', 'Paymenter\\Extensions\\' . ucfirst($type) . 's' . '\\' . ucfirst($name), $stub);
// Create the extension file
$path = base_path('extensions/' . ucfirst($type) . 's/' . ucfirst($name) . '/' . ucfirst($name) . '.php');
if (file_exists(dirname($path)) && !$this->option('force')) {
$this->error("Extension already exists\nRerun the command with a different name or use --force to overwrite");
return;
}
if (!file_exists(dirname($path))) {
mkdir(dirname($path), 0755, true);
}
file_put_contents($path, $stub);
// Return path
$this->info("Extension created at: {$path}");
}
/**
* Prompt for missing input arguments using the returned questions.
*
* @return array
*/
protected function promptForMissingArgumentsUsing()
{
return [
'name' => 'What is the name of the extension?',
'type' => function () {
$type = $this->choice('What type of extension?', ['server', 'gateway', 'other']);
return $type;
},
];
}
}

View File

@@ -0,0 +1,54 @@
<?php
namespace App\Console\Commands\Extension;
use App\Models\Extension;
use Illuminate\Console\Command;
use Illuminate\Contracts\Console\PromptsForMissingInput;
use function Laravel\Prompts\select;
class Disable extends Command implements PromptsForMissingInput
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:extension:disable {name}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Disable a extension if it causes issues';
public function handle()
{
$name = $this->argument('name');
$extension = Extension::where('extension', $name)->first();
if (!$extension) {
$this->error('Extension not found');
return;
}
$extension->update(['enabled' => false]);
$this->info('Extension disabled');
}
/**
* Prompt for missing input arguments using the returned questions.
*
* @return array
*/
protected function promptForMissingArgumentsUsing()
{
return [
'name' => fn () => select(
label: 'Which extension do you want to disable?',
options: Extension::all()->pluck('extension', 'extension')->toArray(),
),
];
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace {{ namespace }};
use App\Classes\Extension\Gateway;
use App\Models\Invoice;
class {{ class }} extends Gateway
{
/**
* Get all the configuration for the extension
*
* @param array $values
* @return array
*/
public function getConfig($values = [])
{
return [];
}
/**
* Return a view or a url to redirect to
*
* @param Invoice $invoice
* @param float $total
* @return string
*/
public function pay(Invoice $invoice, $total)
{
return '';
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace {{ namespace }};
use App\Classes\Extension\Extension;
class {{ class }} extends Extension
{
/**
* Get all the configuration for the extension
*
* @param array $values
* @return array
*/
public function getConfig($values = [])
{
return [];
}
}

View File

@@ -0,0 +1,92 @@
<?php
namespace {{ namespace }};
use App\Classes\Extension\Server;
use App\Models\Service;
class {{ class }} extends Server
{
/**
* Get all the configuration for the extension
*
* @param array $values
* @return array
*/
public function getConfig($values = []): array
{
return [];
}
/**
* Get product config
*
* @param array $values
* @return array
*/
public function getProductConfig($values = []): array
{
return [];
}
/**
* Check if currenct configuration is valid
*
* @return bool|string
*/
public function testConfig(): bool|string
{
return true;
}
/**
* Create a server for the service.
*
* @param Service $service The service that is being created.
* @param array $settings The settings that are provided on the product from `getProductConfig`.
* @param array $properties Custom properties created by the admin and values coming from `getCheckoutConfig`.
*/
public function createServer(Service $service, $settings, $properties)
{
return false;
}
/**
* Suspend a server
*
* @param Service $service
* @param array $settings (product settings)
* @param array $properties (checkout options)
* @return bool
*/
public function suspendServer(Service $service, $settings, $properties)
{
return false;
}
/**
* Unsuspend a server
*
* @param Service $service
* @param array $settings (product settings)
* @param array $properties (checkout options)
* @return bool
*/
public function unsuspendServer(Service $service, $settings, $properties)
{
return false;
}
/**
* Terminate a server
*
* @param Service $service
* @param array $settings (product settings)
* @param array $properties (checkout options)
* @return bool
*/
public function terminateServer(Service $service, $settings, $properties)
{
return false;
}
}