Compare commits
102 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
732ed7ea43 | ||
|
|
e776ae299a | ||
|
|
b8c07cde53 | ||
|
|
6eb36a84af | ||
|
|
9622a08b74 | ||
|
|
4d11e3939a | ||
|
|
592bc2b0f6 | ||
|
|
33ccdd1b2d | ||
|
|
065773fb6f | ||
|
|
e26a7c2a50 | ||
|
|
022caacb24 | ||
|
|
b5da1367d0 | ||
|
|
175134233b | ||
|
|
072018b122 | ||
|
|
694254cd21 | ||
|
|
8b5c5734c1 | ||
|
|
528868c1df | ||
|
|
ba2b932bb8 | ||
|
|
a986d4316e | ||
|
|
f05206f940 | ||
|
|
2d6a5fa770 | ||
|
|
cd29843a88 | ||
|
|
5a6e742fd9 | ||
|
|
6a991aa320 | ||
|
|
1a61a01628 | ||
|
|
896564990d | ||
|
|
3fa5bb7df9 | ||
|
|
6b6435f71b | ||
|
|
a838f1a1da | ||
|
|
9535f03ff1 | ||
|
|
879fe90f18 | ||
|
|
9e79b4d3c1 | ||
|
|
f8929e5622 | ||
|
|
6556cf017a | ||
|
|
514c010804 | ||
|
|
b3a5624ad4 | ||
|
|
3857aa33d2 | ||
|
|
c625a5c967 | ||
|
|
b4d35adfb4 | ||
|
|
0c1d970a9c | ||
|
|
3df600bcda | ||
|
|
c9e0bb3bda | ||
|
|
3aae5068ce | ||
|
|
255353763f | ||
|
|
99a49848ca | ||
|
|
def9e3c722 | ||
|
|
6cc46cf652 | ||
|
|
9ac72ffda8 | ||
|
|
3f1bdb1d8e | ||
|
|
f3d2b0c71f | ||
|
|
4071ba6d49 | ||
|
|
4ec50d7ca1 | ||
|
|
51b7f28634 | ||
|
|
7f6b59cd4f | ||
|
|
80b4428b72 | ||
|
|
010ecd63ac | ||
|
|
741104de05 | ||
|
|
5254ca3ebe | ||
|
|
aefbb5be33 | ||
|
|
d22bb52f35 | ||
|
|
088d951bea | ||
|
|
01fe642a9d | ||
|
|
258e7127f7 | ||
|
|
7e44db0e56 | ||
|
|
e1c07d84df | ||
|
|
145a4af407 | ||
|
|
d1a7b6002a | ||
|
|
a9c0bdee34 | ||
|
|
604b535895 | ||
|
|
c67546b949 | ||
|
|
0a45a1c8b2 | ||
|
|
3cd83ad69c | ||
|
|
d27df25b3c | ||
|
|
e55e984f98 | ||
|
|
5fbc0e0a37 | ||
|
|
3313786480 | ||
|
|
5ed532535b | ||
|
|
a8361f7b22 | ||
|
|
a190ccf8dc | ||
|
|
3f927f9ec1 | ||
|
|
33692960ff | ||
|
|
1f79a4e790 | ||
|
|
903e1cccc6 | ||
|
|
3f7f6206bd | ||
|
|
be00824f59 | ||
|
|
eb4220adc9 | ||
|
|
3562a60461 | ||
|
|
4d80f26519 | ||
|
|
29dc893806 | ||
|
|
35abe4cfd7 | ||
|
|
275b359b53 | ||
|
|
0be4f4cd94 | ||
|
|
2ffd09877e | ||
|
|
a5d2445e3f | ||
|
|
92631cdee9 | ||
|
|
0f63b8153a | ||
|
|
b6983d5377 | ||
|
|
78899bef61 | ||
|
|
9397651515 | ||
|
|
f692fb681a | ||
|
|
6de17d3e3c | ||
|
|
b2b24db2e6 |
@@ -7,7 +7,8 @@ APP_DEMO=false
|
||||
APP_DATE_TIME_FORMAT="Y-m-d H:i:s"
|
||||
|
||||
PLOI_TOKEN=
|
||||
PLOI_CORE_TOKEN=
|
||||
|
||||
IMPERSONATION=false
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
|
||||
|
||||
42
.github/workflows/master.yml
vendored
42
.github/workflows/master.yml
vendored
@@ -1,42 +0,0 @@
|
||||
name: Run tests & build files
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Run tests
|
||||
uses: ./.github/workflows/run-tests.yml
|
||||
|
||||
deploy:
|
||||
needs: test
|
||||
name: Prepare build assets
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Setup PHP with PECL extension
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.1'
|
||||
extensions: pcntl
|
||||
|
||||
- run: composer install
|
||||
name: Install dependencies
|
||||
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '14.x'
|
||||
- run: npm install
|
||||
- run: npm run prod
|
||||
- run: npm run prod:filament
|
||||
|
||||
- name: Commit build assets
|
||||
run: |
|
||||
git config --local user.email "actions@github.com"
|
||||
git config --local user.name "GitHub Actions"
|
||||
git add .
|
||||
git commit -m "Updated build assets"
|
||||
git push origin
|
||||
2
.github/workflows/run-tests.yml
vendored
2
.github/workflows/run-tests.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
php: [8.1]
|
||||
php: [8.4]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -21,3 +21,4 @@ yarn-error.log
|
||||
rr
|
||||
.rr.yaml
|
||||
.DS_Store
|
||||
.phpunit.cache
|
||||
|
||||
122
CLAUDE.md
Normal file
122
CLAUDE.md
Normal file
@@ -0,0 +1,122 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Project Overview
|
||||
|
||||
Ploi Core is a Laravel-based webhosting management platform that allows users to launch their own webhosting service using ploi.io as the backend infrastructure.
|
||||
|
||||
## Essential Commands
|
||||
|
||||
### Development
|
||||
```bash
|
||||
# Start development server
|
||||
npm run dev
|
||||
|
||||
# Build for production
|
||||
npm run build
|
||||
|
||||
# Watch for changes
|
||||
npm run watch
|
||||
|
||||
# Format PHP code
|
||||
composer format
|
||||
|
||||
# Run tests
|
||||
php artisan test
|
||||
php artisan test --filter=TestName
|
||||
|
||||
# Run browser tests
|
||||
php artisan dusk
|
||||
|
||||
# Clear all caches
|
||||
php artisan cache:clear
|
||||
php artisan config:clear
|
||||
php artisan route:clear
|
||||
php artisan view:clear
|
||||
|
||||
# Queue management
|
||||
php artisan horizon
|
||||
php artisan queue:work
|
||||
```
|
||||
|
||||
### Database
|
||||
```bash
|
||||
# Run migrations
|
||||
php artisan migrate
|
||||
|
||||
# Rollback migrations
|
||||
php artisan migrate:rollback
|
||||
|
||||
# Fresh migration with seeders
|
||||
php artisan migrate:fresh --seed
|
||||
```
|
||||
|
||||
### Custom Artisan Commands
|
||||
```bash
|
||||
php artisan core:install # Initial installation
|
||||
php artisan core:synchronize # Sync with Ploi API
|
||||
php artisan core:cleanup # Clean up resources
|
||||
php artisan core:trial # Manage trials
|
||||
```
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
### Technology Stack
|
||||
- **Backend**: Laravel 11 (PHP 8.2+), Filament v3 admin panel
|
||||
- **Frontend**: Vue 3 with Inertia.js, Tailwind CSS, Vite
|
||||
- **Queue**: Laravel Horizon with Redis
|
||||
- **Payments**: Laravel Cashier (Stripe)
|
||||
- **Testing**: Pest PHP, Laravel Dusk
|
||||
|
||||
### Key Directories
|
||||
- `app/Services/Ploi/` - Ploi.io API integration layer
|
||||
- `app/Filament/` - Admin panel resources and pages
|
||||
- `app/Http/Controllers/` - Web and API controllers
|
||||
- `app/Jobs/` - Async queue jobs for Ploi API operations
|
||||
- `resources/js/Pages/` - Inertia.js Vue pages
|
||||
- `resources/js/components/` - Reusable Vue components
|
||||
|
||||
### Ploi API Integration
|
||||
The application heavily integrates with the Ploi.io API. Key service class is at `app/Services/Ploi/Ploi.php`. All server/site management operations go through this API layer. Use queue jobs for long-running operations to avoid timeouts.
|
||||
|
||||
### Database Structure
|
||||
Main entities: Users, Packages, Servers, Sites, Databases, Certificates, Cronjobs. Multi-tenancy through user-server-site relationships. Role-based access: admin, reseller, user.
|
||||
|
||||
### Frontend Architecture
|
||||
- Inertia.js handles the Vue-Laravel bridge
|
||||
- Pages are in `resources/js/Pages/` following Laravel route structure
|
||||
- Shared data is passed via Inertia middleware
|
||||
- Vuex store modules in `resources/js/store/`
|
||||
- Form handling uses Inertia forms
|
||||
|
||||
### Testing Approach
|
||||
- Feature tests use Pest PHP syntax
|
||||
- Database tests use RefreshDatabase trait
|
||||
- API calls should be mocked using Http::fake()
|
||||
- Browser tests in `tests/Browser/` using Dusk
|
||||
|
||||
### Important Environment Variables
|
||||
```
|
||||
PLOI_TOKEN= # Ploi API token
|
||||
APP_DEMO=false # Demo mode toggle
|
||||
STRIPE_KEY= # Stripe public key
|
||||
STRIPE_SECRET= # Stripe secret key
|
||||
```
|
||||
|
||||
### Development Workflow
|
||||
1. Always run `npm run dev` for frontend changes
|
||||
2. Use queue workers for Ploi API operations
|
||||
3. Clear caches when changing config or routes
|
||||
4. Format code with `composer format` before commits
|
||||
5. Test with `php artisan test` for unit/feature tests
|
||||
|
||||
### Common Patterns
|
||||
- Use Actions (`app/Actions/`) for business logic
|
||||
- API responses follow Laravel's resource pattern
|
||||
- Filament resources handle admin CRUD operations
|
||||
- Queue jobs for async Ploi API calls
|
||||
- Service classes for external integrations
|
||||
|
||||
### Deployment
|
||||
Production deployment uses the `update.sh` script which handles git pull, composer install, migrations, and cache clearing. Laravel Horizon manages queues in production.
|
||||
@@ -1,6 +1,6 @@
|
||||
# Ploi Core
|
||||
|
||||
With Ploi Core, you'll power-launch your webhosting company.
|
||||
With Ploi Core, you'll power-launch your webhosting company.
|
||||
Using the ploi.io system as backbone you will be able to serve your customers your custom panel & feeling.
|
||||
|
||||
<p align="center"><img src="https://ploi-core.io/images/og.jpg" width="100%"></p>
|
||||
@@ -17,4 +17,4 @@ https://ploi.io
|
||||
|
||||
The contribution guide can be found inside our documentation:
|
||||
|
||||
https://docs.ploi-core.io/getting-started/contribution-guide
|
||||
https://docs.ploi-core.io/261-getting-started/639-contribution-guide
|
||||
|
||||
@@ -2,30 +2,59 @@
|
||||
|
||||
namespace App\Actions\Server;
|
||||
|
||||
use Throwable;
|
||||
use App\Models\Server;
|
||||
use App\Services\Ploi\Ploi;
|
||||
use Filament\Notifications\Notification;
|
||||
|
||||
class SynchronizeServerAction
|
||||
{
|
||||
public function execute(int $ploiServerId): Server
|
||||
public function execute(int $ploiServerId): Server|null
|
||||
{
|
||||
$serverData = Ploi::make()->server()->get($ploiServerId)->getData();
|
||||
try {
|
||||
$serverData = Ploi::make()->server()->get($ploiServerId)->getData();
|
||||
} catch (Throwable $exception) {
|
||||
Notification::make()
|
||||
->title('An error has occurred: ' . $exception->getMessage())
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$server = Server::query()
|
||||
->updateOrCreate([
|
||||
'ploi_id' => $serverData->id,
|
||||
], [
|
||||
'status' => $serverData->status,
|
||||
'name' => $serverData->name,
|
||||
'ip' => $serverData->ip_address,
|
||||
'ssh_port' => $serverData->ssh_port,
|
||||
'internal_ip' => $serverData->internal_ip,
|
||||
'available_php_versions' => $serverData->installed_php_versions,
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
if(!$serverData){
|
||||
Notification::make()
|
||||
->title('Server synchronization')
|
||||
->body('It was not possible to synchronize servers, it seems the API key has the wrong scopes. Please make sure the Ploi API key you\'ve entered has all the scopes enabled.')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
$server = Server::query()
|
||||
->updateOrCreate([
|
||||
'ploi_id' => $serverData->id,
|
||||
], [
|
||||
'status' => $serverData->status,
|
||||
'name' => $serverData->name,
|
||||
'ip' => $serverData->ip_address,
|
||||
'ssh_port' => $serverData->ssh_port,
|
||||
'internal_ip' => $serverData->internal_ip,
|
||||
'available_php_versions' => $serverData->installed_php_versions,
|
||||
]);
|
||||
} catch (Throwable $exception) {
|
||||
Notification::make()
|
||||
->title('An error has occurred: ' . $exception->getMessage())
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->body(__('Server :server synchronized successfully.', ['server' => $server->name]))
|
||||
->title(__('Server :server synchronized successfully.', ['server' => $server->name]))
|
||||
->success()
|
||||
->send();
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ class SynchronizeSiteAction
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->body(__('Site :site synchronized successfully.', ['site' => $site->domain]))
|
||||
->title(__('Site :site synchronized successfully.', ['site' => $site->domain]))
|
||||
->success()
|
||||
->send();
|
||||
|
||||
|
||||
@@ -14,6 +14,17 @@ use App\Services\VersionChecker;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use function Laravel\Prompts\text;
|
||||
use function Laravel\Prompts\password;
|
||||
use function Laravel\Prompts\confirm;
|
||||
use function Laravel\Prompts\select;
|
||||
use function Laravel\Prompts\info;
|
||||
use function Laravel\Prompts\error;
|
||||
use function Laravel\Prompts\warning;
|
||||
use function Laravel\Prompts\note;
|
||||
use function Laravel\Prompts\spin;
|
||||
use function Laravel\Prompts\intro;
|
||||
use function Laravel\Prompts\outro;
|
||||
|
||||
class Install extends Command
|
||||
{
|
||||
@@ -25,29 +36,34 @@ class Install extends Command
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$this->init();
|
||||
$this->intro();
|
||||
$this->isInstalled();
|
||||
$this->checkApplicationKey();
|
||||
$this->checkDatabaseConnection();
|
||||
$this->runDatabaseMigrations();
|
||||
$this->checkCredentials();
|
||||
$this->askAboutAdministrationAccount();
|
||||
$this->askAboutDefaultPackages();
|
||||
$this->checkApplicationUrl();
|
||||
$this->createInstallationFile();
|
||||
$this->linkStorage();
|
||||
try {
|
||||
$this->init();
|
||||
$this->intro();
|
||||
$this->isInstalled();
|
||||
$this->checkApplicationKey();
|
||||
$this->checkDatabaseConnection();
|
||||
$this->runDatabaseMigrations();
|
||||
$this->checkCredentials();
|
||||
$this->askAboutAdministrationAccount();
|
||||
$this->askAboutDefaultPackages();
|
||||
$this->checkApplicationUrl();
|
||||
$this->createInstallationFile();
|
||||
$this->linkStorage();
|
||||
|
||||
$this->info('Success! Installation has finished.');
|
||||
$this->line(' ');
|
||||
$this->writeSeparationLine();
|
||||
$this->info('Make sure to also setup emailing, the cronjob and the queue worker.');
|
||||
$this->line(' ');
|
||||
$this->info('Setting up emailing: https://docs.ploi-core.io/getting-started/setting-up-email');
|
||||
$this->info('Setting up cronjob & queue worker: https://docs.ploi-core.io/getting-started/installation');
|
||||
$this->writeSeparationLine();
|
||||
$this->line(' ');
|
||||
$this->info('Visit your platform at ' . env('APP_URL'));
|
||||
outro('🎉 Installation completed successfully!');
|
||||
|
||||
note(
|
||||
"Next steps:\n\n" .
|
||||
"📧 Setup email: https://docs.ploi-core.io/261-getting-started/918-setting-up-email\n" .
|
||||
"⚙️ Setup cron & queue: https://docs.ploi-core.io/261-getting-started/638-installation\n\n" .
|
||||
"Visit your platform at: " . env('APP_URL')
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
} catch (\Exception $e) {
|
||||
error('Installation failed: ' . $e->getMessage());
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
protected function init()
|
||||
@@ -58,96 +74,122 @@ class Install extends Command
|
||||
protected function askAboutAdministrationAccount()
|
||||
{
|
||||
if (!User::query()->where('role', User::ADMIN)->count()) {
|
||||
$this->info('Let\'s start by setting up your administration account.');
|
||||
note('Let\'s set up your administration account');
|
||||
|
||||
$name = $this->ask('What is your name', $this->company['user_name']);
|
||||
$email = $this->ask('What is your e-mail address', $this->company['email']);
|
||||
$password = $this->secret('What password do you desire');
|
||||
$name = text(
|
||||
label: 'What is your name?',
|
||||
default: $this->company['user_name'],
|
||||
required: true
|
||||
);
|
||||
|
||||
$check = User::where('email', $email)->count();
|
||||
$email = text(
|
||||
label: 'What is your email address?',
|
||||
default: $this->company['email'],
|
||||
required: true,
|
||||
validate: fn (string $value) => match (true) {
|
||||
!filter_var($value, FILTER_VALIDATE_EMAIL) => 'Please enter a valid email address.',
|
||||
User::where('email', $value)->exists() => 'This email is already registered in the system.',
|
||||
default => null
|
||||
}
|
||||
);
|
||||
|
||||
if ($check) {
|
||||
$this->line('');
|
||||
$this->comment('This user is already present in your system, please refresh your database or use different credentials.');
|
||||
$this->comment('Aborting installation..');
|
||||
$password = password(
|
||||
label: 'Choose a secure password',
|
||||
required: true,
|
||||
validate: fn (string $value) => match (true) {
|
||||
strlen($value) < 8 => 'Password must be at least 8 characters.',
|
||||
default => null
|
||||
}
|
||||
);
|
||||
|
||||
exit();
|
||||
}
|
||||
spin(
|
||||
function () use ($name, $email, $password) {
|
||||
User::forceCreate([
|
||||
'name' => $name,
|
||||
'email' => $email,
|
||||
'password' => $password,
|
||||
'role' => User::ADMIN
|
||||
]);
|
||||
},
|
||||
'Creating administrator account...'
|
||||
);
|
||||
|
||||
User::forceCreate([
|
||||
'name' => $name,
|
||||
'email' => $email,
|
||||
'password' => $password,
|
||||
'role' => User::ADMIN
|
||||
]);
|
||||
info('✓ Administrator account created successfully');
|
||||
} else {
|
||||
$this->line('Already found a administrator user in your system. Use that user to login.');
|
||||
note('Administrator account already exists. Use existing credentials to login.');
|
||||
}
|
||||
}
|
||||
|
||||
protected function askAboutDefaultPackages()
|
||||
{
|
||||
$basicPackages = $this->confirm(
|
||||
'Do you want to create the basic packages which you can edit later?',
|
||||
true
|
||||
$createPackages = confirm(
|
||||
label: 'Would you like to create default packages?',
|
||||
default: true,
|
||||
hint: 'Basic (5 sites), Professional (30 sites), and Unlimited packages'
|
||||
);
|
||||
|
||||
if (!$basicPackages) {
|
||||
if (!$createPackages) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Package::create([
|
||||
'name' => 'Basic',
|
||||
'maximum_sites' => 5,
|
||||
'site_permissions' => [
|
||||
'create' => true,
|
||||
'update' => true,
|
||||
'delete' => true
|
||||
],
|
||||
'server_permissions' => [
|
||||
'create' => false,
|
||||
'update' => false,
|
||||
'delete' => false
|
||||
]
|
||||
]);
|
||||
spin(
|
||||
function () {
|
||||
Package::create([
|
||||
'name' => 'Basic',
|
||||
'maximum_sites' => 5,
|
||||
'site_permissions' => [
|
||||
'create' => true,
|
||||
'update' => true,
|
||||
'delete' => true
|
||||
],
|
||||
'server_permissions' => [
|
||||
'create' => false,
|
||||
'update' => false,
|
||||
'delete' => false
|
||||
]
|
||||
]);
|
||||
|
||||
Package::create([
|
||||
'name' => 'Professional',
|
||||
'maximum_sites' => 30,
|
||||
'site_permissions' => [
|
||||
'create' => true,
|
||||
'update' => true,
|
||||
'delete' => true
|
||||
],
|
||||
'server_permissions' => [
|
||||
'create' => false,
|
||||
'update' => false,
|
||||
'delete' => false
|
||||
]
|
||||
]);
|
||||
Package::create([
|
||||
'name' => 'Professional',
|
||||
'maximum_sites' => 30,
|
||||
'site_permissions' => [
|
||||
'create' => true,
|
||||
'update' => true,
|
||||
'delete' => true
|
||||
],
|
||||
'server_permissions' => [
|
||||
'create' => false,
|
||||
'update' => false,
|
||||
'delete' => false
|
||||
]
|
||||
]);
|
||||
|
||||
Package::create([
|
||||
'name' => 'Unlimited',
|
||||
'maximum_sites' => 0,
|
||||
'site_permissions' => [
|
||||
'create' => true,
|
||||
'update' => true,
|
||||
'delete' => true
|
||||
],
|
||||
'server_permissions' => [
|
||||
'create' => false,
|
||||
'update' => false,
|
||||
'delete' => false
|
||||
]
|
||||
]);
|
||||
Package::create([
|
||||
'name' => 'Unlimited',
|
||||
'maximum_sites' => 0,
|
||||
'site_permissions' => [
|
||||
'create' => true,
|
||||
'update' => true,
|
||||
'delete' => true
|
||||
],
|
||||
'server_permissions' => [
|
||||
'create' => false,
|
||||
'update' => false,
|
||||
'delete' => false
|
||||
]
|
||||
]);
|
||||
},
|
||||
'Creating default packages...'
|
||||
);
|
||||
|
||||
info('✓ Created 3 default packages');
|
||||
}
|
||||
|
||||
protected function getCompany($ploiCoreKey, $token)
|
||||
protected function getCompany($token)
|
||||
{
|
||||
$response = Http::withHeaders([
|
||||
'Accept' => 'application/json',
|
||||
'Content-Type' => 'application/json',
|
||||
'X-Ploi-Core-Key' => $ploiCoreKey
|
||||
'Content-Type' => 'application/json'
|
||||
])
|
||||
->withToken($token)
|
||||
->get((new Ploi)->url . 'ping');
|
||||
@@ -170,28 +212,26 @@ class Install extends Command
|
||||
|
||||
protected function intro()
|
||||
{
|
||||
$this->writeSeparationLine();
|
||||
$this->line('Ploi Core Installation');
|
||||
$this->line('Ploi Core version: ' . $this->versionChecker->currentVersion);
|
||||
$this->line('Ploi Core remote: ' . $this->versionChecker->remoteVersion);
|
||||
$this->line('Laravel version: ' . app()->version());
|
||||
$this->line('PHP version: ' . trim(phpversion()));
|
||||
$this->line(' ');
|
||||
$this->line('Website: https://ploi-core.io');
|
||||
$this->line('E-mail: core@ploi.io');
|
||||
$this->line('Terms of service: https://ploi-core.io/terms');
|
||||
$this->writeSeparationLine();
|
||||
$this->line('');
|
||||
intro('🚀 Ploi Core Installation');
|
||||
|
||||
note(
|
||||
"Ploi Core v{$this->versionChecker->currentVersion} (Remote: v{$this->versionChecker->remoteVersion})\n" .
|
||||
"Laravel v" . app()->version() . " | PHP v" . trim(phpversion()) . "\n\n" .
|
||||
"Website: https://ploi-core.io\n" .
|
||||
"E-mail: core@ploi.io\n" .
|
||||
"Terms: https://ploi-core.io/terms"
|
||||
);
|
||||
}
|
||||
|
||||
protected function isInstalled()
|
||||
{
|
||||
if (file_exists(storage_path($this->installationFile)) && !$this->option('force')) {
|
||||
$this->line('');
|
||||
$this->comment('Ploi Core has already been installed before.');
|
||||
$this->comment('If you still want to start installation, remove this file to continue: ./storage/' . $this->installationFile);
|
||||
$this->comment('Aborting installation..');
|
||||
|
||||
warning('Ploi Core has already been installed before.');
|
||||
error(
|
||||
"To reinstall, either:\n" .
|
||||
"• Remove the file: ./storage/{$this->installationFile}\n" .
|
||||
"• Or run with --force flag"
|
||||
);
|
||||
exit();
|
||||
}
|
||||
|
||||
@@ -201,138 +241,215 @@ class Install extends Command
|
||||
protected function checkApplicationKey(): void
|
||||
{
|
||||
if (!config('app.key')) {
|
||||
$this->call('key:generate');
|
||||
|
||||
$this->info('Application key has been set');
|
||||
spin(
|
||||
fn () => $this->call('key:generate', [], $this->getOutput()),
|
||||
'Generating application key...'
|
||||
);
|
||||
info('✓ Application key has been set');
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkApplicationUrl()
|
||||
{
|
||||
// Ask about URL
|
||||
$url = $this->ask('What URL is this platform using?', env('APP_URL'));
|
||||
$url = text(
|
||||
label: 'What URL will this platform use?',
|
||||
default: env('APP_URL', 'https://example.com'),
|
||||
required: true,
|
||||
validate: fn (string $value) => match (true) {
|
||||
!filter_var($value, FILTER_VALIDATE_URL) => 'Please enter a valid URL.',
|
||||
!str_starts_with($value, 'http://') && !str_starts_with($value, 'https://') => 'URL must start with http:// or https://',
|
||||
default => null
|
||||
},
|
||||
hint: 'Include the protocol (http:// or https://)'
|
||||
);
|
||||
|
||||
$this->writeToEnvironmentFile('APP_URL', $url);
|
||||
try {
|
||||
$this->writeToEnvironmentFile('APP_URL', $url);
|
||||
info('✓ Application URL configured');
|
||||
} catch (\Exception $e) {
|
||||
error('Failed to save application URL: ' . $e->getMessage());
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
protected function createInstallationFile()
|
||||
{
|
||||
file_put_contents(storage_path($this->installationFile), json_encode($this->getInstallationPayload(), JSON_PRETTY_PRINT));
|
||||
try {
|
||||
$path = storage_path($this->installationFile);
|
||||
$content = json_encode($this->getInstallationPayload(), JSON_PRETTY_PRINT);
|
||||
|
||||
if (file_put_contents($path, $content) === false) {
|
||||
error('Failed to create installation file');
|
||||
exit(1);
|
||||
}
|
||||
|
||||
info('✓ Installation marker created');
|
||||
} catch (\Exception $e) {
|
||||
error('Error creating installation file: ' . $e->getMessage());
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
protected function linkStorage()
|
||||
{
|
||||
Artisan::call('storage:link');
|
||||
// Create storage symlink
|
||||
$publicPath = public_path('storage');
|
||||
$storagePath = storage_path('app/public');
|
||||
|
||||
// Remove existing symlink if it exists
|
||||
if (is_link($publicPath)) {
|
||||
unlink($publicPath);
|
||||
}
|
||||
|
||||
// Create new symlink
|
||||
if (!file_exists($publicPath)) {
|
||||
try {
|
||||
symlink($storagePath, $publicPath);
|
||||
info('✓ Storage symlink created');
|
||||
} catch (\Exception $e) {
|
||||
warning('Could not create storage symlink (may need manual creation)');
|
||||
}
|
||||
} else {
|
||||
info('✓ Storage path already exists');
|
||||
}
|
||||
}
|
||||
|
||||
protected function createDatabaseCredentials(): bool
|
||||
{
|
||||
$storeCredentials = $this->confirm(
|
||||
'Unable to connect to your database. Would you like to enter your credentials now?',
|
||||
true
|
||||
$storeCredentials = confirm(
|
||||
label: 'Would you like to configure database credentials now?',
|
||||
default: true
|
||||
);
|
||||
|
||||
if (!$storeCredentials) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$connection = $this->choice('Type', ['mysql', 'pgsql'], 0);
|
||||
$connection = select(
|
||||
label: 'Select database type',
|
||||
options: [
|
||||
'mysql' => 'MySQL / MariaDB',
|
||||
'pgsql' => 'PostgreSQL'
|
||||
],
|
||||
default: 'mysql'
|
||||
);
|
||||
|
||||
$defaultPort = $connection === 'mysql' ? '3306' : '5432';
|
||||
|
||||
$variables = [
|
||||
'DB_CONNECTION' => $connection,
|
||||
|
||||
'DB_HOST' => $this->anticipate(
|
||||
'Host',
|
||||
['127.0.0.1', 'localhost'],
|
||||
config("database.connections.{$connection}.host", '127.0.0.1')
|
||||
'DB_HOST' => text(
|
||||
label: 'Database host',
|
||||
default: config("database.connections.{$connection}.host", '127.0.0.1'),
|
||||
required: true,
|
||||
hint: 'Usually 127.0.0.1 or localhost'
|
||||
),
|
||||
|
||||
'DB_PORT' => $this->ask(
|
||||
'Port',
|
||||
config("database.connections.{$connection}.port", '3306')
|
||||
'DB_PORT' => text(
|
||||
label: 'Database port',
|
||||
default: config("database.connections.{$connection}.port", $defaultPort),
|
||||
required: true
|
||||
),
|
||||
|
||||
'DB_DATABASE' => $this->ask(
|
||||
'Database',
|
||||
config("database.connections.{$connection}.database")
|
||||
'DB_DATABASE' => text(
|
||||
label: 'Database name',
|
||||
default: config("database.connections.{$connection}.database", 'ploi_core'),
|
||||
required: true
|
||||
),
|
||||
|
||||
'DB_USERNAME' => $this->ask(
|
||||
'Username',
|
||||
config("database.connections.{$connection}.username")
|
||||
'DB_USERNAME' => text(
|
||||
label: 'Database username',
|
||||
default: config("database.connections.{$connection}.username", 'root'),
|
||||
required: true
|
||||
),
|
||||
|
||||
'DB_PASSWORD' => $this->secret(
|
||||
'Password',
|
||||
config("database.connections.{$connection}.password")
|
||||
),
|
||||
'DB_PASSWORD' => password(
|
||||
label: 'Database password',
|
||||
hint: 'Leave empty if no password is set'
|
||||
) ?: '',
|
||||
];
|
||||
|
||||
$this->persistVariables($variables);
|
||||
spin(
|
||||
fn () => $this->persistVariables($variables),
|
||||
'Saving database configuration...'
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function checkCredentials()
|
||||
{
|
||||
do {
|
||||
$ploiApiToken = $this->ask('Enter the Ploi API token', env('PLOI_TOKEN'));
|
||||
} while (empty($ploiApiToken));
|
||||
$ploiApiToken = text(
|
||||
label: 'Enter your Ploi API token',
|
||||
default: env('PLOI_TOKEN'),
|
||||
required: true,
|
||||
hint: 'You can find this in your Ploi account settings'
|
||||
);
|
||||
|
||||
do {
|
||||
$ploiCoreKey = $this->ask('Enter the Ploi Core key', env('PLOI_CORE_TOKEN'));
|
||||
} while (empty($ploiCoreKey));
|
||||
|
||||
$this->company = $this->getCompany($ploiCoreKey, $ploiApiToken);
|
||||
$this->company = spin(
|
||||
fn () => $this->getCompany($ploiApiToken),
|
||||
'Authenticating with Ploi API...'
|
||||
);
|
||||
|
||||
if (!$this->company) {
|
||||
$this->error('Could not authenticate with ploi.io, please retry by running this command again.');
|
||||
|
||||
error('Could not authenticate with ploi.io');
|
||||
exit();
|
||||
}
|
||||
|
||||
if (isset($this->company['error'])) {
|
||||
$this->error($this->company['error']);
|
||||
|
||||
error($this->company['error']);
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($this->company['user']['subscription'] !== 'unlimited') {
|
||||
$this->error('Your subscription does not cover the usage of Ploi Core. Please upgrade your subscription to Unlimited.');
|
||||
|
||||
error('Your Ploi subscription does not support Ploi Core.');
|
||||
warning('Please upgrade to the Unlimited plan at https://ploi.io');
|
||||
exit();
|
||||
}
|
||||
|
||||
info('✓ Successfully authenticated with Ploi');
|
||||
|
||||
$this->writeToEnvironmentFile('PLOI_TOKEN', $ploiApiToken);
|
||||
$this->writeToEnvironmentFile('PLOI_CORE_TOKEN', $ploiCoreKey);
|
||||
|
||||
$name = $this->ask('What is the name of your company? (Press enter to keep the name here)', $this->company['name']);
|
||||
$name = text(
|
||||
label: 'What is the name of your company?',
|
||||
default: $this->company['name'],
|
||||
required: true
|
||||
);
|
||||
|
||||
$this->writeToEnvironmentFile('APP_NAME', $name);
|
||||
|
||||
setting(['name' => $name]);
|
||||
}
|
||||
|
||||
protected function runDatabaseMigrations()
|
||||
{
|
||||
$this->info('Running database migrations..');
|
||||
$this->call('migrate', ['--force' => true]);
|
||||
$this->info('Database migrations successful');
|
||||
spin(
|
||||
fn () => $this->call('migrate', ['--force' => true], $this->getOutput()),
|
||||
'Running database migrations...'
|
||||
);
|
||||
info('✓ Database migrations completed');
|
||||
}
|
||||
|
||||
protected function checkDatabaseConnection(): void
|
||||
{
|
||||
try {
|
||||
DB::connection()->getPdo();
|
||||
$this->info('Database connection successful.');
|
||||
spin(
|
||||
fn () => DB::connection()->getPdo(),
|
||||
'Testing database connection...'
|
||||
);
|
||||
info('✓ Database connection successful');
|
||||
} catch (Exception $e) {
|
||||
warning('Unable to connect to database');
|
||||
|
||||
try {
|
||||
if (!$this->createDatabaseCredentials()) {
|
||||
$this->error('A database connection could not be established. Please update your configuration and try again.');
|
||||
error('Database connection could not be established.');
|
||||
$this->printDatabaseConfig();
|
||||
exit();
|
||||
}
|
||||
} catch (RuntimeException $e) {
|
||||
$this->error('Failed to persist environment configuration.');
|
||||
error('Failed to persist environment configuration.');
|
||||
exit();
|
||||
}
|
||||
|
||||
@@ -344,14 +461,15 @@ class Install extends Command
|
||||
{
|
||||
$connection = config('database.default');
|
||||
|
||||
$this->line('');
|
||||
$this->info('Database Configuration:');
|
||||
$this->line("- Connection: {$connection}");
|
||||
$this->line('- Host: ' . config("database.connections.{$connection}.host"));
|
||||
$this->line('- Port: ' . config("database.connections.{$connection}.port"));
|
||||
$this->line('- Database: ' . config("database.connections.{$connection}.database"));
|
||||
$this->line('- Username: ' . config("database.connections.{$connection}.username"));
|
||||
$this->line('- Password: ' . config("database.connections.{$connection}.password"));
|
||||
note(
|
||||
"Current Database Configuration:\n" .
|
||||
"• Connection: {$connection}\n" .
|
||||
"• Host: " . config("database.connections.{$connection}.host") . "\n" .
|
||||
"• Port: " . config("database.connections.{$connection}.port") . "\n" .
|
||||
"• Database: " . config("database.connections.{$connection}.database") . "\n" .
|
||||
"• Username: " . config("database.connections.{$connection}.username") . "\n" .
|
||||
"• Password: " . (config("database.connections.{$connection}.password") ? '***' : '(not set)')
|
||||
);
|
||||
}
|
||||
|
||||
protected function persistVariables(array $connectionData): void
|
||||
@@ -407,8 +525,4 @@ class Install extends Command
|
||||
$this->laravel['config'][$key] = $value;
|
||||
}
|
||||
|
||||
protected function writeSeparationLine()
|
||||
{
|
||||
$this->info('*---------------------------------------------------------------------------*');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,24 +26,17 @@ class ServerData extends Data
|
||||
public ?int $id = null,
|
||||
#[StringType]
|
||||
public ?string $status = null,
|
||||
#[StringType,
|
||||
AlphaDash,
|
||||
Max(40)]
|
||||
#[StringType, AlphaDash, Max(40)]
|
||||
public string $name,
|
||||
#[NotIn(0),
|
||||
Exists(Provider::class, 'id')]
|
||||
#[NotIn(0), Exists(Provider::class, 'id')]
|
||||
public int $provider_id,
|
||||
#[NotIn(0),
|
||||
Exists(ProviderRegion::class, 'id')]
|
||||
#[NotIn(0), Exists(ProviderRegion::class, 'id')]
|
||||
public int $provider_region_id,
|
||||
#[NotIn(0),
|
||||
Exists(ProviderPlan::class, 'id')]
|
||||
#[NotIn(0), Exists(ProviderPlan::class, 'id')]
|
||||
public int $provider_plan_id,
|
||||
#[StringType,
|
||||
In(['mysql', 'mariadb', 'postgresql', 'postgresql13'])]
|
||||
#[StringType, In(['mysql', 'mariadb', 'postgresql', 'postgresql13'])]
|
||||
public string $database_type,
|
||||
#[Exists(User::class, 'id'),
|
||||
IntegerType]
|
||||
#[Exists(User::class, 'id'), IntegerType]
|
||||
public ?int $user_id = null,
|
||||
public ?Carbon $created_at = null,
|
||||
) {
|
||||
|
||||
@@ -23,14 +23,11 @@ class SiteData extends Data
|
||||
public function __construct(
|
||||
public ?int $id = null,
|
||||
public ?string $status = null,
|
||||
#[Exists(Server::class, 'id'),
|
||||
IntegerType]
|
||||
#[Exists(Server::class, 'id'), IntegerType]
|
||||
public ?int $server_id = null,
|
||||
#[StringType,
|
||||
CustomRule(Hostname::class, ValidateMaximumSites::class)]
|
||||
#[StringType, CustomRule(Hostname::class, ValidateMaximumSites::class)]
|
||||
public ?string $domain = null,
|
||||
#[Exists(User::class, 'id'),
|
||||
IntegerType]
|
||||
#[Exists(User::class, 'id'), IntegerType]
|
||||
public ?int $user_id = null,
|
||||
public ?Carbon $created_at = null,
|
||||
) {
|
||||
|
||||
@@ -8,7 +8,7 @@ use Spatie\LaravelData\Support\DataProperty;
|
||||
|
||||
class CarbonCast implements Cast
|
||||
{
|
||||
public function cast(DataProperty $property, mixed $value): mixed
|
||||
public function cast(DataProperty $property, mixed $value, array $context): Carbon
|
||||
{
|
||||
return Carbon::parse($value);
|
||||
}
|
||||
|
||||
@@ -2,16 +2,13 @@
|
||||
|
||||
namespace App\DataTransferObjects\Support;
|
||||
|
||||
use Illuminate\Support\Enumerable;
|
||||
use Spatie\LaravelData\DataCollection;
|
||||
use Illuminate\Pagination\AbstractPaginator;
|
||||
use Illuminate\Contracts\Pagination\Paginator;
|
||||
use Illuminate\Pagination\AbstractCursorPaginator;
|
||||
|
||||
class Data extends \Spatie\LaravelData\Data
|
||||
{
|
||||
public static function collection(Paginator|Enumerable|array|AbstractCursorPaginator|DataCollection|AbstractPaginator $items): \App\DataTransferObjects\Support\DataCollection
|
||||
{
|
||||
return new \App\DataTransferObjects\Support\DataCollection(static::class, $items);
|
||||
}
|
||||
/**
|
||||
* When working with paginated data, we want to include pagination details in JSON
|
||||
* responses from the API. However, due to legacy requirements Ploi Core is using
|
||||
* a different structure than this package assumes. Therefore, we will override
|
||||
* the data collection, register a custom transformer and output the structure.
|
||||
*/
|
||||
protected static string $_paginatedCollectionClass = PaginatedDataCollection::class;
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
namespace App\DataTransferObjects\Support;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class DataCollectionTransformer extends \Spatie\LaravelData\Transformers\DataCollectionTransformer
|
||||
class DataCollectableTransformer extends \Spatie\LaravelData\Transformers\DataCollectableTransformer
|
||||
{
|
||||
protected function wrapPaginatedArray(array $paginated): array
|
||||
{
|
||||
$wrapKey = $this->wrap->getKey() ?? 'data';
|
||||
|
||||
return [
|
||||
'data' => $paginated['data'],
|
||||
$wrapKey => $paginated['data'],
|
||||
'links' => [
|
||||
'first' => $paginated['first_page_url'],
|
||||
'last' => $paginated['last_page_url'],
|
||||
@@ -27,14 +27,5 @@ class DataCollectionTransformer extends \Spatie\LaravelData\Transformers\DataCol
|
||||
'total' => $paginated['total'],
|
||||
],
|
||||
];
|
||||
|
||||
return [
|
||||
'data' => $paginated['data'],
|
||||
'links' => $paginated['links'] ?? [],
|
||||
'meta' => Arr::except($paginated, [
|
||||
'data',
|
||||
'links',
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\DataTransferObjects\Support;
|
||||
|
||||
use Spatie\LaravelData\Support\TransformationType;
|
||||
|
||||
class DataCollection extends \Spatie\LaravelData\DataCollection
|
||||
{
|
||||
public function transform(TransformationType $type): array
|
||||
{
|
||||
$transformer = new DataCollectionTransformer(
|
||||
$this->dataClass,
|
||||
$type,
|
||||
$this->getInclusionTree(),
|
||||
$this->getExclusionTree(),
|
||||
$this->items,
|
||||
$this->through,
|
||||
$this->filter
|
||||
);
|
||||
|
||||
return $transformer->transform();
|
||||
}
|
||||
}
|
||||
23
app/DataTransferObjects/Support/PaginatedDataCollection.php
Normal file
23
app/DataTransferObjects/Support/PaginatedDataCollection.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\DataTransferObjects\Support;
|
||||
|
||||
use Spatie\LaravelData\Support\Wrapping\WrapExecutionType;
|
||||
|
||||
class PaginatedDataCollection extends \Spatie\LaravelData\PaginatedDataCollection
|
||||
{
|
||||
public function transform(bool $transformValues = true, WrapExecutionType $wrapExecutionType = WrapExecutionType::Disabled, bool $mapPropertyNames = true): array
|
||||
{
|
||||
$transformer = new DataCollectableTransformer(
|
||||
$this->dataClass,
|
||||
$transformValues,
|
||||
$wrapExecutionType,
|
||||
$mapPropertyNames,
|
||||
$this->getPartialTrees(),
|
||||
$this->items,
|
||||
$this->getWrap(),
|
||||
);
|
||||
|
||||
return $transformer->transform();
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,11 @@
|
||||
namespace App\DataTransferObjects\Support\Rules;
|
||||
|
||||
use Attribute;
|
||||
use Spatie\LaravelData\Attributes\Validation\ValidationAttribute;
|
||||
use Spatie\LaravelData\Support\Validation\ValidationPath;
|
||||
use Spatie\LaravelData\Attributes\Validation\CustomValidationAttribute;
|
||||
|
||||
#[Attribute(Attribute::TARGET_PROPERTY)]
|
||||
class CustomRule extends ValidationAttribute
|
||||
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)]
|
||||
class CustomRule extends CustomValidationAttribute
|
||||
{
|
||||
protected array $rules = [];
|
||||
|
||||
@@ -15,10 +16,14 @@ class CustomRule extends ValidationAttribute
|
||||
$this->rules = $rules;
|
||||
}
|
||||
|
||||
public function getRules(): array
|
||||
/**
|
||||
* @return array<object|string>|object|string
|
||||
*/
|
||||
public function getRules(ValidationPath $path): array|object|string
|
||||
{
|
||||
return collect($this->rules)
|
||||
->map(fn (string $rule) => new $rule())
|
||||
->all();
|
||||
return array_map(
|
||||
fn (string $ruleClass) => new $ruleClass(),
|
||||
$this->rules
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
namespace App\DataTransferObjects\Support\Transformers;
|
||||
|
||||
use Illuminate\Support\Carbon;
|
||||
use Spatie\LaravelData\Support\DataProperty;
|
||||
use Spatie\LaravelData\Transformers\Transformer;
|
||||
|
||||
class CarbonTransformer implements Transformer
|
||||
{
|
||||
public function transform(DataProperty $property, mixed $value): mixed
|
||||
public function transform(DataProperty $property, mixed $value): string
|
||||
{
|
||||
/** @var Carbon $value */
|
||||
return $value->toISOString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,16 +19,11 @@ class UserData extends Data
|
||||
public function __construct(
|
||||
public ?int $id = null,
|
||||
public ?string $avatar = null,
|
||||
#[StringType,
|
||||
Max(255)]
|
||||
#[StringType, Max(255)]
|
||||
public ?string $name = null,
|
||||
#[StringType,
|
||||
Email,
|
||||
Max(255),
|
||||
Unique(User::class)]
|
||||
#[StringType, Email, Max(255), Unique(User::class)]
|
||||
public ?string $email = null,
|
||||
#[Exists(Package::class, 'id'),
|
||||
IntegerType]
|
||||
#[Exists(Package::class, 'id'), IntegerType]
|
||||
public ?int $package_id = null,
|
||||
#[StringType]
|
||||
public ?string $blocked = null,
|
||||
|
||||
@@ -2,18 +2,15 @@
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use Filament\Forms;
|
||||
use App\Models\Server;
|
||||
use App\Models\Package;
|
||||
use Filament\Pages\Page;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Filament\Forms\Components\Grid;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
|
||||
class Settings extends Page
|
||||
@@ -40,15 +37,15 @@ class Settings extends Page
|
||||
'default_package' => setting('default_package'),
|
||||
'default_language' => setting('default_language'),
|
||||
'rotate_logs_after' => setting('rotate_logs_after'),
|
||||
'trial' => (bool) setting('trial'),
|
||||
'support' => (bool) setting('support'),
|
||||
'documentation' => (bool) setting('documentation'),
|
||||
'allow_registration' => (bool) setting('allow_registration'),
|
||||
'receive_email_on_server_creation' => (bool) setting('receive_email_on_server_creation'),
|
||||
'receive_email_on_site_creation' => (bool) setting('receive_email_on_site_creation'),
|
||||
'enable_api' => (bool) setting('enable_api'),
|
||||
'trial' => (bool)setting('trial'),
|
||||
'support' => (bool)setting('support'),
|
||||
'documentation' => (bool)setting('documentation'),
|
||||
'allow_registration' => (bool)setting('allow_registration'),
|
||||
'receive_email_on_server_creation' => (bool)setting('receive_email_on_server_creation'),
|
||||
'receive_email_on_site_creation' => (bool)setting('receive_email_on_site_creation'),
|
||||
'enable_api' => (bool)setting('enable_api'),
|
||||
'api_token' => setting('api_token'),
|
||||
'isolate_per_site_per_user' => (bool) setting('isolate_per_site_per_user'),
|
||||
'isolate_per_site_per_user' => (bool)setting('isolate_per_site_per_user'),
|
||||
'default_os' => setting('default_os', Server::OS_UBUNTU_22),
|
||||
]);
|
||||
}
|
||||
@@ -56,35 +53,34 @@ class Settings extends Page
|
||||
public function getFormSchema(): array
|
||||
{
|
||||
return [
|
||||
Grid::make(2)
|
||||
Forms\Components\Grid::make(2)
|
||||
->schema([
|
||||
|
||||
Grid::make(1)
|
||||
Forms\Components\Grid::make(2)
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label(__('Company name'))
|
||||
->required(),
|
||||
TextInput::make('email')
|
||||
Forms\Components\TextInput::make('email')
|
||||
->label(__('E-mail address'))
|
||||
->email(),
|
||||
TextInput::make('support_emails')
|
||||
Forms\Components\TextInput::make('support_emails')
|
||||
->label(__('Support email address'))
|
||||
->helperText('Separate by comma to allow more email addresses'),
|
||||
])
|
||||
->columnSpan(2),
|
||||
Select::make('default_package')
|
||||
->options(fn () => Package::orderBy('name')->get()->mapWithKeys(fn (Package $package) => [$package->id => $package->name]))
|
||||
Forms\Components\Select::make('default_package')
|
||||
->options(fn () => Package::orderBy('name')->pluck('name', 'id'))
|
||||
->label(__('Select default package'))
|
||||
->helperText(__('Select the default package a user should get when you create or they register')),
|
||||
Select::make('default_language')
|
||||
Forms\Components\Select::make('default_language')
|
||||
->options(collect(languages())->mapWithKeys(fn (string $language) => [$language => $language]))
|
||||
->label('Select default language')
|
||||
->helperText('Select the default language a user should get when you create or they register'),
|
||||
FileUpload::make('logo')
|
||||
Forms\Components\FileUpload::make('logo')
|
||||
->label(__('Logo'))
|
||||
->disk('logos')
|
||||
->columnSpan(2),
|
||||
Select::make('rotate_logs_after')
|
||||
Forms\Components\Select::make('rotate_logs_after')
|
||||
->label(__('This will rotate any logs older than selected, this helps cleanup your database'))
|
||||
->options([
|
||||
null => __("Don't rotate logs"),
|
||||
@@ -98,7 +94,7 @@ class Settings extends Page
|
||||
'years-4' => __('Older than 4 years'),
|
||||
])
|
||||
->columnSpan(1),
|
||||
Select::make('default_os')
|
||||
Forms\Components\Select::make('default_os')
|
||||
->label(__('Select the default OS that should be used when users create a server'))
|
||||
->default(Server::OS_UBUNTU_22)
|
||||
->options([
|
||||
@@ -107,30 +103,30 @@ class Settings extends Page
|
||||
Server::OS_UBUNTU_22 => __('Ubuntu 22'),
|
||||
])
|
||||
->columnSpan(1),
|
||||
Toggle::make('trial')
|
||||
Forms\Components\Toggle::make('trial')
|
||||
->label(__('Enable trial'))
|
||||
->helperText(__('This will allow you to have users with trials.')),
|
||||
Toggle::make('allow_registration')
|
||||
Forms\Components\Toggle::make('allow_registration')
|
||||
->label(__('Allow registration'))
|
||||
->helperText(__('This will allow your customers to make support requests to you.')),
|
||||
Toggle::make('support')
|
||||
->helperText(__('Allow customer registration')),
|
||||
Forms\Components\Toggle::make('support')
|
||||
->label(__('Enable support platform'))
|
||||
->helperText(__('This will allow your customers to make support requests to you.')),
|
||||
Toggle::make('documentation')
|
||||
Forms\Components\Toggle::make('documentation')
|
||||
->label(__('Enable documentation platform'))
|
||||
->helperText(__('This will allow you to create articles for your users to look at.')),
|
||||
Toggle::make('receive_email_on_server_creation')
|
||||
Forms\Components\Toggle::make('receive_email_on_server_creation')
|
||||
->label(__('Receive email when customers create server'))
|
||||
->helperText(__('This will send an email to all admins notifying them about a new server installation.')),
|
||||
Toggle::make('receive_email_on_site_creation')
|
||||
Forms\Components\Toggle::make('receive_email_on_site_creation')
|
||||
->label(__('Receive email when customers create site'))
|
||||
->helperText(__('This will send an email to all admins notifying them about a new site installation.')),
|
||||
Toggle::make('enable_api')
|
||||
Forms\Components\Toggle::make('enable_api')
|
||||
->label(__('Enable API'))
|
||||
->helperText(new HtmlString(__('This will allow you to interact with your system via the API. ') . '<a href="https://docs.ploi-core.io/core-api/introduction" target="_blank" class="text-primary-600">' . __('More information') . '</a>')),
|
||||
TextInput::make('api_token')
|
||||
->helperText(new HtmlString(__('This will allow you to interact with your system via the API. ') . '<a href="https://docs.ploi-core.io/304-core-api/737-introduction" target="_blank" class="text-primary-600">' . __('More information') . '</a>')),
|
||||
Forms\Components\TextInput::make('api_token')
|
||||
->label(__('API token'))
|
||||
->afterStateHydrated(function (?string $state, TextInput $component) {
|
||||
->afterStateHydrated(function (?string $state, Forms\Components\TextInput $component) {
|
||||
$state = filled($state) ? decrypt($state) : null;
|
||||
|
||||
$component->state($state);
|
||||
@@ -148,7 +144,7 @@ class Settings extends Page
|
||||
->tooltip('Generate'),
|
||||
])
|
||||
->suffixAction($generateAction),
|
||||
Toggle::make('isolate_per_site_per_user')
|
||||
Forms\Components\Toggle::make('isolate_per_site_per_user')
|
||||
->label(__('Enable site isolation per site & user'))
|
||||
->helperText(__('This will make sure each site created by one user is always isolated from another.')),
|
||||
]),
|
||||
@@ -178,11 +174,11 @@ class Settings extends Page
|
||||
|
||||
Notification::make()
|
||||
->success()
|
||||
->body(__('Settings saved.'))
|
||||
->title(__('Settings saved.'))
|
||||
->send();
|
||||
|
||||
if ($state['logo'] !== $oldLogo || $state['documentation'] !== $oldDocumentation || $state['support'] !== $oldSupport) {
|
||||
$this->redirectRoute('filament.pages.settings');
|
||||
$this->redirect(Settings::getUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ use Laravel\Horizon\Contracts\MasterSupervisorRepository;
|
||||
|
||||
class System extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-adjustments';
|
||||
protected static ?string $navigationIcon = 'heroicon-o-adjustments-vertical';
|
||||
|
||||
protected static string $view = 'filament.pages.system';
|
||||
|
||||
@@ -33,13 +33,13 @@ class System extends Page
|
||||
|
||||
Notification::make()
|
||||
->success()
|
||||
->body(__('Refreshed versions'))
|
||||
->title(__('Refreshed versions'))
|
||||
->send();
|
||||
}
|
||||
|
||||
public function getHorizonWorkerStatus(): bool
|
||||
{
|
||||
return rescue(fn () => (bool) app(MasterSupervisorRepository::class)->all(), false, false);
|
||||
return rescue(fn () => (bool)app(MasterSupervisorRepository::class)->all(), false, false);
|
||||
}
|
||||
|
||||
public function hasAvailableUpdate(): bool
|
||||
@@ -47,7 +47,7 @@ class System extends Page
|
||||
return app(VersionChecker::class)->getVersions()->isOutOfDate();
|
||||
}
|
||||
|
||||
protected static function getNavigationBadge(): ?string
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
$systemChecker = app(VersionChecker::class);
|
||||
|
||||
|
||||
@@ -2,12 +2,11 @@
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use Filament\Forms;
|
||||
use Filament\Actions;
|
||||
use Filament\Pages\Page;
|
||||
use Illuminate\Support\Str;
|
||||
use Filament\Pages\Actions\Action;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Forms\Components\MarkdownEditor;
|
||||
|
||||
class Terms extends Page
|
||||
{
|
||||
@@ -26,7 +25,7 @@ class Terms extends Page
|
||||
cache()->forget('core.settings');
|
||||
|
||||
$this->form->fill([
|
||||
'accept_terms_required' => (bool) setting('accept_terms_required'),
|
||||
'accept_terms_required' => (bool)setting('accept_terms_required'),
|
||||
'terms' => setting('terms'),
|
||||
'privacy' => setting('privacy'),
|
||||
]);
|
||||
@@ -35,20 +34,20 @@ class Terms extends Page
|
||||
protected function getFormSchema(): array
|
||||
{
|
||||
return [
|
||||
Toggle::make('accept_terms_required')
|
||||
Forms\Components\Toggle::make('accept_terms_required')
|
||||
->label(__(' Require users to accept terms of service on registration'))
|
||||
->helperText(__('This will require newly registered users to accept the terms of service.')),
|
||||
MarkdownEditor::make('terms')
|
||||
Forms\Components\MarkdownEditor::make('terms')
|
||||
->label(__('Content Terms Of Service')),
|
||||
MarkdownEditor::make('privacy')
|
||||
Forms\Components\MarkdownEditor::make('privacy')
|
||||
->label(__('Content Privacy Policy')),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('load_terms_template')
|
||||
Actions\Action::make('load_terms_template')
|
||||
->label(__('Load Terms Of Service Template'))
|
||||
->action(function (self $livewire) {
|
||||
$template = Str::of(file_get_contents(storage_path('templates/terms-of-service.md')))
|
||||
@@ -67,7 +66,7 @@ class Terms extends Page
|
||||
|
||||
Notification::make()
|
||||
->success()
|
||||
->body(__('Loaded Terms Of Service Template'))
|
||||
->title(__('Loaded Terms Of Service Template'))
|
||||
->send();
|
||||
}),
|
||||
];
|
||||
@@ -88,7 +87,7 @@ class Terms extends Page
|
||||
|
||||
Notification::make()
|
||||
->success()
|
||||
->body(__('Terms saved.'))
|
||||
->title(__('Terms saved.'))
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,14 @@
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use Filament\Forms;
|
||||
use Filament\Tables;
|
||||
use App\Models\Alert;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\Str;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Resources\Resource;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\BadgeColumn;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\MarkdownEditor;
|
||||
use App\Filament\Resources\AlertResource\Pages;
|
||||
|
||||
class AlertResource extends Resource
|
||||
@@ -31,11 +28,11 @@ class AlertResource extends Resource
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
MarkdownEditor::make('message')
|
||||
Forms\Components\MarkdownEditor::make('message')
|
||||
->label(__('Content'))
|
||||
->columnSpan(2)
|
||||
->required(),
|
||||
Select::make('type')
|
||||
Forms\Components\Select::make('type')
|
||||
->label(__('Type'))
|
||||
->options([
|
||||
Alert::TYPE_INFO => __('Informational'),
|
||||
@@ -43,9 +40,9 @@ class AlertResource extends Resource
|
||||
Alert::TYPE_DANGER => __('Danger'),
|
||||
])
|
||||
->required(),
|
||||
DateTimePicker::make('expires_at')
|
||||
Forms\Components\DateTimePicker::make('expires_at')
|
||||
->label(__('Expires at'))
|
||||
->withoutSeconds(),
|
||||
->seconds(false),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -53,24 +50,26 @@ class AlertResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('message')
|
||||
Tables\Columns\TextColumn::make('message')
|
||||
->label(__('Content'))
|
||||
->formatStateUsing(fn (?string $state) => new HtmlString(Str::markdown($state))),
|
||||
BadgeColumn::make('type')
|
||||
Tables\Columns\TextColumn::make('type')
|
||||
->label(__('Type'))
|
||||
->enum([
|
||||
->badge()
|
||||
->formatStateUsing(fn (string $state) => match ($state) {
|
||||
Alert::TYPE_INFO => __('Informational'),
|
||||
Alert::TYPE_WARNING => __('Warning'),
|
||||
Alert::TYPE_DANGER => __('Danger'),
|
||||
])
|
||||
default => __('Unknown status')
|
||||
})
|
||||
->colors([
|
||||
'primary' => Alert::TYPE_INFO,
|
||||
'warning' => Alert::TYPE_WARNING,
|
||||
'danger' => Alert::TYPE_DANGER,
|
||||
]),
|
||||
TextColumn::make('expires_at')
|
||||
->label('Expires Date')
|
||||
->formatStateUsing(fn (?string $state) => filled($state) ? $state : '-'),
|
||||
Tables\Columns\TextColumn::make('expires_at')
|
||||
->label('Expires')
|
||||
->default('-'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\AlertResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions\DeleteAction;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use App\Filament\Resources\AlertResource;
|
||||
|
||||
@@ -10,10 +10,10 @@ class EditAlert extends EditRecord
|
||||
{
|
||||
protected static string $resource = AlertResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,18 +2,21 @@
|
||||
|
||||
namespace App\Filament\Resources\AlertResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions\CreateAction;
|
||||
use Filament\Actions;
|
||||
use App\Filament\Resources\AlertResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
class ListAlerts extends ListRecords
|
||||
{
|
||||
protected static string $resource = AlertResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected ?string $subheading = 'Alerts are meant to inform your users about things that are going on. For example server migrations, pricing changes. They will display as top-banner inside the panel.';
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,19 +4,19 @@ namespace App\Filament\Resources;
|
||||
|
||||
use Filament\Forms;
|
||||
use Filament\Tables;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use App\Models\Certificate;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Resources\Resource;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Filament\Resources\CertificateResource\Pages;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
class CertificateResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Certificate::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-annotation';
|
||||
protected static ?string $navigationIcon = 'heroicon-o-chat-bubble-bottom-center-text';
|
||||
|
||||
protected static ?string $navigationGroup = 'Site management';
|
||||
|
||||
@@ -28,15 +28,12 @@ class CertificateResource extends Resource
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('site.name'),
|
||||
Forms\Components\TextInput::make('server_id'),
|
||||
Forms\Components\TextInput::make('status')
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('status'),
|
||||
Forms\Components\TextInput::make('ploi_id'),
|
||||
Forms\Components\TextInput::make('domain')
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('domain'),
|
||||
Forms\Components\Textarea::make('certificate'),
|
||||
Forms\Components\Textarea::make('private'),
|
||||
Forms\Components\TextInput::make('type')
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('type'),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -52,11 +49,13 @@ class CertificateResource extends Resource
|
||||
->label(__('Main domain')),
|
||||
Tables\Columns\TextColumn::make('type')
|
||||
->label('Type'),
|
||||
Tables\Columns\BadgeColumn::make('status')
|
||||
->enum([
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->badge()
|
||||
->formatStateUsing(fn (string $state) => match ($state) {
|
||||
Certificate::STATUS_BUSY => __('Busy'),
|
||||
Certificate::STATUS_ACTIVE => __('Active'),
|
||||
])
|
||||
default => __('Unknown status')
|
||||
})
|
||||
->colors([
|
||||
'warning' => Certificate::STATUS_BUSY,
|
||||
'success' => Certificate::STATUS_ACTIVE,
|
||||
@@ -81,6 +80,7 @@ class CertificateResource extends Resource
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\CertificateResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use App\Filament\Resources\CertificateResource;
|
||||
|
||||
@@ -10,7 +10,7 @@ class ListCertificates extends ListRecords
|
||||
{
|
||||
protected static string $resource = CertificateResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace App\Filament\Resources;
|
||||
|
||||
use Filament\Tables;
|
||||
use App\Models\Cronjob;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Resources\Resource;
|
||||
use App\Filament\Resources\CronjobResource\Pages;
|
||||
|
||||
@@ -34,11 +34,13 @@ class CronjobResource extends Resource
|
||||
Tables\Columns\TextColumn::make('site.domain')
|
||||
->searchable()
|
||||
->label(__('Site')),
|
||||
Tables\Columns\BadgeColumn::make('status')
|
||||
->enum([
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->badge()
|
||||
->formatStateUsing(fn (string $state) => match ($state) {
|
||||
Cronjob::STATUS_BUSY => __('Busy'),
|
||||
Cronjob::STATUS_ACTIVE => __('Active'),
|
||||
])
|
||||
default => __('Unknown status')
|
||||
})
|
||||
->colors([
|
||||
'warning' => Cronjob::STATUS_BUSY,
|
||||
'success' => Cronjob::STATUS_ACTIVE,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\CronjobResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use App\Filament\Resources\CronjobResource;
|
||||
|
||||
@@ -10,7 +10,7 @@ class EditCronjob extends EditRecord
|
||||
{
|
||||
protected static string $resource = CronjobResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\CronjobResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use App\Filament\Resources\CronjobResource;
|
||||
|
||||
@@ -10,7 +10,7 @@ class ListCronjobs extends ListRecords
|
||||
{
|
||||
protected static string $resource = CronjobResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace App\Filament\Resources;
|
||||
|
||||
use Filament\Tables;
|
||||
use App\Models\Database;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Resources\Resource;
|
||||
use App\Filament\Resources\DatabaseResource\Pages;
|
||||
|
||||
@@ -13,7 +13,7 @@ class DatabaseResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Database::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-database';
|
||||
protected static ?string $navigationIcon = 'heroicon-o-circle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Site management';
|
||||
|
||||
@@ -40,17 +40,18 @@ class DatabaseResource extends Resource
|
||||
Tables\Columns\TextColumn::make('site.domain')
|
||||
->label(__('Site'))
|
||||
->searchable(),
|
||||
Tables\Columns\BadgeColumn::make('status')
|
||||
->enum([
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->badge()
|
||||
->formatStateUsing(fn (string $state) => match ($state) {
|
||||
Database::STATUS_BUSY => __('Busy'),
|
||||
Database::STATUS_ACTIVE => __('Active'),
|
||||
])
|
||||
default => __('Unknown status')
|
||||
})
|
||||
->colors([
|
||||
'warning' => Database::STATUS_BUSY,
|
||||
'success' => Database::STATUS_ACTIVE,
|
||||
])
|
||||
->label(__('Status')),
|
||||
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label(__('Date'))
|
||||
->sortable()
|
||||
|
||||
@@ -56,7 +56,7 @@ class EditDatabase extends Page
|
||||
$this->recentlyUpdatedPassword = $data->new_password;
|
||||
|
||||
Notification::make()
|
||||
->body(__('Successfully reset database password.'))
|
||||
->title(__('Successfully reset database password.'))
|
||||
->success()
|
||||
->send();
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\DatabaseResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use App\Filament\Resources\DatabaseResource;
|
||||
|
||||
@@ -10,7 +10,7 @@ class ListDatabases extends ListRecords
|
||||
{
|
||||
protected static string $resource = DatabaseResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
|
||||
@@ -2,17 +2,16 @@
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use Filament\Forms;
|
||||
use Filament\Tables;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\Str;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Resources\Resource;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use App\Models\DocumentationCategory;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\MarkdownEditor;
|
||||
use App\Filament\Resources\DocumentationCategoryResource\Pages;
|
||||
use App\Filament\Resources\DocumentationCategoryResource\RelationManagers\DocumentationItemsRelationManager;
|
||||
use App\Filament\Resources\DocumentationCategoryResource\RelationManagers;
|
||||
|
||||
class DocumentationCategoryResource extends Resource
|
||||
{
|
||||
@@ -28,21 +27,21 @@ class DocumentationCategoryResource extends Resource
|
||||
|
||||
protected static ?string $label = 'Category';
|
||||
|
||||
protected static function shouldRegisterNavigation(): bool
|
||||
public static function shouldRegisterNavigation(): bool
|
||||
{
|
||||
return (bool) setting('documentation');
|
||||
return (bool)setting('documentation');
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
TextInput::make('title')
|
||||
Forms\Components\TextInput::make('title')
|
||||
->label(__('Title'))
|
||||
->unique(table: DocumentationCategory::class, column: 'title', ignoreRecord: true)
|
||||
->required()
|
||||
->columnSpan(2),
|
||||
MarkdownEditor::make('description')
|
||||
Forms\Components\MarkdownEditor::make('description')
|
||||
->label(__('Description'))
|
||||
->required()
|
||||
->columnSpan(2),
|
||||
@@ -53,11 +52,11 @@ class DocumentationCategoryResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('title')
|
||||
Tables\Columns\TextColumn::make('title')
|
||||
->searchable()
|
||||
->sortable()
|
||||
->label(__('Title')),
|
||||
TextColumn::make('description')
|
||||
Tables\Columns\TextColumn::make('description')
|
||||
->label(__('Description'))
|
||||
->formatStateUsing(fn (string $state) => new HtmlString(Str::markdown($state))),
|
||||
]);
|
||||
@@ -66,7 +65,7 @@ class DocumentationCategoryResource extends Resource
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
DocumentationItemsRelationManager::class,
|
||||
RelationManagers\DocumentationItemsRelationManager::class,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\DocumentationCategoryResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions\DeleteAction;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use App\Filament\Resources\DocumentationCategoryResource;
|
||||
|
||||
@@ -10,10 +10,10 @@ class EditDocumentationCategory extends EditRecord
|
||||
{
|
||||
protected static string $resource = DocumentationCategoryResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\DocumentationCategoryResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions\CreateAction;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use App\Filament\Resources\DocumentationCategoryResource;
|
||||
|
||||
@@ -10,10 +10,10 @@ class ListDocumentationCategories extends ListRecords
|
||||
{
|
||||
protected static string $resource = DocumentationCategoryResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace App\Filament\Resources\DocumentationCategoryResource\RelationManagers;
|
||||
|
||||
use Filament\Forms;
|
||||
use Filament\Tables;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
|
||||
class DocumentationItemsRelationManager extends RelationManager
|
||||
@@ -18,7 +18,7 @@ class DocumentationItemsRelationManager extends RelationManager
|
||||
|
||||
protected static ?string $pluralLabel = 'Articles';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
@@ -28,7 +28,7 @@ class DocumentationItemsRelationManager extends RelationManager
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Forms;
|
||||
use Filament\Tables;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Resources\Resource;
|
||||
use App\Models\DocumentationItem;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\MarkdownEditor;
|
||||
use App\Filament\Resources\DocumentationItemResource\Pages;
|
||||
|
||||
class DocumentationItemResource extends Resource
|
||||
@@ -26,23 +24,23 @@ class DocumentationItemResource extends Resource
|
||||
|
||||
protected static ?string $label = 'Article';
|
||||
|
||||
protected static function shouldRegisterNavigation(): bool
|
||||
public static function shouldRegisterNavigation(): bool
|
||||
{
|
||||
return (bool) setting('documentation');
|
||||
return (bool)setting('documentation');
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
TextInput::make('title')
|
||||
Forms\Components\TextInput::make('title')
|
||||
->label(__('Title'))
|
||||
->required(),
|
||||
Select::make('documentation_category_id')
|
||||
Forms\Components\Select::make('documentation_category_id')
|
||||
->relationship('category', 'title')
|
||||
->searchable()
|
||||
->preload(),
|
||||
MarkdownEditor::make('content')
|
||||
Forms\Components\MarkdownEditor::make('content')
|
||||
->label(__('Content'))
|
||||
->required()
|
||||
->columnSpan(2),
|
||||
@@ -53,11 +51,10 @@ class DocumentationItemResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('title')
|
||||
Tables\Columns\TextColumn::make('title')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('category.title')
|
||||
Tables\Columns\TextColumn::make('category.title')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
]);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\DocumentationItemResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions\DeleteAction;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use App\Filament\Resources\DocumentationItemResource;
|
||||
|
||||
@@ -10,10 +10,10 @@ class EditDocumentationItem extends EditRecord
|
||||
{
|
||||
protected static string $resource = DocumentationItemResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\DocumentationItemResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions\CreateAction;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use App\Filament\Resources\DocumentationItemResource;
|
||||
|
||||
@@ -10,10 +10,10 @@ class ListDocumentationItems extends ListRecords
|
||||
{
|
||||
protected static string $resource = DocumentationItemResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,25 +2,24 @@
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use Filament\Tables;
|
||||
use App\Models\Package;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Forms\Components\Grid;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use App\Filament\Resources\PackageResource\Pages;
|
||||
use App\Filament\Resources\PackageResource\RelationManagers;
|
||||
use App\Models\Package;
|
||||
use App\Models\Provider;
|
||||
use App\Models\ProviderPlan;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
class PackageResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Package::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-color-swatch';
|
||||
protected static ?string $navigationIcon = 'heroicon-o-swatch';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
@@ -28,33 +27,31 @@ class PackageResource extends Resource
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label(__('Name'))
|
||||
->required()
|
||||
->columnSpan(2),
|
||||
TextInput::make('maximum_sites')
|
||||
Forms\Components\TextInput::make('maximum_sites')
|
||||
->helperText(__('Set to 0 for unlimited'))
|
||||
->integer()
|
||||
->required(),
|
||||
TextInput::make('maximum_servers')
|
||||
Forms\Components\TextInput::make('maximum_servers')
|
||||
->helperText(__('Set to 0 for unlimited'))
|
||||
->integer()
|
||||
->required(),
|
||||
TextInput::make('stripe_plan_id')
|
||||
->helperText(__('Enter the pricing ID from Stripe here') . ' - <a href="https://docs.ploi-core.io/digging-deeper/using-stripe" target="ploi-docs-stripe" class="text-primary-500">How does this work?</a>')
|
||||
Forms\Components\TextInput::make('stripe_plan_id')
|
||||
->helperText(new HtmlString(__('Enter the pricing ID from Stripe here') . ' - <a href="https://docs.ploi-core.io/263-digging-deeper/743-using-stripe" target="ploi-docs-stripe" class="text-primary-500">How does this work?</a>'))
|
||||
->label(__('Stripe ID'))
|
||||
->columnSpan(2),
|
||||
TextInput::make('price_monthly')
|
||||
->numeric()
|
||||
Forms\Components\TextInput::make('price_monthly')
|
||||
->label(__('Monthly price'))
|
||||
->helperText(__('Fill this in if you want it to be monthly payments'))
|
||||
->required(),
|
||||
TextInput::make('price_yearly')
|
||||
->numeric()
|
||||
Forms\Components\TextInput::make('price_yearly')
|
||||
->label(__('Yearly price'))
|
||||
->helperText(__('Fill this in if you want it to be yearly payments'))
|
||||
->required(),
|
||||
Select::make('currency')
|
||||
Forms\Components\Select::make('currency')
|
||||
->label(__('Currency'))
|
||||
->options([
|
||||
'usd' => 'USD $',
|
||||
@@ -66,46 +63,135 @@ class PackageResource extends Resource
|
||||
'inr' => 'INR (Indian ₹ rupee)',
|
||||
'thb' => 'THB (Thai Baht)',
|
||||
'brl' => 'BRL R$ (Brazilian Real)',
|
||||
'nz' => 'NZD $ (New Zealand Dollar)',
|
||||
])
|
||||
->required(),
|
||||
Grid::make()
|
||||
Forms\Components\Grid::make()
|
||||
->schema([
|
||||
Section::make(__('Server permissions'))
|
||||
Forms\Components\Section::make(__('Server permissions'))
|
||||
->icon(ServerResource::getNavigationIcon())
|
||||
->schema([
|
||||
Checkbox::make('server_permissions.create')
|
||||
Forms\Components\Checkbox::make('server_permissions.create')
|
||||
->reactive()
|
||||
->label('Allow server creation')
|
||||
->helperText('This will allow users to create servers'),
|
||||
Checkbox::make('server_permissions.update')
|
||||
Forms\Components\Checkbox::make('server_permissions.update')
|
||||
->label('Allow server updates')
|
||||
->helperText('This will allow users to update servers'),
|
||||
Checkbox::make('server_permissions.delete')
|
||||
Forms\Components\Checkbox::make('server_permissions.delete')
|
||||
->label('Allow server deletion')
|
||||
->helperText('This will allow users to delete servers'),
|
||||
])
|
||||
->columnSpan(1),
|
||||
Section::make(__('Site permissions'))
|
||||
Forms\Components\Section::make(__('Site permissions'))
|
||||
->icon(SiteResource::getNavigationIcon())
|
||||
->schema([
|
||||
Checkbox::make('site_permissions.create')
|
||||
Forms\Components\Checkbox::make('site_permissions.create')
|
||||
->label('Allow site creation')
|
||||
->helperText('This will allow users to create sites'),
|
||||
Checkbox::make('site_permissions.update')
|
||||
Forms\Components\Checkbox::make('site_permissions.update')
|
||||
->label('Allow site updates')
|
||||
->helperText('This will allow users to update sites'),
|
||||
Checkbox::make('site_permissions.delete')
|
||||
Forms\Components\Checkbox::make('site_permissions.delete')
|
||||
->label('Allow site deletion')
|
||||
->helperText('This will allow users to delete sites'),
|
||||
])
|
||||
->columnSpan(1),
|
||||
]),
|
||||
|
||||
Grid::make()
|
||||
Forms\Components\Grid::make()
|
||||
->schema([
|
||||
Section::make(__('Available server providers'))
|
||||
Forms\Components\Section::make(__('Available server providers'))
|
||||
->description(__('These server providers will be available for users that are attached to this package.'))
|
||||
->icon(ProviderResource::getNavigationIcon())
|
||||
->schema([
|
||||
CheckboxList::make('providers')
|
||||
Forms\Components\CheckboxList::make('providers')
|
||||
->relationship('providers', 'name')
|
||||
->reactive(),
|
||||
Forms\Components\Grid::make(1)
|
||||
->schema([
|
||||
Forms\Components\Actions::make([
|
||||
Forms\Components\Actions\Action::make('manage_provider_plans')
|
||||
->label(__('Manage provider plans'))
|
||||
->icon('heroicon-o-adjustments-horizontal')
|
||||
->form(function (Package $record) {
|
||||
return $record->providers->sortBy('name')->map(function (Provider $provider) {
|
||||
return Forms\Components\Section::make($provider->label)
|
||||
->description(__('Select the plans that should be available for this provider on this package.'))
|
||||
->icon(ProviderResource::getNavigationIcon())
|
||||
->statePath($provider->id)
|
||||
->schema([
|
||||
Forms\Components\Toggle::make('select_specific_provider_plans')
|
||||
->label(__('Select subset'))
|
||||
->helperText(__('Check this box if you want to limit the provider plans available on this package.'))
|
||||
->default(false)
|
||||
->reactive()
|
||||
->afterStateUpdated(function (Forms\Components\Toggle $component, Forms\Set $set) use ($provider) {
|
||||
$set(
|
||||
path: "provider_plans",
|
||||
state: $component->getState() ? $provider->plans->pluck('id') : [],
|
||||
);
|
||||
}),
|
||||
Forms\Components\CheckboxList::make("provider_plans")
|
||||
->label(__('Select plans'))
|
||||
->options(fn() => $provider->plans->mapWithKeys(fn(ProviderPlan $providerPlan) => [$providerPlan->id => $providerPlan->label ?? $providerPlan->plan_id])->all())
|
||||
->visible(fn(Forms\Get $get) => $get('select_specific_provider_plans'))
|
||||
->reactive()
|
||||
->bulkToggleable()
|
||||
->columns(2)
|
||||
])
|
||||
->collapsible();
|
||||
})->all();
|
||||
})
|
||||
->fillForm(function (Package $record) {
|
||||
return $record->providers->mapWithKeys(function (Provider $provider) use ($record) {
|
||||
$providerPlanIds = $record->providerPlans()->whereBelongsTo($provider)->pluck('provider_plans.id');
|
||||
|
||||
return [$provider->id => [
|
||||
'select_specific_provider_plans' => $providerPlanIds->isNotEmpty(),
|
||||
'provider_plans' => $providerPlanIds->all(),
|
||||
]];
|
||||
})->all();
|
||||
})
|
||||
->action(function (Package $record, array $data) {
|
||||
$providerPlanIds = collect($data)
|
||||
// If `select_specific_provider_plans`, all provider plans are available. It could be that this
|
||||
// option was deselected, and that we have some left over provider plans in the field that
|
||||
// is now hidden. We will not include theSE IDs so that they ARE detached automatically.
|
||||
->where('select_specific_provider_plans', true)
|
||||
->pluck('provider_plans')
|
||||
->flatten();
|
||||
|
||||
// Detaches provider plans not specifically selected.
|
||||
$record->providerPlans()->sync($providerPlanIds);
|
||||
|
||||
Notification::make()
|
||||
->title(__('Provider plans saved'))
|
||||
->success()
|
||||
->send();
|
||||
})
|
||||
->modalSubmitActionLabel(__('Save'))
|
||||
->color('gray')
|
||||
->disabled(function (Package $record, Forms\Get $get) {
|
||||
$providers = collect($get('providers'))
|
||||
->map(fn(string $id): int => (int)$id)
|
||||
->sort();
|
||||
|
||||
return $record->providers->pluck('id')->map(fn(string $id): int => (int)$id)->sort()->toArray() !== $providers->all();
|
||||
})
|
||||
]),
|
||||
Forms\Components\Placeholder::make('save_warning')
|
||||
->content(__('You\'ve changed the available server providers. Please save your changes before you can manage the provider plans.'))
|
||||
->visible(function (Package $record, Forms\Get $get) {
|
||||
$providers = collect($get('providers'))
|
||||
->map(fn(string $id): int => (int)$id)
|
||||
->sort();
|
||||
|
||||
return $record->providers->pluck('id')->map(fn(string $id): int => (int)$id)->sort()->toArray() !== $providers->all();
|
||||
})
|
||||
->hiddenLabel(),
|
||||
])
|
||||
->hiddenOn('create'),
|
||||
])
|
||||
->columnSpan(1)
|
||||
])
|
||||
@@ -119,7 +205,9 @@ class PackageResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')->label('ID')->searchable(),
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('ID')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label(__('Name'))
|
||||
->description(function (Package $record) {
|
||||
@@ -130,10 +218,10 @@ class PackageResource extends Resource
|
||||
return "Attached to stripe - {$record->price_monthly} {$record->currency}";
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('maximum_sites')
|
||||
->formatStateUsing(fn (int $state) => $state === 0 ? __('Unlimited') : $state)
|
||||
->formatStateUsing(fn(int $state) => $state === 0 ? __('Unlimited') : $state)
|
||||
->label(__('Maximum sites')),
|
||||
Tables\Columns\TextColumn::make('maximum_servers')
|
||||
->formatStateUsing(fn (int $state) => $state === 0 ? __('Unlimited') : $state)
|
||||
->formatStateUsing(fn(int $state) => $state === 0 ? __('Unlimited') : $state)
|
||||
->label(__('Maximum servers')),
|
||||
Tables\Columns\TextColumn::make('users_count')
|
||||
->counts('users'),
|
||||
@@ -143,6 +231,7 @@ class PackageResource extends Resource
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\PackageResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use App\Filament\Resources\PackageResource;
|
||||
|
||||
@@ -10,10 +10,17 @@ class EditPackage extends EditRecord
|
||||
{
|
||||
protected static string $resource = PackageResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
public function afterSave(): void
|
||||
{
|
||||
// Necessary to refresh, in order to load the updated saved relationships and
|
||||
// correctly show or hide the "manage provider plans" warning placeholder.
|
||||
$this->getRecord()->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\PackageResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use App\Filament\Resources\PackageResource;
|
||||
|
||||
@@ -10,7 +10,7 @@ class ListPackages extends ListRecords
|
||||
{
|
||||
protected static string $resource = PackageResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace App\Filament\Resources\PackageResource\RelationManagers;
|
||||
|
||||
use App\Models\User;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Tables\Actions\Action;
|
||||
use Filament\Forms\Components\Select;
|
||||
use App\Filament\Resources\UserResource;
|
||||
@@ -16,15 +16,16 @@ class UsersRelationManager extends RelationManager
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return UserResource::form($form);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return UserResource::table($table)
|
||||
->appendHeaderActions([
|
||||
->headerActions([
|
||||
...$table->getHeaderActions(),
|
||||
Action::make('add_user')
|
||||
->label(__('Add user'))
|
||||
->form(fn (self $livewire) => [
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use Filament\Forms;
|
||||
use Filament\Tables;
|
||||
use App\Models\Provider;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use App\Models\ProviderPlan;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use App\Filament\Resources\ProviderPlanResource\Pages;
|
||||
|
||||
class ProviderPlanResource extends Resource
|
||||
@@ -25,7 +25,7 @@ class ProviderPlanResource extends Resource
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
TextInput::make('label'),
|
||||
Forms\Components\TextInput::make('label'),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,9 @@ class ProviderPlanResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')->label('ID')->searchable(),
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('ID')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('provider.name')
|
||||
->label(__('Provider'))
|
||||
->searchable(),
|
||||
|
||||
@@ -9,7 +9,7 @@ class ListProviderPlans extends ListRecords
|
||||
{
|
||||
protected static string $resource = ProviderPlanResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace App\Filament\Resources;
|
||||
|
||||
use Filament\Tables;
|
||||
use App\Models\Provider;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use App\Models\ProviderRegion;
|
||||
use Filament\Resources\Resource;
|
||||
use App\Filament\Resources\ProviderRegionResource\Pages;
|
||||
@@ -14,7 +14,7 @@ class ProviderRegionResource extends Resource
|
||||
{
|
||||
protected static ?string $model = ProviderRegion::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-globe';
|
||||
protected static ?string $navigationIcon = 'heroicon-o-globe-americas';
|
||||
|
||||
protected static ?string $navigationGroup = 'Providers';
|
||||
|
||||
@@ -32,7 +32,9 @@ class ProviderRegionResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')->label('ID')->searchable(),
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('ID')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('provider.name')
|
||||
->label(__('Provider'))
|
||||
->searchable(),
|
||||
@@ -46,7 +48,7 @@ class ProviderRegionResource extends Resource
|
||||
->filters([
|
||||
Tables\Filters\SelectFilter::make('provider_id')
|
||||
->label(__('Provider'))
|
||||
->options(fn () => Provider::orderBy('name')->get()->mapWithKeys(fn (Provider $provider) => [$provider->id => $provider->name])),
|
||||
->options(fn () => Provider::orderBy('name')->pluck('name', 'id'))
|
||||
])
|
||||
->actions([
|
||||
//
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\ProviderRegionResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use App\Filament\Resources\ProviderRegionResource;
|
||||
|
||||
@@ -10,7 +10,7 @@ class ListProviderRegions extends ListRecords
|
||||
{
|
||||
protected static string $resource = ProviderRegionResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
|
||||
@@ -5,9 +5,9 @@ namespace App\Filament\Resources;
|
||||
use Filament\Forms;
|
||||
use Filament\Tables;
|
||||
use App\Models\Provider;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use App\Models\ProviderPlan;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@@ -19,7 +19,7 @@ class ProviderResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Provider::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-cloud-upload';
|
||||
protected static ?string $navigationIcon = 'heroicon-o-cloud-arrow-up';
|
||||
|
||||
protected static ?string $navigationGroup = 'Providers';
|
||||
|
||||
@@ -48,7 +48,9 @@ class ProviderResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')->label('ID')->searchable(),
|
||||
Tables\Columns\TextColumn::make('id')
|
||||
->label('ID')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->description(function (Provider $record) {
|
||||
return "{$record->plans_count} plan(s) · {$record->regions_count} region(s)";
|
||||
@@ -71,12 +73,12 @@ class ProviderResource extends Resource
|
||||
Tables\Actions\Action::make('synchronize_provider')
|
||||
->label(__('Synchronize'))
|
||||
->tooltip(__('This will synchronize the latest data from this provider to your Ploi Core installation'))
|
||||
->icon('heroicon-o-refresh')
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->action(function (Provider $record) {
|
||||
$provider = app(SynchronizeProviderAction::class)->execute($record->ploi_id);
|
||||
|
||||
Notification::make()
|
||||
->body(__('Provider :provider synchronized successfully.', ['provider' => $provider->name]))
|
||||
->title(__('Provider :provider synchronized successfully.', ['provider' => $provider->name]))
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\ProviderResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions\Action;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use App\Filament\Resources\ProviderResource;
|
||||
|
||||
@@ -14,14 +14,14 @@ class ListProviders extends ListRecords
|
||||
|
||||
protected static string $resource = ProviderResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('synchronize_providers')
|
||||
Actions\Action::make('synchronize_providers')
|
||||
->label(__('Synchronize providers'))
|
||||
->icon('heroicon-o-refresh')
|
||||
->color('secondary')
|
||||
->url(route('filament.resources.providers.synchronize')),
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->color('gray')
|
||||
->url(ProviderResource::getUrl('synchronize')),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class SynchronizeProviders extends Page
|
||||
];
|
||||
}
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
|
||||
@@ -46,14 +46,14 @@ class AvailableProvidersOverview extends TableWidget
|
||||
return [
|
||||
Action::make('synchronize_provider')
|
||||
->label(__('Synchronize'))
|
||||
->icon('heroicon-o-refresh')
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->action(function (AvailableProvider $record, self $livewire) {
|
||||
$provider = app(SynchronizeProviderAction::class)->execute($record->id);
|
||||
|
||||
$livewire->emit('$refresh');
|
||||
$livewire->dispatch('$refresh');
|
||||
|
||||
Notification::make()
|
||||
->body(__('Provider :provider synchronized successfully.', ['provider' => $provider->name]))
|
||||
->title(__('Provider :provider synchronized successfully.', ['provider' => $provider->name]))
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace App\Filament\Resources;
|
||||
use Filament\Forms;
|
||||
use Filament\Tables;
|
||||
use App\Models\Redirect;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Resources\Resource;
|
||||
use App\Filament\Resources\RedirectResource\Pages;
|
||||
|
||||
@@ -14,7 +14,7 @@ class RedirectResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Redirect::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-external-link';
|
||||
protected static ?string $navigationIcon = 'heroicon-o-arrow-top-right-on-square';
|
||||
|
||||
protected static ?string $navigationGroup = 'Site management';
|
||||
|
||||
@@ -26,15 +26,11 @@ class RedirectResource extends Resource
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('site_id'),
|
||||
Forms\Components\TextInput::make('server_id'),
|
||||
Forms\Components\TextInput::make('status')
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('status'),
|
||||
Forms\Components\TextInput::make('ploi_id'),
|
||||
Forms\Components\TextInput::make('redirect_from')
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('redirect_to')
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('type')
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('redirect_from'),
|
||||
Forms\Components\TextInput::make('redirect_to'),
|
||||
Forms\Components\TextInput::make('type'),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -58,11 +54,13 @@ class RedirectResource extends Resource
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('type')
|
||||
->label(__('Type')),
|
||||
Tables\Columns\BadgeColumn::make('status')
|
||||
->enum([
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->badge()
|
||||
->formatStateUsing(fn (string $state) => match ($state) {
|
||||
Redirect::STATUS_BUSY => __('Busy'),
|
||||
Redirect::STATUS_ACTIVE => __('Active'),
|
||||
])
|
||||
default => __('Unknown status')
|
||||
})
|
||||
->colors([
|
||||
'warning' => Redirect::STATUS_BUSY,
|
||||
'success' => Redirect::STATUS_ACTIVE,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\RedirectResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use App\Filament\Resources\RedirectResource;
|
||||
|
||||
@@ -10,7 +10,7 @@ class ListRedirects extends ListRecords
|
||||
{
|
||||
protected static string $resource = RedirectResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
|
||||
@@ -6,8 +6,8 @@ use Filament\Forms;
|
||||
use App\Models\User;
|
||||
use Filament\Tables;
|
||||
use App\Models\Server;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Resources\Resource;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@@ -61,12 +61,14 @@ class ServerResource extends Resource
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label(__('Name'))
|
||||
->searchable(),
|
||||
Tables\Columns\BadgeColumn::make('status')
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->label(__('Status'))
|
||||
->enum([
|
||||
->badge()
|
||||
->formatStateUsing(fn (string $state) => match ($state) {
|
||||
Server::STATUS_BUSY => __('Busy'),
|
||||
Server::STATUS_ACTIVE => __('Active'),
|
||||
])
|
||||
default => __('Unknown status')
|
||||
})
|
||||
->colors([
|
||||
'warning' => Server::STATUS_BUSY,
|
||||
'success' => Server::STATUS_ACTIVE,
|
||||
@@ -74,19 +76,27 @@ class ServerResource extends Resource
|
||||
Tables\Columns\TextColumn::make('users')
|
||||
->label(__('Users'))
|
||||
->wrap()
|
||||
->getStateUsing(function (Server $record) {
|
||||
->formatStateUsing(function (Server $record) {
|
||||
$state = $record
|
||||
->users
|
||||
->map(function (User $user) {
|
||||
return '<a href="' . route('filament.resources.users.edit', ['record' => $user]) . '" class="text-primary-600">' . $user->name . '</a>';
|
||||
return '<a href="' . UserResource::getUrl('edit', ['record' => $user]) . '" class="text-primary-600" style="white-space: nowrap">' . $user->name . '</a>';
|
||||
})
|
||||
->implode(', ') ?: '-';
|
||||
|
||||
return new HtmlString($state);
|
||||
})
|
||||
->searchable(query: function (Builder $query, string $search) {
|
||||
return $query->whereHas('users', function (Builder $query) use ($search) {
|
||||
return $query
|
||||
->where('name', 'LIKE', "%{$search}%")
|
||||
->orWhere('email', 'LIKE', "%{$search}%");
|
||||
});
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('maximum_sites')
|
||||
->label(__('Max sites'))
|
||||
->formatStateUsing(fn (Server $record) => $record->maximum_sites . " (Current: {$record->sites_count})"),
|
||||
->formatStateUsing(fn (Server $record) => $record->maximum_sites . " (Current: {$record->sites_count})")
|
||||
->counts('sites'),
|
||||
Tables\Columns\TextColumn::make('ip')
|
||||
->label(__('IP')),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
@@ -101,9 +111,10 @@ class ServerResource extends Resource
|
||||
Tables\Actions\Action::make('synchronize_server')
|
||||
->label(__('Synchronize'))
|
||||
->tooltip(__('This will synchronize the latest data from this provider to your Ploi Core installation'))
|
||||
->icon('heroicon-o-refresh')
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->action(fn (Server $record) => app(SynchronizeServerAction::class)->execute($record->ploi_id))
|
||||
->visible(fn (Server $record) => $record->status === Server::STATUS_ACTIVE),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\ServerResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use App\Filament\Resources\ServerResource;
|
||||
|
||||
@@ -10,7 +10,7 @@ class EditServer extends EditRecord
|
||||
{
|
||||
protected static string $resource = ServerResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
|
||||
@@ -2,36 +2,23 @@
|
||||
|
||||
namespace App\Filament\Resources\ServerResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions\Action;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Filament\Resources\ServerResource;
|
||||
|
||||
class ListServers extends ListRecords
|
||||
{
|
||||
protected static string $resource = ServerResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('synchronize_servers')
|
||||
Actions\Action::make('synchronize_servers')
|
||||
->label(__('Synchronize servers'))
|
||||
->icon('heroicon-o-refresh')
|
||||
->color('secondary')
|
||||
->url(route('filament.resources.servers.synchronize')),
|
||||
...parent::getActions(),
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->color('gray')
|
||||
->url(ServerResource::getUrl('synchronize')),
|
||||
...parent::getHeaderActions(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function applySearchToTableQuery(Builder $query): Builder
|
||||
{
|
||||
if (filled($searchTerm = $this->getTableSearchQuery())) {
|
||||
$query
|
||||
->where('domain', 'LIKE', "%{$searchTerm}%")
|
||||
->orWhereHas('users', fn (Builder $query) => $query->where('name', 'LIKE', "%{$searchTerm}%"))
|
||||
->orWhereHas('users', fn (Builder $query) => $query->where('email', 'LIKE', "%{$searchTerm}%"));
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Filament\Resources\ServerResource\Pages;
|
||||
|
||||
use Filament\Actions;
|
||||
use App\Models\Server;
|
||||
use App\Services\Ploi\Ploi;
|
||||
use Filament\Pages\Actions\Action;
|
||||
use Filament\Resources\Pages\Page;
|
||||
use Filament\Notifications\Notification;
|
||||
use App\Filament\Resources\ServerResource;
|
||||
@@ -24,15 +24,15 @@ class SynchronizeServers extends Page
|
||||
];
|
||||
}
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('synchronize_servers')
|
||||
Actions\Action::make('synchronize_servers')
|
||||
->label(__('Synchronize all servers'))
|
||||
->icon('heroicon-o-refresh')
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->requiresConfirmation()
|
||||
->modalHeading('Synchronize servers')
|
||||
->modalSubheading('This will synchronize all the servers that are listed in the table, to your Ploi Core installation.')
|
||||
->modalDescription('This will synchronize all the servers that are listed in the table, to your Ploi Core installation.')
|
||||
->action(function () {
|
||||
$availableServers = Ploi::make()->synchronize()->servers()->getData();
|
||||
|
||||
@@ -51,7 +51,7 @@ class SynchronizeServers extends Page
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->body(__('Servers synchronized successfully.'))
|
||||
->title(__('Servers synchronized successfully.'))
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Filament\Resources\ServerResource\RelationManagers;
|
||||
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use App\Filament\Resources\SiteResource;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
|
||||
@@ -23,12 +23,12 @@ class SitesRelationManager extends RelationManager
|
||||
return __('Sites');
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return SiteResource::form($form);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return SiteResource::table($table);
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace App\Filament\Resources\ServerResource\RelationManagers;
|
||||
|
||||
use Filament\Tables;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use App\Filament\Resources\UserResource;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
|
||||
@@ -24,18 +24,21 @@ class UsersRelationManager extends RelationManager
|
||||
return __('Users');
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return UserResource::form($form);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return UserResource::table($table)
|
||||
->appendHeaderActions([
|
||||
Tables\Actions\AttachAction::make()->preloadRecordSelect(),
|
||||
->headerActions([
|
||||
...$table->getHeaderActions(),
|
||||
Tables\Actions\AttachAction::make()
|
||||
->preloadRecordSelect(),
|
||||
])
|
||||
->appendActions([
|
||||
->actions([
|
||||
...$table->getActions(),
|
||||
Tables\Actions\DetachAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class AvailableServersOverview extends TableWidget
|
||||
return [
|
||||
Action::make('synchronize_server')
|
||||
->label(__('Synchronize'))
|
||||
->icon('heroicon-o-refresh')
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->action(function (AvailableServer $record) {
|
||||
app(SynchronizeServerAction::class)->execute($record->id);
|
||||
}),
|
||||
|
||||
@@ -6,10 +6,11 @@ use Filament\Forms;
|
||||
use App\Models\Site;
|
||||
use App\Models\User;
|
||||
use Filament\Tables;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Resources\Resource;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Actions\Site\SynchronizeSiteAction;
|
||||
use App\Filament\Resources\SiteResource\Pages;
|
||||
use App\Filament\Resources\SiteResource\RelationManagers;
|
||||
@@ -18,7 +19,7 @@ class SiteResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Site::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-code';
|
||||
protected static ?string $navigationIcon = 'heroicon-o-code-bracket';
|
||||
|
||||
protected static ?string $navigationGroup = 'Site management';
|
||||
|
||||
@@ -26,9 +27,6 @@ class SiteResource extends Resource
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'domain';
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public static function getLabel(): ?string
|
||||
{
|
||||
return __('Site');
|
||||
@@ -65,12 +63,15 @@ class SiteResource extends Resource
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('server.name')
|
||||
->label(__('Server'))
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\BadgeColumn::make('status')
|
||||
->enum([
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->badge()
|
||||
->formatStateUsing(fn (string $state) => match ($state) {
|
||||
Site::STATUS_BUSY => __('Busy'),
|
||||
Site::STATUS_ACTIVE => __('Active'),
|
||||
])
|
||||
default => __('Unknown status')
|
||||
})
|
||||
->colors([
|
||||
'warning' => Site::STATUS_BUSY,
|
||||
'success' => Site::STATUS_ACTIVE,
|
||||
@@ -78,15 +79,23 @@ class SiteResource extends Resource
|
||||
->label(__('Status')),
|
||||
Tables\Columns\TextColumn::make('users')
|
||||
->label(__('Users'))
|
||||
->getStateUsing(function (Site $record) {
|
||||
->wrap()
|
||||
->formatStateUsing(function (Site $record) {
|
||||
$state = $record
|
||||
->users
|
||||
->map(function (User $user) {
|
||||
return '<a href="' . route('filament.resources.users.edit', ['record' => $user]) . '" class="text-primary-600">' . $user->name . '</a>';
|
||||
return '<a href="' . UserResource::getUrl('edit', ['record' => $user]) . '" class="text-primary-600" style="white-space: nowrap">' . $user->name . '</a>';
|
||||
})
|
||||
->implode(', ') ?: '-';
|
||||
|
||||
return new HtmlString($state);
|
||||
})
|
||||
->searchable(query: function (Builder $query, string $search) {
|
||||
return $query->whereHas('users', function (Builder $query) use ($search) {
|
||||
return $query
|
||||
->where('name', 'LIKE', "%{$search}%")
|
||||
->orWhere('email', 'LIKE', "%{$search}%");
|
||||
});
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label(__('Date'))
|
||||
@@ -101,11 +110,12 @@ class SiteResource extends Resource
|
||||
Tables\Actions\Action::make('synchronize_site')
|
||||
->label(__('Synchronize'))
|
||||
->tooltip(__('This will synchronize the latest data from this provider to your Ploi Core installation'))
|
||||
->icon('heroicon-o-refresh')
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->action(function (Site $record) {
|
||||
app(SynchronizeSiteAction::class)->execute($record->server->ploi_id, $record->ploi_id);
|
||||
})
|
||||
->visible(fn (Site $record) => $record->status === Site::STATUS_ACTIVE),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
@@ -113,7 +123,7 @@ class SiteResource extends Resource
|
||||
->defaultSort('sites.created_at', 'desc');
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): \Illuminate\Database\Eloquent\Builder
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->with(['users', 'server']);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\SiteResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Actions;
|
||||
use App\Filament\Resources\SiteResource;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
@@ -10,7 +10,7 @@ class EditSite extends EditRecord
|
||||
{
|
||||
protected static string $resource = SiteResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
|
||||
namespace App\Filament\Resources\SiteResource\Pages;
|
||||
|
||||
use Filament\Actions;
|
||||
use App\Traits\HasPloi;
|
||||
use Filament\Pages\Actions\Action;
|
||||
use App\Filament\Resources\SiteResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ListSites extends ListRecords
|
||||
{
|
||||
@@ -14,28 +13,15 @@ class ListSites extends ListRecords
|
||||
|
||||
protected static string $resource = SiteResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('synchronize_sites')
|
||||
Actions\Action::make('synchronize_sites')
|
||||
->label(__('Synchronize sites'))
|
||||
->icon('heroicon-o-refresh')
|
||||
->color('secondary')
|
||||
->url(route('filament.resources.sites.synchronize')),
|
||||
|
||||
...parent::getActions()
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->color('gray')
|
||||
->url(SiteResource::getUrl('synchronize')),
|
||||
...parent::getHeaderActions()
|
||||
];
|
||||
}
|
||||
|
||||
protected function applySearchToTableQuery(Builder $query): Builder
|
||||
{
|
||||
if (filled($searchTerm = $this->getTableSearchQuery())) {
|
||||
$query
|
||||
->where('domain', 'LIKE', "%{$searchTerm}%")
|
||||
->orWhereHas('users', fn (Builder $query) => $query->where('name', 'LIKE', "%{$searchTerm}%"))
|
||||
->orWhereHas('users', fn (Builder $query) => $query->where('email', 'LIKE', "%{$searchTerm}%"));
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
namespace App\Filament\Resources\SiteResource\Pages;
|
||||
|
||||
use App\Models\Site;
|
||||
use Filament\Actions;
|
||||
use App\Models\Server;
|
||||
use App\Services\Ploi\Ploi;
|
||||
use Filament\Pages\Actions\Action;
|
||||
use Filament\Resources\Pages\Page;
|
||||
use App\Filament\Resources\SiteResource;
|
||||
use Filament\Notifications\Notification;
|
||||
@@ -23,15 +23,15 @@ class SynchronizeSites extends Page
|
||||
];
|
||||
}
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('synchronize_sites')
|
||||
Actions\Action::make('synchronize_sites')
|
||||
->label(__('Synchronize all sites'))
|
||||
->icon('heroicon-o-refresh')
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->requiresConfirmation()
|
||||
->modalHeading('Synchronize sites')
|
||||
->modalSubheading('This will synchronize all the sites that are listed in the table, to your Ploi Core installation.')
|
||||
->modalDescription('This will synchronize all the sites that are listed in the table, to your Ploi Core installation.')
|
||||
->action(function () {
|
||||
$availableSites = Ploi::make()->synchronize()->sites()->getData();
|
||||
|
||||
@@ -52,7 +52,7 @@ class SynchronizeSites extends Page
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->body(__('Sites synchronized successfully.'))
|
||||
->title(__('Sites synchronized successfully.'))
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Filament\Resources\SiteResource\RelationManagers;
|
||||
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use App\Filament\Resources\CertificateResource;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
|
||||
@@ -13,12 +13,12 @@ class CertificatesRelationManager extends RelationManager
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'domain';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return CertificateResource::form($form);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return CertificateResource::table($table);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Filament\Resources\SiteResource\RelationManagers;
|
||||
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use App\Filament\Resources\CronjobResource;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
|
||||
@@ -13,12 +13,12 @@ class CronjobsRelationManager extends RelationManager
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'command';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return CronjobResource::form($form);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return CronjobResource::table($table);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Filament\Resources\SiteResource\RelationManagers;
|
||||
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use App\Filament\Resources\DatabaseResource;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
|
||||
@@ -13,12 +13,12 @@ class DatabasesRelationManager extends RelationManager
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return DatabaseResource::form($form);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return DatabaseResource::table($table);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Filament\Resources\SiteResource\RelationManagers;
|
||||
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use App\Filament\Resources\RedirectResource;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
|
||||
@@ -13,12 +13,12 @@ class RedirectsRelationManager extends RelationManager
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'from';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return RedirectResource::form($form);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return RedirectResource::table($table);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Filament\Resources\SiteResource\RelationManagers;
|
||||
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use App\Filament\Resources\SiteSystemUserResource;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
|
||||
@@ -13,12 +13,12 @@ class SystemUsersRelationManager extends RelationManager
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'user_name';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return SiteSystemUserResource::form($form);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return SiteSystemUserResource::table($table);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
|
||||
namespace App\Filament\Resources\SiteResource\RelationManagers;
|
||||
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use App\Filament\Resources\UserResource;
|
||||
use Filament\Tables\Actions\AttachAction;
|
||||
use Filament\Tables\Actions\DetachAction;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
|
||||
class UsersRelationManager extends RelationManager
|
||||
@@ -25,20 +24,22 @@ class UsersRelationManager extends RelationManager
|
||||
return __('Users');
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return UserResource::form($form);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return UserResource::table($table)
|
||||
->headerActions([
|
||||
AttachAction::make()
|
||||
...$table->getHeaderActions(),
|
||||
Tables\Actions\AttachAction::make()
|
||||
->preloadRecordSelect(),
|
||||
])
|
||||
->appendActions([
|
||||
DetachAction::make(),
|
||||
->actions([
|
||||
...$table->getActions(),
|
||||
Tables\Actions\DetachAction::make(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class AvailableSitesOverview extends TableWidget
|
||||
return [
|
||||
Action::make('synchronize_site')
|
||||
->label(__('Synchronize'))
|
||||
->icon('heroicon-o-refresh')
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->action(function (AvailableSite $record) {
|
||||
app(SynchronizeSiteAction::class)->execute(ploiServerId: $record->server_id, ploiSiteId: $record->id);
|
||||
}),
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use Filament\Tables;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use App\Models\SiteSystemUser;
|
||||
use Filament\Resources\Resource;
|
||||
use App\Filament\Resources\SiteSystemUserResource\Pages;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\SiteSystemUserResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use App\Filament\Resources\SiteSystemUserResource;
|
||||
|
||||
@@ -10,7 +10,7 @@ class ListSiteSystemUsers extends ListRecords
|
||||
{
|
||||
protected static string $resource = SiteSystemUserResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use Filament\Tables;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Resources\Resource;
|
||||
use Laravel\Cashier\Subscription;
|
||||
use App\Filament\Resources\SubscriptionResource\Pages;
|
||||
@@ -13,7 +13,7 @@ class SubscriptionResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Subscription::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-cash';
|
||||
protected static ?string $navigationIcon = 'heroicon-o-banknotes';
|
||||
|
||||
protected static ?int $navigationSort = 4;
|
||||
|
||||
@@ -39,8 +39,9 @@ class SubscriptionResource extends Resource
|
||||
->url(fn ($record) => UserResource::getUrl('edit', ['record' => $record])),
|
||||
Tables\Columns\TextColumn::make('stripe_id')->searchable(),
|
||||
Tables\Columns\TextColumn::make('stripe_plan')->searchable(),
|
||||
Tables\Columns\BadgeColumn::make('stripe_status')
|
||||
Tables\Columns\TextColumn::make('stripe_status')
|
||||
->label('Status')
|
||||
->badge()
|
||||
->colors([
|
||||
'success' => \Stripe\Subscription::STATUS_ACTIVE,
|
||||
'warning' => \Stripe\Subscription::STATUS_PAST_DUE,
|
||||
@@ -55,6 +56,7 @@ class SubscriptionResource extends Resource
|
||||
])
|
||||
->actions([
|
||||
// Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\SubscriptionResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use App\Filament\Resources\SubscriptionResource;
|
||||
|
||||
@@ -10,7 +10,7 @@ class EditSubscription extends EditRecord
|
||||
{
|
||||
protected static string $resource = SubscriptionResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Tables;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use App\Models\SupportTicket;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\BadgeColumn;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Filament\Tables\Filters\MultiSelectFilter;
|
||||
use App\Filament\Resources\SupportTicketResource\Pages;
|
||||
|
||||
class SupportTicketResource extends Resource
|
||||
@@ -18,18 +16,18 @@ class SupportTicketResource extends Resource
|
||||
|
||||
protected static ?string $navigationGroup = 'Support';
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-support';
|
||||
protected static ?string $navigationIcon = 'heroicon-o-lifebuoy';
|
||||
|
||||
protected static ?string $label = 'Ticker';
|
||||
protected static ?string $label = 'Ticket';
|
||||
|
||||
protected static ?string $pluralLabel = 'Tickets';
|
||||
|
||||
protected static function shouldRegisterNavigation(): bool
|
||||
public static function shouldRegisterNavigation(): bool
|
||||
{
|
||||
return (bool) setting('support');
|
||||
return (bool)setting('support');
|
||||
}
|
||||
|
||||
protected static function getNavigationBadge(): ?string
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return static::getEloquentQuery()->count();
|
||||
}
|
||||
@@ -46,32 +44,35 @@ class SupportTicketResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
BadgeColumn::make('status')
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->label(__('Status'))
|
||||
->enum([
|
||||
->badge()
|
||||
->formatStateUsing(fn (string $state) => match ($state) {
|
||||
SupportTicket::STATUS_OPEN => __('Open'),
|
||||
SupportTicket::STATUS_CLOSED => __('Closed'),
|
||||
SupportTicket::STATUS_CUSTOMER_REPLY => __('Customer Reply'),
|
||||
SupportTicket::STATUS_SUPPORT_REPLY => __('Support Reply'),
|
||||
])
|
||||
default => __('Unknown status')
|
||||
})
|
||||
->colors([
|
||||
'primary' => [SupportTicket::STATUS_OPEN, SupportTicket::STATUS_SUPPORT_REPLY, SupportTicket::STATUS_CUSTOMER_REPLY],
|
||||
'danger' => SupportTicket::STATUS_CLOSED,
|
||||
])
|
||||
->wrap(false),
|
||||
TextColumn::make('title')
|
||||
Tables\Columns\TextColumn::make('title')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('replies_count')
|
||||
Tables\Columns\TextColumn::make('replies_count')
|
||||
->label(__('Replies'))
|
||||
->getStateUsing(fn (SupportTicket $record) => $record->replies->count()),
|
||||
TextColumn::make('user.name')
|
||||
Tables\Columns\TextColumn::make('user.name')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
])
|
||||
->filters([
|
||||
MultiSelectFilter::make('status')
|
||||
Tables\Filters\SelectFilter::make('status')
|
||||
->label(__('Status'))
|
||||
->multiple()
|
||||
->options([
|
||||
SupportTicket::STATUS_OPEN => __('Open'),
|
||||
SupportTicket::STATUS_CLOSED => __('Closed'),
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\SupportTicketResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions\CreateAction;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use App\Filament\Resources\SupportTicketResource;
|
||||
|
||||
@@ -10,10 +10,10 @@ class ListSupportTickets extends ListRecords
|
||||
{
|
||||
protected static string $resource = SupportTicketResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Filament\Resources\SupportTicketResource\Pages;
|
||||
|
||||
use Filament\Actions;
|
||||
use App\Models\SupportTicket;
|
||||
use Filament\Pages\Actions\Action;
|
||||
use Filament\Resources\Pages\Page;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
@@ -31,36 +31,36 @@ class ViewSupportTicket extends Page
|
||||
return __('View ticket') . ': ' . $this->record->title;
|
||||
}
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('close')
|
||||
Actions\Action::make('close')
|
||||
->label(__('Close'))
|
||||
->action(function (self $livewire) {
|
||||
$livewire->record->status = SupportTicket::STATUS_CLOSED;
|
||||
$livewire->record->save();
|
||||
|
||||
Notification::make()
|
||||
->body(__('Ticket closed'))
|
||||
->title(__('Ticket closed'))
|
||||
->success()
|
||||
->send();
|
||||
|
||||
$livewire->redirectRoute('filament.resources.support-tickets.view', $livewire->record);
|
||||
$livewire->redirect(SupportTicketResource::getUrl('view', ['record' => $livewire->record]));
|
||||
})
|
||||
->visible(fn (self $livewire) => $livewire->record->status !== SupportTicket::STATUS_CLOSED)
|
||||
->color('danger'),
|
||||
Action::make('reopen')
|
||||
Actions\Action::make('reopen')
|
||||
->label(__('Reopen'))
|
||||
->action(function (self $livewire) {
|
||||
$livewire->record->status = SupportTicket::STATUS_OPEN;
|
||||
$livewire->record->save();
|
||||
|
||||
Notification::make()
|
||||
->body(__('Ticket reopened'))
|
||||
->title(__('Ticket reopened'))
|
||||
->success()
|
||||
->send();
|
||||
|
||||
$livewire->redirectRoute('filament.resources.support-tickets.view', $livewire->record);
|
||||
$livewire->redirect(SupportTicketResource::getUrl('view', ['record' => $livewire->record]));
|
||||
})
|
||||
->visible(fn (self $livewire) => $livewire->record->status === SupportTicket::STATUS_CLOSED)
|
||||
->color('primary'),
|
||||
@@ -100,10 +100,10 @@ class ViewSupportTicket extends Page
|
||||
Mail::to($this->record->user)->send(new TicketRepliedToEmail($this->record));
|
||||
|
||||
$this->form->fill();
|
||||
$this->emit('$refresh');
|
||||
$this->dispatch('$refresh');
|
||||
|
||||
Notification::make()
|
||||
->body(__('Reply sent'))
|
||||
->title(__('Reply sent'))
|
||||
->success()
|
||||
->send();
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace App\Filament\Resources;
|
||||
use Filament\Forms;
|
||||
use App\Models\User;
|
||||
use Filament\Tables;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Resources\Resource;
|
||||
use STS\FilamentImpersonate\Impersonate;
|
||||
use App\Filament\Resources\UserResource\Pages;
|
||||
@@ -107,8 +107,11 @@ class UserResource extends Resource
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Impersonate::make('impersonate')->tooltip('Login as this user (impersonate)'),
|
||||
Impersonate::make('impersonate')
|
||||
->tooltip('Login as this user (impersonate)')
|
||||
->visible(fn () => config('core.impersonation')),
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
|
||||
@@ -2,10 +2,21 @@
|
||||
|
||||
namespace App\Filament\Resources\UserResource\Pages;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Filament\Resources\UserResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateUser extends CreateRecord
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected function handleRecordCreation(array $data): Model
|
||||
{
|
||||
$model = $this->getModel();
|
||||
$record = new $model;
|
||||
$record->forceFill($data);
|
||||
$record->save();
|
||||
|
||||
return $record;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Filament\Resources\UserResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Actions;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use App\Actions\User\DeleteUserAction;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Filament\Resources\UserResource;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
@@ -13,17 +14,25 @@ class EditUser extends EditRecord
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function handleRecordUpdate(Model $record, array $data): Model
|
||||
{
|
||||
$record->forceFill($data);
|
||||
$record->save();
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\Action::make('two_factor_authentication')
|
||||
->label(__('Disable two-factor authentication'))
|
||||
->color('secondary')
|
||||
->color('gray')
|
||||
->action(function () {
|
||||
$this->record->disableTwoFactorAuth();
|
||||
|
||||
Notification::make()
|
||||
->body(__('Two-factor authentication disabled'))
|
||||
->title(__('Two-factor authentication disabled'))
|
||||
->success()
|
||||
->send();
|
||||
})
|
||||
@@ -41,11 +50,11 @@ class EditUser extends EditRecord
|
||||
app(DeleteUserAction::class)->execute($this->getRecord(), $data['remove_all_data']);
|
||||
|
||||
Notification::make()
|
||||
->body(__('User deleted'))
|
||||
->title(__('User deleted'))
|
||||
->success()
|
||||
->send();
|
||||
|
||||
$this->redirectRoute('filament.resources.users.index');
|
||||
$this->redirect(UserResource::getUrl());
|
||||
})
|
||||
->color('danger'),
|
||||
];
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\UserResource\Pages;
|
||||
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Actions;
|
||||
use App\Filament\Resources\UserResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
@@ -10,7 +10,7 @@ class ListUsers extends ListRecords
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
|
||||
namespace App\Filament\Resources\UserResource\RelationManagers;
|
||||
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use App\Filament\Resources\ServerResource;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
|
||||
class ServersRelationManager extends RelationManager
|
||||
@@ -15,19 +13,13 @@ class ServersRelationManager extends RelationManager
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return ServerResource::form($form);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return ServerResource::table($table);
|
||||
}
|
||||
|
||||
protected function getTableQuery(): Builder|Relation
|
||||
{
|
||||
return parent::getTableQuery()
|
||||
->withCount('sites');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Filament\Resources\UserResource\RelationManagers;
|
||||
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Tables\Table;
|
||||
use App\Filament\Resources\SiteResource;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
|
||||
@@ -13,12 +13,12 @@ class SitesRelationManager extends RelationManager
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'domain';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return SiteResource::form($form);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return SiteResource::table($table);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ namespace App\Filament\Widgets;
|
||||
use App\Models\Site;
|
||||
use App\Models\User;
|
||||
use App\Models\Server;
|
||||
use Filament\Widgets\StatsOverviewWidget\Card;
|
||||
use App\Filament\Resources\SiteResource;
|
||||
use App\Filament\Resources\UserResource;
|
||||
use App\Filament\Resources\ServerResource;
|
||||
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
|
||||
|
||||
class StatsOverview extends BaseWidget
|
||||
@@ -13,14 +15,14 @@ class StatsOverview extends BaseWidget
|
||||
protected function getCards(): array
|
||||
{
|
||||
return [
|
||||
Card::make(__('Servers'), Server::count())
|
||||
->url(route('filament.resources.servers.index'))
|
||||
BaseWidget\Stat::make(__('Servers'), Server::count())
|
||||
->url(ServerResource::getUrl())
|
||||
->icon('heroicon-o-server'),
|
||||
Card::make(__('Sites'), Site::count())
|
||||
->url(route('filament.resources.sites.index'))
|
||||
BaseWidget\Stat::make(__('Sites'), Site::count())
|
||||
->url(SiteResource::getUrl())
|
||||
->icon('heroicon-o-globe-alt'),
|
||||
Card::make(__('Users'), User::count())
|
||||
->url(route('filament.resources.users.index'))
|
||||
BaseWidget\Stat::make(__('Users'), User::count())
|
||||
->url(UserResource::getUrl())
|
||||
->icon('heroicon-o-user'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use Filament\Tables;
|
||||
use App\Models\SystemLog;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Filament\Widgets\TableWidget as BaseWidget;
|
||||
|
||||
@@ -11,27 +12,28 @@ class SystemLogs extends BaseWidget
|
||||
{
|
||||
protected int|string|array $columnSpan = 'full';
|
||||
|
||||
protected int $defaultTableRecordsPerPageSelectOption = 10;
|
||||
|
||||
protected function getTableQuery(): Builder
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return SystemLog::query()
|
||||
->latest()
|
||||
->with('model');
|
||||
}
|
||||
|
||||
protected function getTableColumns(): array
|
||||
{
|
||||
return [
|
||||
TextColumn::make(__('Title'))
|
||||
->formatStateUsing(fn (SystemLog $record) => __($record->title, [
|
||||
'site' => $record->model->domain ?? '-Unknown-',
|
||||
'database' => $record->model->name ?? '-Unknown-',
|
||||
]))
|
||||
->description(fn (SystemLog $record) => __($record->description, [
|
||||
'site' => $record->model->domain ?? '-Unknown-',
|
||||
'database' => $record->model->name ?? '-Unknown-',
|
||||
])),
|
||||
];
|
||||
return $table
|
||||
->query(fn (): Builder => SystemLog::query()->with('model'))
|
||||
->defaultSort(fn (Builder $query) => $query->latest())
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('title')
|
||||
->label(__('Title'))
|
||||
->formatStateUsing(fn (SystemLog $record) => __($record->title, [
|
||||
'site' => $record->model->domain ?? '-Unknown-',
|
||||
'database' => $record->model->name ?? '-Unknown-',
|
||||
]))
|
||||
->description(fn (SystemLog $record) => __($record->description, [
|
||||
'site' => $record->model->domain ?? '-Unknown-',
|
||||
'database' => $record->model->name ?? '-Unknown-',
|
||||
]))
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label(__('Date'))
|
||||
->dateTime()
|
||||
->sortable()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class ServerController extends Controller
|
||||
]);
|
||||
|
||||
$server = app(CreateServerAction::class)->execute(
|
||||
ServerData::validate($data)
|
||||
ServerData::validateAndCreate($data)
|
||||
);
|
||||
|
||||
return response(content: ['data' => ServerData::from($server->refresh())->toArray()], status: 201);
|
||||
|
||||
@@ -29,7 +29,7 @@ class SiteController extends Controller
|
||||
]);
|
||||
|
||||
$site = app(CreateSiteAction::class)->execute(
|
||||
SiteData::validate($data)
|
||||
SiteData::validateAndCreate($data)
|
||||
);
|
||||
|
||||
$site->refresh();
|
||||
|
||||
@@ -32,7 +32,7 @@ class UserController extends Controller
|
||||
'requires_password_for_ftp' => ['nullable'],
|
||||
]);
|
||||
|
||||
$userData = UserData::validate($data);
|
||||
$userData = UserData::validateAndCreate($data);
|
||||
|
||||
$user = User::create($userData->toArray());
|
||||
|
||||
@@ -50,7 +50,7 @@ class UserController extends Controller
|
||||
'requires_password_for_ftp' => [],
|
||||
]);
|
||||
|
||||
$userData = UserData::validate($data);
|
||||
$userData = UserData::validateAndCreate($data);
|
||||
|
||||
$user->update(
|
||||
Arr::only($userData->toArray(), array_keys($data))
|
||||
|
||||
@@ -151,11 +151,11 @@ class ProfileBillingController extends Controller
|
||||
$planId = $plan->stripe_plan_id;
|
||||
|
||||
// Only do something if the user is not already subscribed to this plan.
|
||||
if ($user->subscribedToPlan($planId, 'default')) {
|
||||
if ($user->subscribedToPrice($planId, 'default')) {
|
||||
return redirect()->route('profile.billing.index')->with('error', 'You did not select a different plan');
|
||||
}
|
||||
|
||||
// If the user is already subscribed to the default plan, we have to swap it. Otherwise create a new one.
|
||||
// If the user is already subscribed to the default plan, we have to swap it. Otherwise, create a new one.
|
||||
try {
|
||||
if ($user->subscribed('default')) {
|
||||
$user->subscription('default')->swap($planId);
|
||||
@@ -208,9 +208,14 @@ class ProfileBillingController extends Controller
|
||||
|
||||
public function pdf(Request $request, $id)
|
||||
{
|
||||
$invoice = $request->user()->findInvoice($id);
|
||||
$planId = $invoice->lines->data[0]->plan->id;
|
||||
|
||||
$plan = Package::query()->where('stripe_plan_id', $planId)->first();
|
||||
|
||||
return $request->user()->downloadInvoice($id, [
|
||||
'vendor' => setting('name'),
|
||||
'product' => 'Webhosting',
|
||||
'product' => $plan->name,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -226,6 +231,7 @@ class ProfileBillingController extends Controller
|
||||
Package::CURRENCY_INR => 'INR ₹',
|
||||
Package::CURRENCY_THB => 'THB ',
|
||||
Package::CURRENCY_BRL => 'BRL R$ ',
|
||||
Package::CURRENCY_NZD => 'NZD $ ',
|
||||
];
|
||||
|
||||
return $currencies[strtolower($key)] ?? '$';
|
||||
|
||||
@@ -3,12 +3,14 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\ProviderPlan;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Jobs\Servers\DeleteServer;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use App\Http\Resources\ServerResource;
|
||||
use App\DataTransferObjects\ServerData;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Actions\Server\CreateServerAction;
|
||||
use App\Http\Requests\ServerUpdateRequest;
|
||||
|
||||
@@ -33,6 +35,12 @@ class ServerController extends Controller
|
||||
{
|
||||
$this->authorize('create', Server::class);
|
||||
|
||||
if ($package = $request->user()->package) {
|
||||
if ($package->maximum_servers > 0 && $request->user()->servers()->count() >= $package->maximum_servers) {
|
||||
return redirect()->back()->withErrors(['name' => 'You have received the maximum servers you\'re allowed to create.']);
|
||||
}
|
||||
}
|
||||
|
||||
$data = $request->validate([
|
||||
'name' => ['required'],
|
||||
'provider_id' => ['required'],
|
||||
@@ -44,7 +52,7 @@ class ServerController extends Controller
|
||||
$data['user_id'] = Auth::id();
|
||||
|
||||
app(CreateServerAction::class)->execute(
|
||||
ServerData::validate($data)
|
||||
ServerData::validateAndCreate($data)
|
||||
);
|
||||
|
||||
return redirect()->route('servers.index');
|
||||
@@ -95,19 +103,29 @@ class ServerController extends Controller
|
||||
|
||||
public function plansAndRegions(Request $request, $providerId)
|
||||
{
|
||||
$provider = $request->user()->package->providers()->findOrFail($providerId);
|
||||
$package = $request->user()->package;
|
||||
|
||||
$regions = $provider->regions()
|
||||
$provider = $package->providers()->findOrFail($providerId);
|
||||
|
||||
$regions = $provider
|
||||
->regions()
|
||||
->when($provider->allowed_regions, function ($query) use ($provider) {
|
||||
return $query->whereIn('id', $provider->allowed_regions);
|
||||
})
|
||||
->pluck('label', 'id');
|
||||
|
||||
$plans = $provider->plans()
|
||||
$plans = $provider
|
||||
->plans()
|
||||
->when($provider->allowed_plans, function ($query) use ($provider) {
|
||||
return $query->whereIn('id', $provider->allowed_plans);
|
||||
})
|
||||
->pluck('label', 'id');
|
||||
->when($package->providerPlans()->whereBelongsTo($provider)->exists(), function (Builder $query) use ($provider, $package) {
|
||||
return $query->whereIn('id', $package->providerPlans()->whereBelongsTo($provider)->pluck('provider_plans.id'));
|
||||
})
|
||||
->get()
|
||||
->mapWithKeys(function (ProviderPlan $providerPlan) {
|
||||
return [$providerPlan->id => $providerPlan->label ?? $providerPlan->plan_id];
|
||||
});
|
||||
|
||||
return [
|
||||
'regions' => $regions,
|
||||
|
||||
@@ -77,7 +77,7 @@ class SiteController extends Controller
|
||||
$request->merge(['user_id' => auth()->id()]);
|
||||
|
||||
$site = app(CreateSiteAction::class)->execute(
|
||||
SiteData::validate($request)
|
||||
SiteData::validateAndCreate($request)
|
||||
);
|
||||
|
||||
return $site
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Http\Request;
|
||||
use Livewire\Livewire;
|
||||
|
||||
class Demo
|
||||
{
|
||||
|
||||
@@ -11,12 +11,12 @@ class HasAccessToThisGroup
|
||||
public function handle(Request $request, Closure $next, $group)
|
||||
{
|
||||
if ($group === 'servers') {
|
||||
$package = $request->user()->package ?? [];
|
||||
$package = $request->user()->package ?? null;
|
||||
|
||||
if (
|
||||
!Arr::get($package->server_permissions, 'create', false) &&
|
||||
!Arr::get($package->server_permissions, 'update', false) &&
|
||||
!Arr::get($package->server_permissions, 'delete', false)
|
||||
!Arr::get($package->server_permissions ?? [], 'create', false) &&
|
||||
!Arr::get($package->server_permissions ?? [], 'update', false) &&
|
||||
!Arr::get($package->server_permissions ?? [], 'delete', false)
|
||||
) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ class InstallationComplete
|
||||
protected function isInstallationComplete()
|
||||
{
|
||||
return config('app.key') &&
|
||||
config('services.ploi.token') &&
|
||||
config('services.ploi.core-token');
|
||||
config('services.ploi.token');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,22 +8,12 @@ use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class SiteAppRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'type' => [
|
||||
@@ -32,7 +22,6 @@ class SiteAppRequest extends FormRequest
|
||||
Rule::in([
|
||||
Site::PROJECT_WORDPRESS,
|
||||
Site::PROJECT_NEXTCLOUD,
|
||||
Site::PROJECT_OCTOBERCMS
|
||||
])
|
||||
]
|
||||
];
|
||||
|
||||
@@ -16,18 +16,11 @@ class InstallApp implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasPloi;
|
||||
|
||||
public Site $site;
|
||||
public $type;
|
||||
public $options;
|
||||
|
||||
public function __construct(Site $site, string $type = Site::PROJECT_WORDPRESS, array $options = [])
|
||||
public function __construct(public Site $site, public string $type = Site::PROJECT_WORDPRESS, public array $options = [])
|
||||
{
|
||||
$this->site = $site;
|
||||
$this->type = $type;
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
public function handle(): void
|
||||
{
|
||||
$response = $this->getPloi()
|
||||
->server($this->site->server->ploi_id)
|
||||
|
||||
@@ -23,8 +23,7 @@ class Ping implements ShouldQueue
|
||||
|
||||
$response = Http::withHeaders([
|
||||
'Accept' => 'application/json',
|
||||
'Content-Type' => 'application/json',
|
||||
'X-Ploi-Core-Key' => config('services.ploi.core-token')
|
||||
'Content-Type' => 'application/json'
|
||||
])
|
||||
->withToken(config('services.ploi.token'))
|
||||
->post((new Ploi)->url . 'ping', [
|
||||
|
||||
@@ -14,27 +14,11 @@ class ChangePhpVersion implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasPloi;
|
||||
|
||||
public $site;
|
||||
public $version;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param Site $site
|
||||
* @param string $version
|
||||
*/
|
||||
public function __construct(Site $site, $version = '7.4')
|
||||
public function __construct(public Site $site, public $version = '8.2')
|
||||
{
|
||||
$this->site = $site;
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): void
|
||||
{
|
||||
$this->getPloi()->server($this->site->server->ploi_id)->sites($this->site->ploi_id)->phpVersion($this->version);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user