Compare commits

...

20 Commits

Author SHA1 Message Date
Dennis
e225499905 Assets fix 2026-01-14 08:15:15 +01:00
Dennis
9522b28b9d wip 2025-12-29 08:02:21 +01:00
Dennis
e3b944f450 updates 2025-10-28 13:34:34 +01:00
Dennis
e197a915b3 Add useragent 2025-10-28 13:31:05 +01:00
Dennis
db1240c43f Composer format & run action 2025-08-13 20:49:47 +02:00
Dennis
732ed7ea43 Merge branch 'master' of https://github.com/ploi/ploi-core 2025-08-13 20:46:37 +02:00
Dennis
e776ae299a Use Laravel prompts 💬 2025-08-13 20:46:33 +02:00
Dennis Smink
b8c07cde53 Merge pull request #38 from jelleroorda/fix-support-close-reopen
Fix closing and reopening of support tickets.
2025-08-13 20:24:23 +02:00
Dennis Smink
6eb36a84af Merge pull request #37 from jelleroorda/fix-support-ticket-mail
Use the proper route for in new ticket received mail.
2025-08-13 20:23:34 +02:00
Jelle Roorda
9622a08b74 Fix closing and reopening of support tickets. 2025-08-13 17:49:47 +02:00
Jelle Roorda
4d11e3939a Use the proper route for in new ticket received mail. 2025-08-13 17:41:15 +02:00
Dennis Smink
592bc2b0f6 Merge pull request #36 from ploi/prepare-open-source
Open Source 🔥
2025-08-12 11:39:15 +02:00
Dennis
33ccdd1b2d remove traces 2025-08-12 11:23:34 +02:00
Dennis
065773fb6f wip 2025-08-12 08:32:52 +02:00
Dennis
e26a7c2a50 Vite upgrade 2025-08-12 07:44:19 +02:00
Dennis
022caacb24 wip 2025-08-12 07:39:20 +02:00
Dennis
b5da1367d0 wip 2025-08-12 07:37:58 +02:00
Dennis
175134233b wip 2025-08-11 13:53:57 +02:00
Dennis
072018b122 wip 2025-04-11 09:10:21 +02:00
Dennis
694254cd21 prod mix 2025-01-07 10:34:38 +01:00
275 changed files with 47963 additions and 26033 deletions

0
.ai/mcp/mcp.json Normal file
View File

View File

@@ -7,7 +7,6 @@ APP_DEMO=false
APP_DATE_TIME_FORMAT="Y-m-d H:i:s"
PLOI_TOKEN=
PLOI_CORE_TOKEN=
IMPERSONATION=false

View File

@@ -11,7 +11,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: [8.2]
php: [8.4]
runs-on: ${{ matrix.os }}
steps:

1
.gitignore vendored
View File

@@ -21,3 +21,4 @@ yarn-error.log
rr
.rr.yaml
.DS_Store
.phpunit.cache

551
.junie/guidelines.md Normal file
View File

@@ -0,0 +1,551 @@
<laravel-boost-guidelines>
=== foundation rules ===
# Laravel Boost Guidelines
The Laravel Boost guidelines are specifically curated by Laravel maintainers for this application. These guidelines should be followed closely to enhance the user's satisfaction building Laravel applications.
## Foundational Context
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.
- php - 8.4.10
- filament/filament (FILAMENT) - v3
- inertiajs/inertia-laravel (INERTIA) - v2
- laravel/cashier (CASHIER) - v15
- laravel/framework (LARAVEL) - v11
- laravel/horizon (HORIZON) - v5
- laravel/octane (OCTANE) - v2
- laravel/prompts (PROMPTS) - v0
- livewire/livewire (LIVEWIRE) - v3
- tightenco/ziggy (ZIGGY) - v1
- laravel/dusk (DUSK) - v8
- laravel/mcp (MCP) - v0
- pestphp/pest (PEST) - v3
- phpunit/phpunit (PHPUNIT) - v11
- @inertiajs/vue3 (INERTIA) - v2
- tailwindcss (TAILWINDCSS) - v3
- vue (VUE) - v3
## Conventions
- You must follow all existing code conventions used in this application. When creating or editing a file, check sibling files for the correct structure, approach, naming.
- Use descriptive names for variables and methods. For example, `isRegisteredForDiscounts`, not `discount()`.
- Check for existing components to reuse before writing a new one.
## Verification Scripts
- Do not create verification scripts or tinker when tests cover that functionality and prove it works. Unit and feature tests are more important.
## Application Structure & Architecture
- Stick to existing directory structure - don't create new base folders without approval.
- Do not change the application's dependencies without approval.
## Frontend Bundling
- If the user doesn't see a frontend change reflected in the UI, it could mean they need to run `npm run build`, `npm run dev`, or `composer run dev`. Ask them.
## Replies
- Be concise in your explanations - focus on what's important rather than explaining obvious details.
## Documentation Files
- You must only create documentation files if explicitly requested by the user.
=== boost rules ===
## Laravel Boost
- Laravel Boost is an MCP server that comes with powerful tools designed specifically for this application. Use them.
## Artisan
- Use the `list-artisan-commands` tool when you need to call an Artisan command to double check the available parameters.
## URLs
- Whenever you share a project URL with the user you should use the `get-absolute-url` tool to ensure you're using the correct scheme, domain / IP, and port.
## Tinker / Debugging
- You should use the `tinker` tool when you need to execute PHP to debug code or query Eloquent models directly.
- Use the `database-query` tool when you only need to read from the database.
## Reading Browser Logs With the `browser-logs` Tool
- You can read browser logs, errors, and exceptions using the `browser-logs` tool from Boost.
- Only recent browser logs will be useful - ignore old logs.
## Searching Documentation (Critically Important)
- Boost comes with a powerful `search-docs` tool you should use before any other approaches. This tool automatically passes a list of installed packages and their versions to the remote Boost API, so it returns only version-specific documentation specific for the user's circumstance. You should pass an array of packages to filter on if you know you need docs for particular packages.
- The 'search-docs' tool is perfect for all Laravel related packages, including Laravel, Inertia, Livewire, Filament, Tailwind, Pest, Nova, Nightwatch, etc.
- You must use this tool to search for Laravel-ecosystem documentation before falling back to other approaches.
- Search the documentation before making code changes to ensure we are taking the correct approach.
- Use multiple, broad, simple, topic based queries to start. For example: `['rate limiting', 'routing rate limiting', 'routing']`.
- Do not add package names to queries - package information is already shared. For example, use `test resource table`, not `filament 4 test resource table`.
### Available Search Syntax
- You can and should pass multiple queries at once. The most relevant results will be returned first.
1. Simple Word Searches with auto-stemming - query=authentication - finds 'authenticate' and 'auth'
2. Multiple Words (AND Logic) - query=rate limit - finds knowledge containing both "rate" AND "limit"
3. Quoted Phrases (Exact Position) - query="infinite scroll" - Words must be adjacent and in that order
4. Mixed Queries - query=middleware "rate limit" - "middleware" AND exact phrase "rate limit"
5. Multiple Queries - queries=["authentication", "middleware"] - ANY of these terms
=== php rules ===
## PHP
- Always use curly braces for control structures, even if it has one line.
### Constructors
- Use PHP 8 constructor property promotion in `__construct()`.
- <code-snippet>public function __construct(public GitHub $github) { }</code-snippet>
- Do not allow empty `__construct()` methods with zero parameters.
### Type Declarations
- Always use explicit return type declarations for methods and functions.
- Use appropriate PHP type hints for method parameters.
<code-snippet name="Explicit Return Types and Method Params" lang="php">
protected function isAccessible(User $user, ?string $path = null): bool
{
...
}
</code-snippet>
## Comments
- Prefer PHPDoc blocks over comments. Never use comments within the code itself unless there is something _very_ complex going on.
## PHPDoc Blocks
- Add useful array shape type definitions for arrays when appropriate.
## Enums
- Typically, keys in an Enum should be TitleCase. For example: `FavoritePerson`, `BestLake`, `Monthly`.
=== tests rules ===
## Test Enforcement
- Every change must be programmatically tested. Write a new test or update an existing test, then run the affected tests to make sure they pass.
- Run the minimum number of tests needed to ensure code quality and speed. Use `php artisan test` with a specific filename or filter.
=== inertia-laravel/core rules ===
## Inertia Core
- Inertia.js components should be placed in the `resources/js/Pages` directory unless specified differently in the JS bundler (vite.config.js).
- Use `Inertia::render()` for server-side routing instead of traditional Blade views.
- Use `search-docs` for accurate guidance on all things Inertia.
<code-snippet lang="php" name="Inertia::render Example">
// routes/web.php example
Route::get('/users', function () {
return Inertia::render('Users/Index', [
'users' => User::all()
]);
});
</code-snippet>
=== inertia-laravel/v2 rules ===
## Inertia v2
- Make use of all Inertia features from v1 & v2. Check the documentation before making any changes to ensure we are taking the correct approach.
### Inertia v2 New Features
- Polling
- Prefetching
- Deferred props
- Infinite scrolling using merging props and `WhenVisible`
- Lazy loading data on scroll
### Deferred Props & Empty States
- When using deferred props on the frontend, you should add a nice empty state with pulsing / animated skeleton.
### Inertia Form General Guidance
- Build forms using the `useForm` helper. Use the code examples and `search-docs` tool with a query of `useForm helper` for guidance.
=== laravel/core rules ===
## Do Things the Laravel Way
- Use `php artisan make:` commands to create new files (i.e. migrations, controllers, models, etc.). You can list available Artisan commands using the `list-artisan-commands` tool.
- If you're creating a generic PHP class, use `php artisan make:class`.
- Pass `--no-interaction` to all Artisan commands to ensure they work without user input. You should also pass the correct `--options` to ensure correct behavior.
### Database
- Always use proper Eloquent relationship methods with return type hints. Prefer relationship methods over raw queries or manual joins.
- Use Eloquent models and relationships before suggesting raw database queries
- Avoid `DB::`; prefer `Model::query()`. Generate code that leverages Laravel's ORM capabilities rather than bypassing them.
- Generate code that prevents N+1 query problems by using eager loading.
- Use Laravel's query builder for very complex database operations.
### Model Creation
- When creating new models, create useful factories and seeders for them too. Ask the user if they need any other things, using `list-artisan-commands` to check the available options to `php artisan make:model`.
### APIs & Eloquent Resources
- For APIs, default to using Eloquent API Resources and API versioning unless existing API routes do not, then you should follow existing application convention.
### Controllers & Validation
- Always create Form Request classes for validation rather than inline validation in controllers. Include both validation rules and custom error messages.
- Check sibling Form Requests to see if the application uses array or string based validation rules.
### Queues
- Use queued jobs for time-consuming operations with the `ShouldQueue` interface.
### Authentication & Authorization
- Use Laravel's built-in authentication and authorization features (gates, policies, Sanctum, etc.).
### URL Generation
- When generating links to other pages, prefer named routes and the `route()` function.
### Configuration
- Use environment variables only in configuration files - never use the `env()` function directly outside of config files. Always use `config('app.name')`, not `env('APP_NAME')`.
### Testing
- When creating models for tests, use the factories for the models. Check if the factory has custom states that can be used before manually setting up the model.
- Faker: Use methods such as `$this->faker->word()` or `fake()->randomDigit()`. Follow existing conventions whether to use `$this->faker` or `fake()`.
- When creating tests, make use of `php artisan make:test [options] {name}` to create a feature test, and pass `--unit` to create a unit test. Most tests should be feature tests.
### Vite Error
- If you receive an "Illuminate\Foundation\ViteException: Unable to locate file in Vite manifest" error, you can run `npm run build` or ask the user to run `npm run dev` or `composer run dev`.
=== laravel/v11 rules ===
## Laravel 11
- Use the `search-docs` tool to get version specific documentation.
- This project upgraded from Laravel 10 without migrating to the new streamlined Laravel 11 file structure.
- This is **perfectly fine** and recommended by Laravel. Follow the existing structure from Laravel 10. We do not to need migrate to the Laravel 11 structure unless the user explicitly requests that.
### Laravel 10 Structure
- Middleware typically live in `app/Http/Middleware/` and service providers in `app/Providers/`.
- There is no `bootstrap/app.php` application configuration in a Laravel 10 structure:
- Middleware registration is in `app/Http/Kernel.php`
- Exception handling is in `app/Exceptions/Handler.php`
- Console commands and schedule registration is in `app/Console/Kernel.php`
- Rate limits likely exist in `RouteServiceProvider` or `app/Http/Kernel.php`
### Database
- When modifying a column, the migration must include all of the attributes that were previously defined on the column. Otherwise, they will be dropped and lost.
- Laravel 11 allows limiting eagerly loaded records natively, without external packages: `$query->latest()->limit(10);`.
### Models
- Casts can and likely should be set in a `casts()` method on a model rather than the `$casts` property. Follow existing conventions from other models.
### New Artisan Commands
- List Artisan commands using Boost's MCP tool, if available. New commands available in Laravel 11:
- `php artisan make:enum`
- `php artisan make:class `
- `php artisan make:interface `
=== livewire/core rules ===
## Livewire Core
- Use the `search-docs` tool to find exact version specific documentation for how to write Livewire & Livewire tests.
- Use the `php artisan make:livewire [Posts\CreatePost]` artisan command to create new components
- State should live on the server, with the UI reflecting it.
- All Livewire requests hit the Laravel backend, they're like regular HTTP requests. Always validate form data, and run authorization checks in Livewire actions.
## Livewire Best Practices
- Livewire components require a single root element.
- Use `wire:loading` and `wire:dirty` for delightful loading states.
- Add `wire:key` in loops:
```blade
@foreach ($items as $item)
<div wire:key="item-{{ $item->id }}">
{{ $item->name }}
</div>
@endforeach
```
- Prefer lifecycle hooks like `mount()`, `updatedFoo()` for initialization and reactive side effects:
<code-snippet name="Lifecycle hook examples" lang="php">
public function mount(User $user) { $this->user = $user; }
public function updatedSearch() { $this->resetPage(); }
</code-snippet>
## Testing Livewire
<code-snippet name="Example Livewire component test" lang="php">
Livewire::test(Counter::class)
->assertSet('count', 0)
->call('increment')
->assertSet('count', 1)
->assertSee(1)
->assertStatus(200);
</code-snippet>
<code-snippet name="Testing a Livewire component exists within a page" lang="php">
$this->get('/posts/create')
->assertSeeLivewire(CreatePost::class);
</code-snippet>
=== livewire/v3 rules ===
## Livewire 3
### Key Changes From Livewire 2
- These things changed in Livewire 2, but may not have been updated in this application. Verify this application's setup to ensure you conform with application conventions.
- Use `wire:model.live` for real-time updates, `wire:model` is now deferred by default.
- Components now use the `App\Livewire` namespace (not `App\Http\Livewire`).
- Use `$this->dispatch()` to dispatch events (not `emit` or `dispatchBrowserEvent`).
- Use the `components.layouts.app` view as the typical layout path (not `layouts.app`).
### New Directives
- `wire:show`, `wire:transition`, `wire:cloak`, `wire:offline`, `wire:target` are available for use. Use the documentation to find usage examples.
### Alpine
- Alpine is now included with Livewire, don't manually include Alpine.js.
- Plugins included with Alpine: persist, intersect, collapse, and focus.
### Lifecycle Hooks
- You can listen for `livewire:init` to hook into Livewire initialization, and `fail.status === 419` for the page expiring:
<code-snippet name="livewire:load example" lang="js">
document.addEventListener('livewire:init', function () {
Livewire.hook('request', ({ fail }) => {
if (fail && fail.status === 419) {
alert('Your session expired');
}
});
Livewire.hook('message.failed', (message, component) => {
console.error(message);
});
});
</code-snippet>
=== pest/core rules ===
## Pest
### Testing
- If you need to verify a feature is working, write or update a Unit / Feature test.
### Pest Tests
- All tests must be written using Pest. Use `php artisan make:test --pest {name}`.
- You must not remove any tests or test files from the tests directory without approval. These are not temporary or helper files - these are core to the application.
- Tests should test all of the happy paths, failure paths, and weird paths.
- Tests live in the `tests/Feature` and `tests/Unit` directories.
- Pest tests look and behave like this:
<code-snippet name="Basic Pest Test Example" lang="php">
it('is true', function () {
expect(true)->toBeTrue();
});
</code-snippet>
### Running Tests
- Run the minimal number of tests using an appropriate filter before finalizing code edits.
- To run all tests: `php artisan test`.
- To run all tests in a file: `php artisan test tests/Feature/ExampleTest.php`.
- To filter on a particular test name: `php artisan test --filter=testName` (recommended after making a change to a related file).
- When the tests relating to your changes are passing, ask the user if they would like to run the entire test suite to ensure everything is still passing.
### Pest Assertions
- When asserting status codes on a response, use the specific method like `assertForbidden` and `assertNotFound` instead of using `assertStatus(403)` or similar, e.g.:
<code-snippet name="Pest Example Asserting postJson Response" lang="php">
it('returns all', function () {
$response = $this->postJson('/api/docs', []);
$response->assertSuccessful();
});
</code-snippet>
### Mocking
- Mocking can be very helpful when appropriate.
- When mocking, you can use the `Pest\Laravel\mock` Pest function, but always import it via `use function Pest\Laravel\mock;` before using it. Alternatively, you can use `$this->mock()` if existing tests do.
- You can also create partial mocks using the same import or self method.
### Datasets
- Use datasets in Pest to simplify tests which have a lot of duplicated data. This is often the case when testing validation rules, so consider going with this solution when writing tests for validation rules.
<code-snippet name="Pest Dataset Example" lang="php">
it('has emails', function (string $email) {
expect($email)->not->toBeEmpty();
})->with([
'james' => 'james@laravel.com',
'taylor' => 'taylor@laravel.com',
]);
</code-snippet>
=== inertia-vue/core rules ===
## Inertia + Vue
- Vue components must have a single root element.
- Use `router.visit()` or `<Link>` for navigation instead of traditional links.
<code-snippet name="Inertia Client Navigation" lang="vue">
import { Link } from '@inertiajs/vue3'
<Link href="/">Home</Link>
</code-snippet>
=== inertia-vue/v2/forms rules ===
## Inertia + Vue Forms
<code-snippet name="Inertia Vue useForm example" lang="vue">
<script setup>
import { useForm } from '@inertiajs/vue3'
const form = useForm({
email: null,
password: null,
remember: false,
})
</script>
<template>
<form @submit.prevent="form.post('/login')">
<!-- email -->
<input type="text" v-model="form.email">
<div v-if="form.errors.email">{{ form.errors.email }}</div>
<!-- password -->
<input type="password" v-model="form.password">
<div v-if="form.errors.password">{{ form.errors.password }}</div>
<!-- remember me -->
<input type="checkbox" v-model="form.remember"> Remember Me
<!-- submit -->
<button type="submit" :disabled="form.processing">Login</button>
</form>
</template>
</code-snippet>
=== tailwindcss/core rules ===
## Tailwind Core
- Use Tailwind CSS classes to style HTML, check and use existing tailwind conventions within the project before writing your own.
- Offer to extract repeated patterns into components that match the project's conventions (i.e. Blade, JSX, Vue, etc..)
- Think through class placement, order, priority, and defaults - remove redundant classes, add classes to parent or child carefully to limit repetition, group elements logically
- You can use the `search-docs` tool to get exact examples from the official documentation when needed.
### Spacing
- When listing items, use gap utilities for spacing, don't use margins.
<code-snippet name="Valid Flex Gap Spacing Example" lang="html">
<div class="flex gap-8">
<div>Superior</div>
<div>Michigan</div>
<div>Erie</div>
</div>
</code-snippet>
### Dark Mode
- If existing pages and components support dark mode, new pages and components must support dark mode in a similar way, typically using `dark:`.
=== tailwindcss/v3 rules ===
## Tailwind 3
- Always use Tailwind CSS v3 - verify you're using only classes supported by this version.
=== filament/filament rules ===
## Filament
- Filament is used by this application, check how and where to follow existing application conventions.
- Filament is a Server-Driven UI (SDUI) framework for Laravel. It allows developers to define user interfaces in PHP using structured configuration objects. It is built on top of Livewire, Alpine.js, and Tailwind CSS.
- You can use the `search-docs` tool to get information from the official Filament documentation when needed. This is very useful for Artisan command arguments, specific code examples, testing functionality, relationship management, and ensuring you're following idiomatic practices.
- Utilize static `make()` methods for consistent component initialization.
### Artisan
- You must use the Filament specific Artisan commands to create new files or components for Filament. You can find these with the `list-artisan-commands` tool, or with `php artisan` and the `--help` option.
- Inspect the required options, always pass `--no-interaction`, and valid arguments for other options when applicable.
### Filament's Core Features
- Actions: Handle doing something within the application, often with a button or link. Actions encapsulate the UI, the interactive modal window, and the logic that should be executed when the modal window is submitted. They can be used anywhere in the UI and are commonly used to perform one-time actions like deleting a record, sending an email, or updating data in the database based on modal form input.
- Forms: Dynamic forms rendered within other features, such as resources, action modals, table filters, and more.
- Infolists: Read-only lists of data.
- Notifications: Flash notifications displayed to users within the application.
- Panels: The top-level container in Filament that can include all other features like pages, resources, forms, tables, notifications, actions, infolists, and widgets.
- Resources: Static classes that are used to build CRUD interfaces for Eloquent models. Typically live in `app/Filament/Resources`.
- Schemas: Represent components that define the structure and behavior of the UI, such as forms, tables, or lists.
- Tables: Interactive tables with filtering, sorting, pagination, and more.
- Widgets: Small component included within dashboards, often used for displaying data in charts, tables, or as a stat.
### Relationships
- Determine if you can use the `relationship()` method on form components when you need `options` for a select, checkbox, repeater, or when building a `Fieldset`:
<code-snippet name="Relationship example for Form Select" lang="php">
Forms\Components\Select::make('user_id')
->label('Author')
->relationship('author')
->required(),
</code-snippet>
## Testing
- It's important to test Filament functionality for user satisfaction.
- Ensure that you are authenticated to access the application within the test.
- Filament uses Livewire, so start assertions with `livewire()` or `Livewire::test()`.
### Example Tests
<code-snippet name="Filament Table Test" lang="php">
livewire(ListUsers::class)
->assertCanSeeTableRecords($users)
->searchTable($users->first()->name)
->assertCanSeeTableRecords($users->take(1))
->assertCanNotSeeTableRecords($users->skip(1))
->searchTable($users->last()->email)
->assertCanSeeTableRecords($users->take(-1))
->assertCanNotSeeTableRecords($users->take($users->count() - 1));
</code-snippet>
<code-snippet name="Filament Create Resource Test" lang="php">
livewire(CreateUser::class)
->fillForm([
'name' => 'Howdy',
'email' => 'howdy@example.com',
])
->call('create')
->assertNotified()
->assertRedirect();
assertDatabaseHas(User::class, [
'name' => 'Howdy',
'email' => 'howdy@example.com',
]);
</code-snippet>
<code-snippet name="Testing Multiple Panels (setup())" lang="php">
use Filament\Facades\Filament;
Filament::setCurrentPanel('app');
</code-snippet>
<code-snippet name="Calling an Action in a Test" lang="php">
livewire(EditInvoice::class, [
'invoice' => $invoice,
])->callAction('send');
expect($invoice->refresh())->isSent()->toBeTrue();
</code-snippet>
## Version 3 Changes To Focus On
- Resources are located in `app/Filament/Resources/` directory.
- Resource pages (List, Create, Edit) are auto-generated within the resource's directory - e.g., `app/Filament/Resources/PostResource/Pages/`.
- Forms use the `Forms\Components` namespace for form fields.
- Tables use the `Tables\Columns` namespace for table columns.
- A new `Filament\Forms\Components\RichEditor` component is available.
- Form and table schemas now use fluent method chaining.
- Added `php artisan filament:optimize` command for production optimization.
- Requires implementing `FilamentUser` contract for production access control.
</laravel-boost-guidelines>

11
.junie/mcp/mcp.json Normal file
View File

@@ -0,0 +1,11 @@
{
"mcpServers": {
"laravel-boost": {
"command": "/opt/homebrew/Cellar/php/8.4.10/bin/php",
"args": [
"/Users/dennissmink/Workspace/ploi-core/artisan",
"boost:mcp"
]
}
}
}

11
.mcp.json Normal file
View File

@@ -0,0 +1,11 @@
{
"mcpServers": {
"laravel-boost": {
"command": "php",
"args": [
"artisan",
"boost:mcp"
]
}
}
}

View File

@@ -15,4 +15,5 @@ return (new PhpCsFixer\Config)
'ordered_imports' => ['sort_algorithm' => 'length'],
'no_unused_imports' => true,
])
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
->setFinder($finder);

676
CLAUDE.md Normal file
View File

@@ -0,0 +1,676 @@
# 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.
===
<laravel-boost-guidelines>
=== foundation rules ===
# Laravel Boost Guidelines
The Laravel Boost guidelines are specifically curated by Laravel maintainers for this application. These guidelines should be followed closely to enhance the user's satisfaction building Laravel applications.
## Foundational Context
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.
- php - 8.4.10
- filament/filament (FILAMENT) - v3
- inertiajs/inertia-laravel (INERTIA) - v2
- laravel/cashier (CASHIER) - v15
- laravel/framework (LARAVEL) - v11
- laravel/horizon (HORIZON) - v5
- laravel/octane (OCTANE) - v2
- laravel/prompts (PROMPTS) - v0
- livewire/livewire (LIVEWIRE) - v3
- tightenco/ziggy (ZIGGY) - v1
- laravel/dusk (DUSK) - v8
- laravel/mcp (MCP) - v0
- pestphp/pest (PEST) - v3
- phpunit/phpunit (PHPUNIT) - v11
- @inertiajs/vue3 (INERTIA) - v2
- tailwindcss (TAILWINDCSS) - v3
- vue (VUE) - v3
## Conventions
- You must follow all existing code conventions used in this application. When creating or editing a file, check sibling files for the correct structure, approach, naming.
- Use descriptive names for variables and methods. For example, `isRegisteredForDiscounts`, not `discount()`.
- Check for existing components to reuse before writing a new one.
## Verification Scripts
- Do not create verification scripts or tinker when tests cover that functionality and prove it works. Unit and feature tests are more important.
## Application Structure & Architecture
- Stick to existing directory structure - don't create new base folders without approval.
- Do not change the application's dependencies without approval.
## Frontend Bundling
- If the user doesn't see a frontend change reflected in the UI, it could mean they need to run `npm run build`, `npm run dev`, or `composer run dev`. Ask them.
## Replies
- Be concise in your explanations - focus on what's important rather than explaining obvious details.
## Documentation Files
- You must only create documentation files if explicitly requested by the user.
=== boost rules ===
## Laravel Boost
- Laravel Boost is an MCP server that comes with powerful tools designed specifically for this application. Use them.
## Artisan
- Use the `list-artisan-commands` tool when you need to call an Artisan command to double check the available parameters.
## URLs
- Whenever you share a project URL with the user you should use the `get-absolute-url` tool to ensure you're using the correct scheme, domain / IP, and port.
## Tinker / Debugging
- You should use the `tinker` tool when you need to execute PHP to debug code or query Eloquent models directly.
- Use the `database-query` tool when you only need to read from the database.
## Reading Browser Logs With the `browser-logs` Tool
- You can read browser logs, errors, and exceptions using the `browser-logs` tool from Boost.
- Only recent browser logs will be useful - ignore old logs.
## Searching Documentation (Critically Important)
- Boost comes with a powerful `search-docs` tool you should use before any other approaches. This tool automatically passes a list of installed packages and their versions to the remote Boost API, so it returns only version-specific documentation specific for the user's circumstance. You should pass an array of packages to filter on if you know you need docs for particular packages.
- The 'search-docs' tool is perfect for all Laravel related packages, including Laravel, Inertia, Livewire, Filament, Tailwind, Pest, Nova, Nightwatch, etc.
- You must use this tool to search for Laravel-ecosystem documentation before falling back to other approaches.
- Search the documentation before making code changes to ensure we are taking the correct approach.
- Use multiple, broad, simple, topic based queries to start. For example: `['rate limiting', 'routing rate limiting', 'routing']`.
- Do not add package names to queries - package information is already shared. For example, use `test resource table`, not `filament 4 test resource table`.
### Available Search Syntax
- You can and should pass multiple queries at once. The most relevant results will be returned first.
1. Simple Word Searches with auto-stemming - query=authentication - finds 'authenticate' and 'auth'
2. Multiple Words (AND Logic) - query=rate limit - finds knowledge containing both "rate" AND "limit"
3. Quoted Phrases (Exact Position) - query="infinite scroll" - Words must be adjacent and in that order
4. Mixed Queries - query=middleware "rate limit" - "middleware" AND exact phrase "rate limit"
5. Multiple Queries - queries=["authentication", "middleware"] - ANY of these terms
=== php rules ===
## PHP
- Always use curly braces for control structures, even if it has one line.
### Constructors
- Use PHP 8 constructor property promotion in `__construct()`.
- <code-snippet>public function __construct(public GitHub $github) { }</code-snippet>
- Do not allow empty `__construct()` methods with zero parameters.
### Type Declarations
- Always use explicit return type declarations for methods and functions.
- Use appropriate PHP type hints for method parameters.
<code-snippet name="Explicit Return Types and Method Params" lang="php">
protected function isAccessible(User $user, ?string $path = null): bool
{
...
}
</code-snippet>
## Comments
- Prefer PHPDoc blocks over comments. Never use comments within the code itself unless there is something _very_ complex going on.
## PHPDoc Blocks
- Add useful array shape type definitions for arrays when appropriate.
## Enums
- Typically, keys in an Enum should be TitleCase. For example: `FavoritePerson`, `BestLake`, `Monthly`.
=== tests rules ===
## Test Enforcement
- Every change must be programmatically tested. Write a new test or update an existing test, then run the affected tests to make sure they pass.
- Run the minimum number of tests needed to ensure code quality and speed. Use `php artisan test` with a specific filename or filter.
=== inertia-laravel/core rules ===
## Inertia Core
- Inertia.js components should be placed in the `resources/js/Pages` directory unless specified differently in the JS bundler (vite.config.js).
- Use `Inertia::render()` for server-side routing instead of traditional Blade views.
- Use `search-docs` for accurate guidance on all things Inertia.
<code-snippet lang="php" name="Inertia::render Example">
// routes/web.php example
Route::get('/users', function () {
return Inertia::render('Users/Index', [
'users' => User::all()
]);
});
</code-snippet>
=== inertia-laravel/v2 rules ===
## Inertia v2
- Make use of all Inertia features from v1 & v2. Check the documentation before making any changes to ensure we are taking the correct approach.
### Inertia v2 New Features
- Polling
- Prefetching
- Deferred props
- Infinite scrolling using merging props and `WhenVisible`
- Lazy loading data on scroll
### Deferred Props & Empty States
- When using deferred props on the frontend, you should add a nice empty state with pulsing / animated skeleton.
### Inertia Form General Guidance
- Build forms using the `useForm` helper. Use the code examples and `search-docs` tool with a query of `useForm helper` for guidance.
=== laravel/core rules ===
## Do Things the Laravel Way
- Use `php artisan make:` commands to create new files (i.e. migrations, controllers, models, etc.). You can list available Artisan commands using the `list-artisan-commands` tool.
- If you're creating a generic PHP class, use `php artisan make:class`.
- Pass `--no-interaction` to all Artisan commands to ensure they work without user input. You should also pass the correct `--options` to ensure correct behavior.
### Database
- Always use proper Eloquent relationship methods with return type hints. Prefer relationship methods over raw queries or manual joins.
- Use Eloquent models and relationships before suggesting raw database queries
- Avoid `DB::`; prefer `Model::query()`. Generate code that leverages Laravel's ORM capabilities rather than bypassing them.
- Generate code that prevents N+1 query problems by using eager loading.
- Use Laravel's query builder for very complex database operations.
### Model Creation
- When creating new models, create useful factories and seeders for them too. Ask the user if they need any other things, using `list-artisan-commands` to check the available options to `php artisan make:model`.
### APIs & Eloquent Resources
- For APIs, default to using Eloquent API Resources and API versioning unless existing API routes do not, then you should follow existing application convention.
### Controllers & Validation
- Always create Form Request classes for validation rather than inline validation in controllers. Include both validation rules and custom error messages.
- Check sibling Form Requests to see if the application uses array or string based validation rules.
### Queues
- Use queued jobs for time-consuming operations with the `ShouldQueue` interface.
### Authentication & Authorization
- Use Laravel's built-in authentication and authorization features (gates, policies, Sanctum, etc.).
### URL Generation
- When generating links to other pages, prefer named routes and the `route()` function.
### Configuration
- Use environment variables only in configuration files - never use the `env()` function directly outside of config files. Always use `config('app.name')`, not `env('APP_NAME')`.
### Testing
- When creating models for tests, use the factories for the models. Check if the factory has custom states that can be used before manually setting up the model.
- Faker: Use methods such as `$this->faker->word()` or `fake()->randomDigit()`. Follow existing conventions whether to use `$this->faker` or `fake()`.
- When creating tests, make use of `php artisan make:test [options] {name}` to create a feature test, and pass `--unit` to create a unit test. Most tests should be feature tests.
### Vite Error
- If you receive an "Illuminate\Foundation\ViteException: Unable to locate file in Vite manifest" error, you can run `npm run build` or ask the user to run `npm run dev` or `composer run dev`.
=== laravel/v11 rules ===
## Laravel 11
- Use the `search-docs` tool to get version specific documentation.
- This project upgraded from Laravel 10 without migrating to the new streamlined Laravel 11 file structure.
- This is **perfectly fine** and recommended by Laravel. Follow the existing structure from Laravel 10. We do not to need migrate to the Laravel 11 structure unless the user explicitly requests that.
### Laravel 10 Structure
- Middleware typically live in `app/Http/Middleware/` and service providers in `app/Providers/`.
- There is no `bootstrap/app.php` application configuration in a Laravel 10 structure:
- Middleware registration is in `app/Http/Kernel.php`
- Exception handling is in `app/Exceptions/Handler.php`
- Console commands and schedule registration is in `app/Console/Kernel.php`
- Rate limits likely exist in `RouteServiceProvider` or `app/Http/Kernel.php`
### Database
- When modifying a column, the migration must include all of the attributes that were previously defined on the column. Otherwise, they will be dropped and lost.
- Laravel 11 allows limiting eagerly loaded records natively, without external packages: `$query->latest()->limit(10);`.
### Models
- Casts can and likely should be set in a `casts()` method on a model rather than the `$casts` property. Follow existing conventions from other models.
### New Artisan Commands
- List Artisan commands using Boost's MCP tool, if available. New commands available in Laravel 11:
- `php artisan make:enum`
- `php artisan make:class `
- `php artisan make:interface `
=== livewire/core rules ===
## Livewire Core
- Use the `search-docs` tool to find exact version specific documentation for how to write Livewire & Livewire tests.
- Use the `php artisan make:livewire [Posts\CreatePost]` artisan command to create new components
- State should live on the server, with the UI reflecting it.
- All Livewire requests hit the Laravel backend, they're like regular HTTP requests. Always validate form data, and run authorization checks in Livewire actions.
## Livewire Best Practices
- Livewire components require a single root element.
- Use `wire:loading` and `wire:dirty` for delightful loading states.
- Add `wire:key` in loops:
```blade
@foreach ($items as $item)
<div wire:key="item-{{ $item->id }}">
{{ $item->name }}
</div>
@endforeach
```
- Prefer lifecycle hooks like `mount()`, `updatedFoo()` for initialization and reactive side effects:
<code-snippet name="Lifecycle hook examples" lang="php">
public function mount(User $user) { $this->user = $user; }
public function updatedSearch() { $this->resetPage(); }
</code-snippet>
## Testing Livewire
<code-snippet name="Example Livewire component test" lang="php">
Livewire::test(Counter::class)
->assertSet('count', 0)
->call('increment')
->assertSet('count', 1)
->assertSee(1)
->assertStatus(200);
</code-snippet>
<code-snippet name="Testing a Livewire component exists within a page" lang="php">
$this->get('/posts/create')
->assertSeeLivewire(CreatePost::class);
</code-snippet>
=== livewire/v3 rules ===
## Livewire 3
### Key Changes From Livewire 2
- These things changed in Livewire 2, but may not have been updated in this application. Verify this application's setup to ensure you conform with application conventions.
- Use `wire:model.live` for real-time updates, `wire:model` is now deferred by default.
- Components now use the `App\Livewire` namespace (not `App\Http\Livewire`).
- Use `$this->dispatch()` to dispatch events (not `emit` or `dispatchBrowserEvent`).
- Use the `components.layouts.app` view as the typical layout path (not `layouts.app`).
### New Directives
- `wire:show`, `wire:transition`, `wire:cloak`, `wire:offline`, `wire:target` are available for use. Use the documentation to find usage examples.
### Alpine
- Alpine is now included with Livewire, don't manually include Alpine.js.
- Plugins included with Alpine: persist, intersect, collapse, and focus.
### Lifecycle Hooks
- You can listen for `livewire:init` to hook into Livewire initialization, and `fail.status === 419` for the page expiring:
<code-snippet name="livewire:load example" lang="js">
document.addEventListener('livewire:init', function () {
Livewire.hook('request', ({ fail }) => {
if (fail && fail.status === 419) {
alert('Your session expired');
}
});
Livewire.hook('message.failed', (message, component) => {
console.error(message);
});
});
</code-snippet>
=== pest/core rules ===
## Pest
### Testing
- If you need to verify a feature is working, write or update a Unit / Feature test.
### Pest Tests
- All tests must be written using Pest. Use `php artisan make:test --pest {name}`.
- You must not remove any tests or test files from the tests directory without approval. These are not temporary or helper files - these are core to the application.
- Tests should test all of the happy paths, failure paths, and weird paths.
- Tests live in the `tests/Feature` and `tests/Unit` directories.
- Pest tests look and behave like this:
<code-snippet name="Basic Pest Test Example" lang="php">
it('is true', function () {
expect(true)->toBeTrue();
});
</code-snippet>
### Running Tests
- Run the minimal number of tests using an appropriate filter before finalizing code edits.
- To run all tests: `php artisan test`.
- To run all tests in a file: `php artisan test tests/Feature/ExampleTest.php`.
- To filter on a particular test name: `php artisan test --filter=testName` (recommended after making a change to a related file).
- When the tests relating to your changes are passing, ask the user if they would like to run the entire test suite to ensure everything is still passing.
### Pest Assertions
- When asserting status codes on a response, use the specific method like `assertForbidden` and `assertNotFound` instead of using `assertStatus(403)` or similar, e.g.:
<code-snippet name="Pest Example Asserting postJson Response" lang="php">
it('returns all', function () {
$response = $this->postJson('/api/docs', []);
$response->assertSuccessful();
});
</code-snippet>
### Mocking
- Mocking can be very helpful when appropriate.
- When mocking, you can use the `Pest\Laravel\mock` Pest function, but always import it via `use function Pest\Laravel\mock;` before using it. Alternatively, you can use `$this->mock()` if existing tests do.
- You can also create partial mocks using the same import or self method.
### Datasets
- Use datasets in Pest to simplify tests which have a lot of duplicated data. This is often the case when testing validation rules, so consider going with this solution when writing tests for validation rules.
<code-snippet name="Pest Dataset Example" lang="php">
it('has emails', function (string $email) {
expect($email)->not->toBeEmpty();
})->with([
'james' => 'james@laravel.com',
'taylor' => 'taylor@laravel.com',
]);
</code-snippet>
=== inertia-vue/core rules ===
## Inertia + Vue
- Vue components must have a single root element.
- Use `router.visit()` or `<Link>` for navigation instead of traditional links.
<code-snippet name="Inertia Client Navigation" lang="vue">
import { Link } from '@inertiajs/vue3'
<Link href="/">Home</Link>
</code-snippet>
=== inertia-vue/v2/forms rules ===
## Inertia + Vue Forms
<code-snippet name="Inertia Vue useForm example" lang="vue">
<script setup>
import { useForm } from '@inertiajs/vue3'
const form = useForm({
email: null,
password: null,
remember: false,
})
</script>
<template>
<form @submit.prevent="form.post('/login')">
<!-- email -->
<input type="text" v-model="form.email">
<div v-if="form.errors.email">{{ form.errors.email }}</div>
<!-- password -->
<input type="password" v-model="form.password">
<div v-if="form.errors.password">{{ form.errors.password }}</div>
<!-- remember me -->
<input type="checkbox" v-model="form.remember"> Remember Me
<!-- submit -->
<button type="submit" :disabled="form.processing">Login</button>
</form>
</template>
</code-snippet>
=== tailwindcss/core rules ===
## Tailwind Core
- Use Tailwind CSS classes to style HTML, check and use existing tailwind conventions within the project before writing your own.
- Offer to extract repeated patterns into components that match the project's conventions (i.e. Blade, JSX, Vue, etc..)
- Think through class placement, order, priority, and defaults - remove redundant classes, add classes to parent or child carefully to limit repetition, group elements logically
- You can use the `search-docs` tool to get exact examples from the official documentation when needed.
### Spacing
- When listing items, use gap utilities for spacing, don't use margins.
<code-snippet name="Valid Flex Gap Spacing Example" lang="html">
<div class="flex gap-8">
<div>Superior</div>
<div>Michigan</div>
<div>Erie</div>
</div>
</code-snippet>
### Dark Mode
- If existing pages and components support dark mode, new pages and components must support dark mode in a similar way, typically using `dark:`.
=== tailwindcss/v3 rules ===
## Tailwind 3
- Always use Tailwind CSS v3 - verify you're using only classes supported by this version.
=== filament/filament rules ===
## Filament
- Filament is used by this application, check how and where to follow existing application conventions.
- Filament is a Server-Driven UI (SDUI) framework for Laravel. It allows developers to define user interfaces in PHP using structured configuration objects. It is built on top of Livewire, Alpine.js, and Tailwind CSS.
- You can use the `search-docs` tool to get information from the official Filament documentation when needed. This is very useful for Artisan command arguments, specific code examples, testing functionality, relationship management, and ensuring you're following idiomatic practices.
- Utilize static `make()` methods for consistent component initialization.
### Artisan
- You must use the Filament specific Artisan commands to create new files or components for Filament. You can find these with the `list-artisan-commands` tool, or with `php artisan` and the `--help` option.
- Inspect the required options, always pass `--no-interaction`, and valid arguments for other options when applicable.
### Filament's Core Features
- Actions: Handle doing something within the application, often with a button or link. Actions encapsulate the UI, the interactive modal window, and the logic that should be executed when the modal window is submitted. They can be used anywhere in the UI and are commonly used to perform one-time actions like deleting a record, sending an email, or updating data in the database based on modal form input.
- Forms: Dynamic forms rendered within other features, such as resources, action modals, table filters, and more.
- Infolists: Read-only lists of data.
- Notifications: Flash notifications displayed to users within the application.
- Panels: The top-level container in Filament that can include all other features like pages, resources, forms, tables, notifications, actions, infolists, and widgets.
- Resources: Static classes that are used to build CRUD interfaces for Eloquent models. Typically live in `app/Filament/Resources`.
- Schemas: Represent components that define the structure and behavior of the UI, such as forms, tables, or lists.
- Tables: Interactive tables with filtering, sorting, pagination, and more.
- Widgets: Small component included within dashboards, often used for displaying data in charts, tables, or as a stat.
### Relationships
- Determine if you can use the `relationship()` method on form components when you need `options` for a select, checkbox, repeater, or when building a `Fieldset`:
<code-snippet name="Relationship example for Form Select" lang="php">
Forms\Components\Select::make('user_id')
->label('Author')
->relationship('author')
->required(),
</code-snippet>
## Testing
- It's important to test Filament functionality for user satisfaction.
- Ensure that you are authenticated to access the application within the test.
- Filament uses Livewire, so start assertions with `livewire()` or `Livewire::test()`.
### Example Tests
<code-snippet name="Filament Table Test" lang="php">
livewire(ListUsers::class)
->assertCanSeeTableRecords($users)
->searchTable($users->first()->name)
->assertCanSeeTableRecords($users->take(1))
->assertCanNotSeeTableRecords($users->skip(1))
->searchTable($users->last()->email)
->assertCanSeeTableRecords($users->take(-1))
->assertCanNotSeeTableRecords($users->take($users->count() - 1));
</code-snippet>
<code-snippet name="Filament Create Resource Test" lang="php">
livewire(CreateUser::class)
->fillForm([
'name' => 'Howdy',
'email' => 'howdy@example.com',
])
->call('create')
->assertNotified()
->assertRedirect();
assertDatabaseHas(User::class, [
'name' => 'Howdy',
'email' => 'howdy@example.com',
]);
</code-snippet>
<code-snippet name="Testing Multiple Panels (setup())" lang="php">
use Filament\Facades\Filament;
Filament::setCurrentPanel('app');
</code-snippet>
<code-snippet name="Calling an Action in a Test" lang="php">
livewire(EditInvoice::class, [
'invoice' => $invoice,
])->callAction('send');
expect($invoice->refresh())->isSent()->toBeTrue();
</code-snippet>
## Version 3 Changes To Focus On
- Resources are located in `app/Filament/Resources/` directory.
- Resource pages (List, Create, Edit) are auto-generated within the resource's directory - e.g., `app/Filament/Resources/PostResource/Pages/`.
- Forms use the `Forms\Components` namespace for form fields.
- Tables use the `Tables\Columns` namespace for table columns.
- A new `Filament\Forms\Components\RichEditor` component is available.
- Form and table schemas now use fluent method chaining.
- Added `php artisan filament:optimize` command for production optimization.
- Requires implementing `FilamentUser` contract for production access control.
</laravel-boost-guidelines>

View File

@@ -22,7 +22,7 @@ class SynchronizeServerAction
return null;
}
if(!$serverData){
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.')

View File

@@ -2,6 +2,7 @@
namespace App\Casts;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
class Encrypted implements CastsAttributes
@@ -9,7 +10,7 @@ class Encrypted implements CastsAttributes
/**
* Cast the given value.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param Model $model
* @param string $key
* @param mixed $value
* @param array $attributes
@@ -23,7 +24,7 @@ class Encrypted implements CastsAttributes
/**
* Prepare the given value for storage.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param Model $model
* @param string $key
* @param array $value
* @param array $attributes

View File

@@ -2,6 +2,7 @@
namespace App\Casts;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
class PermissionCast implements CastsAttributes
@@ -9,7 +10,7 @@ class PermissionCast implements CastsAttributes
/**
* Cast the given value.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param Model $model
* @param string $key
* @param mixed $value
* @param array $attributes
@@ -31,7 +32,7 @@ class PermissionCast implements CastsAttributes
/**
* Prepare the given value for storage.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param Model $model
* @param string $key
* @param array $value
* @param array $attributes

View File

@@ -11,9 +11,19 @@ use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Console\Command;
use App\Services\VersionChecker;
use function Laravel\Prompts\info;
use function Laravel\Prompts\note;
use function Laravel\Prompts\spin;
use function Laravel\Prompts\text;
use Illuminate\Support\Facades\DB;
use function Laravel\Prompts\error;
use function Laravel\Prompts\intro;
use function Laravel\Prompts\outro;
use function Laravel\Prompts\select;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Artisan;
use function Laravel\Prompts\confirm;
use function Laravel\Prompts\warning;
use function Laravel\Prompts\password;
class Install extends Command
{
@@ -25,29 +35,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/261-getting-started/918-setting-up-email');
$this->info('Setting up cronjob & queue worker: https://docs.ploi-core.io/261-getting-started/638-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 +73,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 +211,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 +240,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 +460,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 +524,4 @@ class Install extends Command
$this->laravel['config'][$key] = $value;
}
protected function writeSeparationLine()
{
$this->info('*---------------------------------------------------------------------------*');
}
}

View File

@@ -2,6 +2,7 @@
namespace App\Console\Commands\Core;
use App\Models\Provider;
use App\Services\Ploi\Ploi;
use Illuminate\Console\Command;
@@ -18,10 +19,10 @@ class Synchronize extends Command
$data = collect($ploi->user()->serverProviders()->getData());
foreach ($data as $apiProvider) {
$provider = \App\Models\Provider::where('ploi_id', $apiProvider->id)->first();
$provider = Provider::where('ploi_id', $apiProvider->id)->first();
if (!$provider) {
$provider = \App\Models\Provider::create([
$provider = Provider::create([
'ploi_id' => $apiProvider->id,
'label' => $apiProvider->label,
'name' => $apiProvider->label

View File

@@ -2,6 +2,14 @@
namespace App\Filament\Pages;
use Filament\Schemas\Schema;
use Filament\Schemas\Components\Grid;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Actions\Action;
use Filament\Forms;
use App\Models\Server;
use App\Models\Package;
@@ -11,15 +19,15 @@ use Illuminate\Support\HtmlString;
use Illuminate\Support\Facades\Storage;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
use Filament\Forms\Components\Actions\Action;
class Settings extends Page
class Settings extends Page implements HasForms
{
protected static ?string $navigationIcon = 'heroicon-o-cog';
use InteractsWithForms;
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-cog';
protected static string $view = 'filament.pages.settings';
protected string $view = 'filament.pages.settings';
protected static ?string $navigationGroup = 'Settings';
protected static string | \UnitEnum | null $navigationGroup = 'Settings';
protected static ?int $navigationSort = 1;
@@ -50,37 +58,39 @@ class Settings extends Page
]);
}
public function getFormSchema(): array
public function form(Schema $schema): Schema
{
return [
Forms\Components\Grid::make(2)
->schema([
Forms\Components\Grid::make(2)
return $schema
->statePath('data')
->components([
Grid::make(2)
->schema([
Grid::make(2)
->schema([
Forms\Components\TextInput::make('name')
TextInput::make('name')
->label(__('Company name'))
->required(),
Forms\Components\TextInput::make('email')
TextInput::make('email')
->label(__('E-mail address'))
->email(),
Forms\Components\TextInput::make('support_emails')
TextInput::make('support_emails')
->label(__('Support email address'))
->helperText('Separate by comma to allow more email addresses'),
])
->columnSpan(2),
Forms\Components\Select::make('default_package')
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')),
Forms\Components\Select::make('default_language')
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'),
Forms\Components\FileUpload::make('logo')
FileUpload::make('logo')
->label(__('Logo'))
->disk('logos')
->columnSpan(2),
Forms\Components\Select::make('rotate_logs_after')
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"),
@@ -94,7 +104,7 @@ class Settings extends Page
'years-4' => __('Older than 4 years'),
])
->columnSpan(1),
Forms\Components\Select::make('default_os')
Select::make('default_os')
->label(__('Select the default OS that should be used when users create a server'))
->default(Server::OS_UBUNTU_22)
->options([
@@ -103,30 +113,30 @@ class Settings extends Page
Server::OS_UBUNTU_22 => __('Ubuntu 22'),
])
->columnSpan(1),
Forms\Components\Toggle::make('trial')
Toggle::make('trial')
->label(__('Enable trial'))
->helperText(__('This will allow you to have users with trials.')),
Forms\Components\Toggle::make('allow_registration')
Toggle::make('allow_registration')
->label(__('Allow registration'))
->helperText(__('Allow customer registration')),
Forms\Components\Toggle::make('support')
Toggle::make('support')
->label(__('Enable support platform'))
->helperText(__('This will allow your customers to make support requests to you.')),
Forms\Components\Toggle::make('documentation')
Toggle::make('documentation')
->label(__('Enable documentation platform'))
->helperText(__('This will allow you to create articles for your users to look at.')),
Forms\Components\Toggle::make('receive_email_on_server_creation')
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.')),
Forms\Components\Toggle::make('receive_email_on_site_creation')
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.')),
Forms\Components\Toggle::make('enable_api')
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/304-core-api/737-introduction" target="_blank" class="text-primary-600">' . __('More information') . '</a>')),
Forms\Components\TextInput::make('api_token')
TextInput::make('api_token')
->label(__('API token'))
->afterStateHydrated(function (?string $state, Forms\Components\TextInput $component) {
->afterStateHydrated(function (?string $state, TextInput $component) {
$state = filled($state) ? decrypt($state) : null;
$component->state($state);
@@ -144,16 +154,11 @@ class Settings extends Page
->tooltip('Generate'),
])
->suffixAction($generateAction),
Forms\Components\Toggle::make('isolate_per_site_per_user')
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.')),
]),
];
}
public function getFormStatePath(): ?string
{
return 'data';
]);
}
public function save(): void

View File

@@ -9,11 +9,11 @@ use Laravel\Horizon\Contracts\MasterSupervisorRepository;
class System extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-adjustments-vertical';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-adjustments-vertical';
protected static string $view = 'filament.pages.system';
protected string $view = 'filament.pages.system';
protected static ?string $navigationGroup = 'Settings';
protected static string | \UnitEnum | null $navigationGroup = 'Settings';
protected static ?int $navigationSort = 2;

View File

@@ -2,19 +2,26 @@
namespace App\Filament\Pages;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\MarkdownEditor;
use Filament\Actions\Action;
use Filament\Forms;
use Filament\Actions;
use Filament\Pages\Page;
use Filament\Schemas\Schema;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Illuminate\Support\Str;
use Filament\Notifications\Notification;
class Terms extends Page
class Terms extends Page implements HasForms
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
use InteractsWithForms;
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.terms';
protected string $view = 'filament.pages.terms';
protected static ?string $navigationGroup = 'Settings';
protected static string | \UnitEnum | null $navigationGroup = 'Settings';
protected static ?int $navigationSort = 3;
@@ -31,23 +38,25 @@ class Terms extends Page
]);
}
protected function getFormSchema(): array
public function form(Schema $schema): Schema
{
return [
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.')),
Forms\Components\MarkdownEditor::make('terms')
->label(__('Content Terms Of Service')),
Forms\Components\MarkdownEditor::make('privacy')
->label(__('Content Privacy Policy')),
];
return $schema
->statePath('data')
->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')
->label(__('Content Terms Of Service')),
MarkdownEditor::make('privacy')
->label(__('Content Privacy Policy')),
]);
}
protected function getHeaderActions(): array
{
return [
Actions\Action::make('load_terms_template')
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')))
@@ -72,11 +81,6 @@ class Terms extends Page
];
}
protected function getFormStatePath(): ?string
{
return 'data';
}
public function save(): void
{
$state = $this->form->getState();

View File

@@ -1,11 +1,18 @@
<?php
namespace App\Filament\Resources;
namespace App\Filament\Resources\Alerts;
use Filament\Schemas\Schema;
use Filament\Forms\Components\MarkdownEditor;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\DateTimePicker;
use Filament\Tables\Columns\TextColumn;
use App\Filament\Resources\Alerts\Pages\ListAlerts;
use App\Filament\Resources\Alerts\Pages\CreateAlert;
use App\Filament\Resources\Alerts\Pages\EditAlert;
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\Resource;
@@ -16,23 +23,23 @@ class AlertResource extends Resource
{
protected static ?string $model = Alert::class;
protected static ?string $navigationIcon = 'heroicon-o-bell';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-bell';
protected static ?string $navigationGroup = 'Settings';
protected static string | \UnitEnum | null $navigationGroup = 'Settings';
protected static ?int $navigationSort = 4;
protected static ?string $recordTitleAttribute = 'message';
public static function form(Form $form): Form
public static function form(Schema $schema): Schema
{
return $form
->schema([
Forms\Components\MarkdownEditor::make('message')
return $schema
->components([
MarkdownEditor::make('message')
->label(__('Content'))
->columnSpan(2)
->required(),
Forms\Components\Select::make('type')
Select::make('type')
->label(__('Type'))
->options([
Alert::TYPE_INFO => __('Informational'),
@@ -40,7 +47,7 @@ class AlertResource extends Resource
Alert::TYPE_DANGER => __('Danger'),
])
->required(),
Forms\Components\DateTimePicker::make('expires_at')
DateTimePicker::make('expires_at')
->label(__('Expires at'))
->seconds(false),
]);
@@ -50,10 +57,10 @@ class AlertResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('message')
TextColumn::make('message')
->label(__('Content'))
->formatStateUsing(fn (?string $state) => new HtmlString(Str::markdown($state))),
Tables\Columns\TextColumn::make('type')
TextColumn::make('type')
->label(__('Type'))
->badge()
->formatStateUsing(fn (string $state) => match ($state) {
@@ -67,7 +74,7 @@ class AlertResource extends Resource
'warning' => Alert::TYPE_WARNING,
'danger' => Alert::TYPE_DANGER,
]),
Tables\Columns\TextColumn::make('expires_at')
TextColumn::make('expires_at')
->label('Expires')
->default('-'),
]);
@@ -76,9 +83,9 @@ class AlertResource extends Resource
public static function getPages(): array
{
return [
'index' => Pages\ListAlerts::route('/'),
'create' => Pages\CreateAlert::route('/create'),
'edit' => Pages\EditAlert::route('/{record}/edit'),
'index' => ListAlerts::route('/'),
'create' => CreateAlert::route('/create'),
'edit' => EditAlert::route('/{record}/edit'),
];
}

View File

@@ -1,8 +1,8 @@
<?php
namespace App\Filament\Resources\AlertResource\Pages;
namespace App\Filament\Resources\Alerts\Pages;
use App\Filament\Resources\AlertResource;
use App\Filament\Resources\Alerts\AlertResource;
use Filament\Resources\Pages\CreateRecord;
class CreateAlert extends CreateRecord

View File

@@ -1,10 +1,11 @@
<?php
namespace App\Filament\Resources\AlertResource\Pages;
namespace App\Filament\Resources\Alerts\Pages;
use Filament\Actions\DeleteAction;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use App\Filament\Resources\AlertResource;
use App\Filament\Resources\Alerts\AlertResource;
class EditAlert extends EditRecord
{
@@ -13,7 +14,7 @@ class EditAlert extends EditRecord
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
DeleteAction::make(),
];
}
}

View File

@@ -1,11 +1,11 @@
<?php
namespace App\Filament\Resources\AlertResource\Pages;
namespace App\Filament\Resources\Alerts\Pages;
use Filament\Actions\CreateAction;
use Filament\Actions;
use App\Filament\Resources\AlertResource;
use App\Filament\Resources\Alerts\AlertResource;
use Filament\Resources\Pages\ListRecords;
use Illuminate\Contracts\Support\Htmlable;
class ListAlerts extends ListRecords
{
@@ -16,7 +16,7 @@ class ListAlerts extends ListRecords
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
CreateAction::make(),
];
}
}

View File

@@ -1,10 +1,17 @@
<?php
namespace App\Filament\Resources;
namespace App\Filament\Resources\Certificates;
use Filament\Schemas\Schema;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Textarea;
use Filament\Tables\Columns\TextColumn;
use Filament\Actions\EditAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use App\Filament\Resources\Certificates\Pages\ListCertificates;
use Filament\Forms;
use Filament\Tables;
use Filament\Forms\Form;
use Filament\Tables\Table;
use App\Models\Certificate;
use Filament\Resources\Resource;
@@ -16,24 +23,24 @@ class CertificateResource extends Resource
{
protected static ?string $model = Certificate::class;
protected static ?string $navigationIcon = 'heroicon-o-chat-bubble-bottom-center-text';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-chat-bubble-bottom-center-text';
protected static ?string $navigationGroup = 'Site management';
protected static string | \UnitEnum | null $navigationGroup = 'Site management';
protected static ?int $navigationSort = 2;
public static function form(Form $form): Form
public static function form(Schema $schema): Schema
{
return $form
->schema([
Forms\Components\TextInput::make('site.name'),
Forms\Components\TextInput::make('server_id'),
Forms\Components\TextInput::make('status'),
Forms\Components\TextInput::make('ploi_id'),
Forms\Components\TextInput::make('domain'),
Forms\Components\Textarea::make('certificate'),
Forms\Components\Textarea::make('private'),
Forms\Components\TextInput::make('type'),
return $schema
->components([
TextInput::make('site.name'),
TextInput::make('server_id'),
TextInput::make('status'),
TextInput::make('ploi_id'),
TextInput::make('domain'),
Textarea::make('certificate'),
Textarea::make('private'),
TextInput::make('type'),
]);
}
@@ -41,15 +48,15 @@ class CertificateResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('server.name')
TextColumn::make('server.name')
->searchable()
->label(__('Server')),
Tables\Columns\TextColumn::make('site.domain')
TextColumn::make('site.domain')
->searchable()
->label(__('Main domain')),
Tables\Columns\TextColumn::make('type')
TextColumn::make('type')
->label('Type'),
Tables\Columns\TextColumn::make('status')
TextColumn::make('status')
->badge()
->formatStateUsing(fn (string $state) => match ($state) {
Certificate::STATUS_BUSY => __('Busy'),
@@ -61,7 +68,7 @@ class CertificateResource extends Resource
'success' => Certificate::STATUS_ACTIVE,
])
->label(__('Status')),
Tables\Columns\TextColumn::make('domain')
TextColumn::make('domain')
->searchable()
->wrap()
->getStateUsing(function (Certificate $record) {
@@ -70,7 +77,7 @@ class CertificateResource extends Resource
return new HtmlString($state);
})
->label('Domains & aliases'),
Tables\Columns\TextColumn::make('created_at')
TextColumn::make('created_at')
->label(__('Date'))
->sortable()
->dateTime(),
@@ -78,12 +85,12 @@ class CertificateResource extends Resource
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
->recordActions([
EditAction::make(),
DeleteAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
->toolbarActions([
DeleteBulkAction::make(),
])
->defaultSort('created_at', 'desc');
}
@@ -104,7 +111,7 @@ class CertificateResource extends Resource
public static function getPages(): array
{
return [
'index' => Pages\ListCertificates::route('/'),
'index' => ListCertificates::route('/'),
];
}
}

View File

@@ -1,10 +1,11 @@
<?php
namespace App\Filament\Resources\CertificateResource\Pages;
namespace App\Filament\Resources\Certificates\Pages;
use Filament\Actions\CreateAction;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use App\Filament\Resources\CertificateResource;
use App\Filament\Resources\Certificates\CertificateResource;
class ListCertificates extends ListRecords
{
@@ -13,7 +14,7 @@ class ListCertificates extends ListRecords
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
CreateAction::make(),
];
}
}

View File

@@ -1,10 +1,12 @@
<?php
namespace App\Filament\Resources;
namespace App\Filament\Resources\Cronjobs;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn;
use App\Filament\Resources\Cronjobs\Pages\ListCronjobs;
use Filament\Tables;
use App\Models\Cronjob;
use Filament\Forms\Form;
use Filament\Tables\Table;
use Filament\Resources\Resource;
use App\Filament\Resources\CronjobResource\Pages;
@@ -13,16 +15,16 @@ class CronjobResource extends Resource
{
protected static ?string $model = Cronjob::class;
protected static ?string $navigationIcon = 'heroicon-o-clock';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-clock';
protected static ?string $navigationGroup = 'Site management';
protected static string | \UnitEnum | null $navigationGroup = 'Site management';
protected static ?int $navigationSort = 3;
public static function form(Form $form): Form
public static function form(Schema $schema): Schema
{
return $form
->schema([
return $schema
->components([
//
]);
}
@@ -31,10 +33,10 @@ class CronjobResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('site.domain')
TextColumn::make('site.domain')
->searchable()
->label(__('Site')),
Tables\Columns\TextColumn::make('status')
TextColumn::make('status')
->badge()
->formatStateUsing(fn (string $state) => match ($state) {
Cronjob::STATUS_BUSY => __('Busy'),
@@ -46,15 +48,15 @@ class CronjobResource extends Resource
'success' => Cronjob::STATUS_ACTIVE,
])
->label(__('Status')),
Tables\Columns\TextColumn::make('server.name')
TextColumn::make('server.name')
->searchable()
->label(__('Server')),
Tables\Columns\TextColumn::make('command')
TextColumn::make('command')
->searchable()
->label(__('Command')),
Tables\Columns\TextColumn::make('frequency')
TextColumn::make('frequency')
->label(__('Frequency')),
Tables\Columns\TextColumn::make('created_at')
TextColumn::make('created_at')
->label(__('Date'))
->sortable()
->dateTime(),
@@ -62,10 +64,10 @@ class CronjobResource extends Resource
->filters([
//
])
->actions([
->recordActions([
//
])
->bulkActions([
->toolbarActions([
//
])
->defaultSort('created_at', 'desc');
@@ -81,7 +83,7 @@ class CronjobResource extends Resource
public static function getPages(): array
{
return [
'index' => Pages\ListCronjobs::route('/'),
'index' => ListCronjobs::route('/'),
];
}
}

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Filament\Resources\CronjobResource\Pages;
namespace App\Filament\Resources\Cronjobs\Pages;
use Filament\Resources\Pages\CreateRecord;
use App\Filament\Resources\CronjobResource;
use App\Filament\Resources\Cronjobs\CronjobResource;
class CreateCronjob extends CreateRecord
{

View File

@@ -1,10 +1,11 @@
<?php
namespace App\Filament\Resources\CronjobResource\Pages;
namespace App\Filament\Resources\Cronjobs\Pages;
use Filament\Actions\DeleteAction;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use App\Filament\Resources\CronjobResource;
use App\Filament\Resources\Cronjobs\CronjobResource;
class EditCronjob extends EditRecord
{
@@ -13,7 +14,7 @@ class EditCronjob extends EditRecord
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
DeleteAction::make(),
];
}
}

View File

@@ -1,10 +1,11 @@
<?php
namespace App\Filament\Resources\CronjobResource\Pages;
namespace App\Filament\Resources\Cronjobs\Pages;
use Filament\Actions\CreateAction;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use App\Filament\Resources\CronjobResource;
use App\Filament\Resources\Cronjobs\CronjobResource;
class ListCronjobs extends ListRecords
{
@@ -13,7 +14,7 @@ class ListCronjobs extends ListRecords
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
CreateAction::make(),
];
}
}

View File

@@ -1,10 +1,14 @@
<?php
namespace App\Filament\Resources;
namespace App\Filament\Resources\Databases;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn;
use Filament\Actions\EditAction;
use App\Filament\Resources\Databases\Pages\ListDatabases;
use App\Filament\Resources\Databases\Pages\EditDatabase;
use Filament\Tables;
use App\Models\Database;
use Filament\Forms\Form;
use Filament\Tables\Table;
use Filament\Resources\Resource;
use App\Filament\Resources\DatabaseResource\Pages;
@@ -13,16 +17,16 @@ class DatabaseResource extends Resource
{
protected static ?string $model = Database::class;
protected static ?string $navigationIcon = 'heroicon-o-circle-stack';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-circle-stack';
protected static ?string $navigationGroup = 'Site management';
protected static string | \UnitEnum | null $navigationGroup = 'Site management';
protected static ?int $navigationSort = 4;
public static function form(Form $form): Form
public static function form(Schema $schema): Schema
{
return $form
->schema([
return $schema
->components([
//
]);
}
@@ -31,16 +35,16 @@ class DatabaseResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('name')
TextColumn::make('name')
->label(__('Name'))
->searchable(),
Tables\Columns\TextColumn::make('server.name')
TextColumn::make('server.name')
->label(__('Server'))
->searchable(),
Tables\Columns\TextColumn::make('site.domain')
TextColumn::make('site.domain')
->label(__('Site'))
->searchable(),
Tables\Columns\TextColumn::make('status')
TextColumn::make('status')
->badge()
->formatStateUsing(fn (string $state) => match ($state) {
Database::STATUS_BUSY => __('Busy'),
@@ -52,7 +56,7 @@ class DatabaseResource extends Resource
'success' => Database::STATUS_ACTIVE,
])
->label(__('Status')),
Tables\Columns\TextColumn::make('created_at')
TextColumn::make('created_at')
->label(__('Date'))
->sortable()
->dateTime(),
@@ -60,10 +64,10 @@ class DatabaseResource extends Resource
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
->recordActions([
EditAction::make(),
])
->bulkActions([
->toolbarActions([
//
])
->defaultSort('created_at', 'desc');
@@ -79,8 +83,8 @@ class DatabaseResource extends Resource
public static function getPages(): array
{
return [
'index' => Pages\ListDatabases::route('/'),
'edit' => Pages\EditDatabase::route('/{record}'),
'index' => ListDatabases::route('/'),
'edit' => EditDatabase::route('/{record}'),
];
}
}

View File

@@ -1,25 +1,25 @@
<?php
namespace App\Filament\Resources\DatabaseResource\Pages;
namespace App\Filament\Resources\Databases\Pages;
use App\Models\Database;
use App\Services\Ploi\Ploi;
use Filament\Resources\Pages\Page;
use Filament\Schemas\Schema;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use App\Mail\Database\PasswordReset;
use Illuminate\Support\Facades\Mail;
use Filament\Forms\Components\Toggle;
use Filament\Notifications\Notification;
use App\Filament\Resources\DatabaseResource;
use App\Filament\Resources\Databases\DatabaseResource;
class EditDatabase extends Page
class EditDatabase extends Page implements HasForms
{
protected $listeners = [
'$refresh',
];
use InteractsWithForms;
protected static string $resource = DatabaseResource::class;
protected static string $view = 'filament.resources.database-resource.pages.edit-database';
protected string $view = 'filament.resources.database-resource.pages.edit-database';
public Database $record;
@@ -30,16 +30,16 @@ class EditDatabase extends Page
$this->resetDatabasePasswordForm->fill();
}
public function getForms(): array
public ?array $resetDatabasePasswordData = [];
public function resetDatabasePasswordForm(Schema $schema): Schema
{
return [
'resetDatabasePasswordForm' => $this->makeForm()
->schema([
Toggle::make('send_new_password_to_user')
->label(__('Email new password to user')),
])
->model($this->record),
];
return $schema
->statePath('resetDatabasePasswordData')
->components([
Toggle::make('send_new_password_to_user')
->label(__('Email new password to user')),
]);
}
public function resetDatabasePassword(): void

View File

@@ -1,10 +1,11 @@
<?php
namespace App\Filament\Resources\DatabaseResource\Pages;
namespace App\Filament\Resources\Databases\Pages;
use Filament\Actions\CreateAction;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use App\Filament\Resources\DatabaseResource;
use App\Filament\Resources\Databases\DatabaseResource;
class ListDatabases extends ListRecords
{
@@ -13,7 +14,7 @@ class ListDatabases extends ListRecords
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
CreateAction::make(),
];
}
}

View File

@@ -1,10 +1,17 @@
<?php
namespace App\Filament\Resources;
namespace App\Filament\Resources\DocumentationCategories;
use Filament\Schemas\Schema;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\MarkdownEditor;
use Filament\Tables\Columns\TextColumn;
use App\Filament\Resources\DocumentationCategories\RelationManagers\DocumentationItemsRelationManager;
use App\Filament\Resources\DocumentationCategories\Pages\ListDocumentationCategories;
use App\Filament\Resources\DocumentationCategories\Pages\CreateDocumentationCategory;
use App\Filament\Resources\DocumentationCategories\Pages\EditDocumentationCategory;
use Filament\Forms;
use Filament\Tables;
use Filament\Forms\Form;
use Filament\Tables\Table;
use Illuminate\Support\Str;
use Filament\Resources\Resource;
@@ -17,9 +24,9 @@ class DocumentationCategoryResource extends Resource
{
protected static ?string $model = DocumentationCategory::class;
protected static ?string $navigationIcon = 'heroicon-o-tag';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-tag';
protected static ?string $navigationGroup = 'Documentation';
protected static string | \UnitEnum | null $navigationGroup = 'Documentation';
protected static ?int $navigationSort = 2;
@@ -32,16 +39,16 @@ class DocumentationCategoryResource extends Resource
return (bool)setting('documentation');
}
public static function form(Form $form): Form
public static function form(Schema $schema): Schema
{
return $form
->schema([
Forms\Components\TextInput::make('title')
return $schema
->components([
TextInput::make('title')
->label(__('Title'))
->unique(table: DocumentationCategory::class, column: 'title', ignoreRecord: true)
->required()
->columnSpan(2),
Forms\Components\MarkdownEditor::make('description')
MarkdownEditor::make('description')
->label(__('Description'))
->required()
->columnSpan(2),
@@ -52,11 +59,11 @@ class DocumentationCategoryResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('title')
TextColumn::make('title')
->searchable()
->sortable()
->label(__('Title')),
Tables\Columns\TextColumn::make('description')
TextColumn::make('description')
->label(__('Description'))
->formatStateUsing(fn (string $state) => new HtmlString(Str::markdown($state))),
]);
@@ -65,16 +72,16 @@ class DocumentationCategoryResource extends Resource
public static function getRelations(): array
{
return [
RelationManagers\DocumentationItemsRelationManager::class,
DocumentationItemsRelationManager::class,
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListDocumentationCategories::route('/'),
'create' => Pages\CreateDocumentationCategory::route('/create'),
'edit' => Pages\EditDocumentationCategory::route('/{record}/edit'),
'index' => ListDocumentationCategories::route('/'),
'create' => CreateDocumentationCategory::route('/create'),
'edit' => EditDocumentationCategory::route('/{record}/edit'),
];
}

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Filament\Resources\DocumentationCategoryResource\Pages;
namespace App\Filament\Resources\DocumentationCategories\Pages;
use Filament\Resources\Pages\CreateRecord;
use App\Filament\Resources\DocumentationCategoryResource;
use App\Filament\Resources\DocumentationCategories\DocumentationCategoryResource;
class CreateDocumentationCategory extends CreateRecord
{

View File

@@ -1,10 +1,11 @@
<?php
namespace App\Filament\Resources\DocumentationCategoryResource\Pages;
namespace App\Filament\Resources\DocumentationCategories\Pages;
use Filament\Actions\DeleteAction;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use App\Filament\Resources\DocumentationCategoryResource;
use App\Filament\Resources\DocumentationCategories\DocumentationCategoryResource;
class EditDocumentationCategory extends EditRecord
{
@@ -13,7 +14,7 @@ class EditDocumentationCategory extends EditRecord
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
DeleteAction::make(),
];
}
}

View File

@@ -1,10 +1,11 @@
<?php
namespace App\Filament\Resources\DocumentationCategoryResource\Pages;
namespace App\Filament\Resources\DocumentationCategories\Pages;
use Filament\Actions\CreateAction;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use App\Filament\Resources\DocumentationCategoryResource;
use App\Filament\Resources\DocumentationCategories\DocumentationCategoryResource;
class ListDocumentationCategories extends ListRecords
{
@@ -13,7 +14,7 @@ class ListDocumentationCategories extends ListRecords
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
CreateAction::make(),
];
}
}

View File

@@ -1,10 +1,16 @@
<?php
namespace App\Filament\Resources\DocumentationCategoryResource\RelationManagers;
namespace App\Filament\Resources\DocumentationCategories\RelationManagers;
use Filament\Schemas\Schema;
use Filament\Forms\Components\TextInput;
use Filament\Tables\Columns\TextColumn;
use Filament\Actions\CreateAction;
use Filament\Actions\EditAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Forms;
use Filament\Tables;
use Filament\Forms\Form;
use Filament\Tables\Table;
use Filament\Resources\RelationManagers\RelationManager;
@@ -18,11 +24,11 @@ class DocumentationItemsRelationManager extends RelationManager
protected static ?string $pluralLabel = 'Articles';
public function form(Form $form): Form
public function form(Schema $schema): Schema
{
return $form
->schema([
Forms\Components\TextInput::make('title')
return $schema
->components([
TextInput::make('title')
->required()
->maxLength(255),
]);
@@ -32,20 +38,20 @@ class DocumentationItemsRelationManager extends RelationManager
{
return $table
->columns([
Tables\Columns\TextColumn::make('title'),
TextColumn::make('title'),
])
->filters([
//
])
->headerActions([
Tables\Actions\CreateAction::make(),
CreateAction::make(),
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
->recordActions([
EditAction::make(),
DeleteAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
->toolbarActions([
DeleteBulkAction::make(),
]);
}
}

View File

@@ -1,10 +1,17 @@
<?php
namespace App\Filament\Resources;
namespace App\Filament\Resources\DocumentationItems;
use Filament\Schemas\Schema;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\MarkdownEditor;
use Filament\Tables\Columns\TextColumn;
use App\Filament\Resources\DocumentationItems\Pages\ListDocumentationItems;
use App\Filament\Resources\DocumentationItems\Pages\CreateDocumentationItem;
use App\Filament\Resources\DocumentationItems\Pages\EditDocumentationItem;
use Filament\Forms;
use Filament\Tables;
use Filament\Forms\Form;
use Filament\Tables\Table;
use Filament\Resources\Resource;
use App\Models\DocumentationItem;
@@ -14,9 +21,9 @@ class DocumentationItemResource extends Resource
{
protected static ?string $model = DocumentationItem::class;
protected static ?string $navigationIcon = 'heroicon-o-document-duplicate';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-document-duplicate';
protected static ?string $navigationGroup = 'Documentation';
protected static string | \UnitEnum | null $navigationGroup = 'Documentation';
protected static ?int $navigationSort = 1;
@@ -29,18 +36,18 @@ class DocumentationItemResource extends Resource
return (bool)setting('documentation');
}
public static function form(Form $form): Form
public static function form(Schema $schema): Schema
{
return $form
->schema([
Forms\Components\TextInput::make('title')
return $schema
->components([
TextInput::make('title')
->label(__('Title'))
->required(),
Forms\Components\Select::make('documentation_category_id')
Select::make('documentation_category_id')
->relationship('category', 'title')
->searchable()
->preload(),
Forms\Components\MarkdownEditor::make('content')
MarkdownEditor::make('content')
->label(__('Content'))
->required()
->columnSpan(2),
@@ -51,10 +58,10 @@ class DocumentationItemResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('title')
TextColumn::make('title')
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('category.title')
TextColumn::make('category.title')
->searchable()
->sortable(),
]);
@@ -63,9 +70,9 @@ class DocumentationItemResource extends Resource
public static function getPages(): array
{
return [
'index' => Pages\ListDocumentationItems::route('/'),
'create' => Pages\CreateDocumentationItem::route('/create'),
'edit' => Pages\EditDocumentationItem::route('/{record}/edit'),
'index' => ListDocumentationItems::route('/'),
'create' => CreateDocumentationItem::route('/create'),
'edit' => EditDocumentationItem::route('/{record}/edit'),
];
}
}

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Filament\Resources\DocumentationItemResource\Pages;
namespace App\Filament\Resources\DocumentationItems\Pages;
use Filament\Resources\Pages\CreateRecord;
use App\Filament\Resources\DocumentationItemResource;
use App\Filament\Resources\DocumentationItems\DocumentationItemResource;
class CreateDocumentationItem extends CreateRecord
{

View File

@@ -1,10 +1,11 @@
<?php
namespace App\Filament\Resources\DocumentationItemResource\Pages;
namespace App\Filament\Resources\DocumentationItems\Pages;
use Filament\Actions\DeleteAction;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use App\Filament\Resources\DocumentationItemResource;
use App\Filament\Resources\DocumentationItems\DocumentationItemResource;
class EditDocumentationItem extends EditRecord
{
@@ -13,7 +14,7 @@ class EditDocumentationItem extends EditRecord
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
DeleteAction::make(),
];
}
}

View File

@@ -1,10 +1,11 @@
<?php
namespace App\Filament\Resources\DocumentationItemResource\Pages;
namespace App\Filament\Resources\DocumentationItems\Pages;
use Filament\Actions\CreateAction;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use App\Filament\Resources\DocumentationItemResource;
use App\Filament\Resources\DocumentationItems\DocumentationItemResource;
class ListDocumentationItems extends ListRecords
{
@@ -13,7 +14,7 @@ class ListDocumentationItems extends ListRecords
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
CreateAction::make(),
];
}
}

View File

@@ -1,57 +1,80 @@
<?php
namespace App\Filament\Resources;
namespace App\Filament\Resources\Packages;
use App\Filament\Resources\PackageResource\Pages;
use App\Filament\Resources\PackageResource\RelationManagers;
use Filament\Schemas\Schema;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Select;
use Filament\Schemas\Components\Grid;
use Filament\Schemas\Components\Section;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\CheckboxList;
use Filament\Schemas\Components\Actions;
use Filament\Actions\Action;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Components\Utilities\Set;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Forms\Components\Placeholder;
use Filament\Tables\Columns\TextColumn;
use Filament\Actions\EditAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use App\Filament\Resources\Packages\RelationManagers\UsersRelationManager;
use App\Filament\Resources\Packages\Pages\ListPackages;
use App\Filament\Resources\Packages\Pages\CreatePackage;
use App\Filament\Resources\Packages\Pages\EditPackage;
use Filament\Forms;
use Filament\Tables;
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 App\Models\ProviderPlan;
use Filament\Resources\Resource;
use Illuminate\Support\HtmlString;
use Filament\Notifications\Notification;
use App\Filament\Resources\Servers\ServerResource;
use App\Filament\Resources\Sites\SiteResource;
use App\Filament\Resources\Providers\ProviderResource;
use App\Filament\Resources\PackageResource\Pages;
use App\Filament\Resources\PackageResource\RelationManagers;
class PackageResource extends Resource
{
protected static ?string $model = Package::class;
protected static ?string $navigationIcon = 'heroicon-o-swatch';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-swatch';
protected static ?int $navigationSort = 3;
public static function form(Form $form): Form
public static function form(Schema $schema): Schema
{
return $form
->schema([
Forms\Components\TextInput::make('name')
return $schema
->components([
TextInput::make('name')
->label(__('Name'))
->required()
->columnSpan(2),
Forms\Components\TextInput::make('maximum_sites')
TextInput::make('maximum_sites')
->helperText(__('Set to 0 for unlimited'))
->integer()
->required(),
Forms\Components\TextInput::make('maximum_servers')
TextInput::make('maximum_servers')
->helperText(__('Set to 0 for unlimited'))
->integer()
->required(),
Forms\Components\TextInput::make('stripe_plan_id')
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),
Forms\Components\TextInput::make('price_monthly')
TextInput::make('price_monthly')
->label(__('Monthly price'))
->helperText(__('Fill this in if you want it to be monthly payments'))
->required(),
Forms\Components\TextInput::make('price_yearly')
TextInput::make('price_yearly')
->label(__('Yearly price'))
->helperText(__('Fill this in if you want it to be yearly payments'))
->required(),
Forms\Components\Select::make('currency')
Select::make('currency')
->label(__('Currency'))
->options([
'usd' => 'USD $',
@@ -66,76 +89,76 @@ class PackageResource extends Resource
'nz' => 'NZD $ (New Zealand Dollar)',
])
->required(),
Forms\Components\Grid::make()
Grid::make()
->schema([
Forms\Components\Section::make(__('Server permissions'))
Section::make(__('Server permissions'))
->icon(ServerResource::getNavigationIcon())
->schema([
Forms\Components\Checkbox::make('server_permissions.create')
Checkbox::make('server_permissions.create')
->reactive()
->label('Allow server creation')
->helperText('This will allow users to create servers'),
Forms\Components\Checkbox::make('server_permissions.update')
Checkbox::make('server_permissions.update')
->label('Allow server updates')
->helperText('This will allow users to update servers'),
Forms\Components\Checkbox::make('server_permissions.delete')
Checkbox::make('server_permissions.delete')
->label('Allow server deletion')
->helperText('This will allow users to delete servers'),
])
->columnSpan(1),
Forms\Components\Section::make(__('Site permissions'))
Section::make(__('Site permissions'))
->icon(SiteResource::getNavigationIcon())
->schema([
Forms\Components\Checkbox::make('site_permissions.create')
Checkbox::make('site_permissions.create')
->label('Allow site creation')
->helperText('This will allow users to create sites'),
Forms\Components\Checkbox::make('site_permissions.update')
Checkbox::make('site_permissions.update')
->label('Allow site updates')
->helperText('This will allow users to update sites'),
Forms\Components\Checkbox::make('site_permissions.delete')
Checkbox::make('site_permissions.delete')
->label('Allow site deletion')
->helperText('This will allow users to delete sites'),
])
->columnSpan(1),
]),
Forms\Components\Grid::make()
Grid::make()
->schema([
Forms\Components\Section::make(__('Available server providers'))
Section::make(__('Available server providers'))
->description(__('These server providers will be available for users that are attached to this package.'))
->icon(ProviderResource::getNavigationIcon())
->schema([
Forms\Components\CheckboxList::make('providers')
CheckboxList::make('providers')
->relationship('providers', 'name')
->reactive(),
Forms\Components\Grid::make(1)
Grid::make(1)
->schema([
Forms\Components\Actions::make([
Forms\Components\Actions\Action::make('manage_provider_plans')
Actions::make([
Action::make('manage_provider_plans')
->label(__('Manage provider plans'))
->icon('heroicon-o-adjustments-horizontal')
->form(function (Package $record) {
->schema(function (Package $record) {
return $record->providers->sortBy('name')->map(function (Provider $provider) {
return Forms\Components\Section::make($provider->label)
return 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')
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) {
->afterStateUpdated(function (Toggle $component, Set $set) use ($provider) {
$set(
path: "provider_plans",
state: $component->getState() ? $provider->plans->pluck('id') : [],
);
}),
Forms\Components\CheckboxList::make("provider_plans")
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'))
->options(fn () => $provider->plans->mapWithKeys(fn (ProviderPlan $providerPlan) => [$providerPlan->id => $providerPlan->label ?? $providerPlan->plan_id])->all())
->visible(fn (Get $get) => $get('select_specific_provider_plans'))
->reactive()
->bulkToggleable()
->columns(2)
@@ -172,22 +195,22 @@ class PackageResource extends Resource
})
->modalSubmitActionLabel(__('Save'))
->color('gray')
->disabled(function (Package $record, Forms\Get $get) {
->disabled(function (Package $record, Get $get) {
$providers = collect($get('providers'))
->map(fn(string $id): int => (int)$id)
->map(fn (string $id): int => (int)$id)
->sort();
return $record->providers->pluck('id')->map(fn(string $id): int => (int)$id)->sort()->toArray() !== $providers->all();
return $record->providers->pluck('id')->map(fn (string $id): int => (int)$id)->sort()->toArray() !== $providers->all();
})
]),
Forms\Components\Placeholder::make('save_warning')
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) {
->visible(function (Package $record, Get $get) {
$providers = collect($get('providers'))
->map(fn(string $id): int => (int)$id)
->map(fn (string $id): int => (int)$id)
->sort();
return $record->providers->pluck('id')->map(fn(string $id): int => (int)$id)->sort()->toArray() !== $providers->all();
return $record->providers->pluck('id')->map(fn (string $id): int => (int)$id)->sort()->toArray() !== $providers->all();
})
->hiddenLabel(),
])
@@ -205,10 +228,10 @@ class PackageResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('id')
TextColumn::make('id')
->label('ID')
->searchable(),
Tables\Columns\TextColumn::make('name')
TextColumn::make('name')
->label(__('Name'))
->description(function (Package $record) {
if (!$record->stripe_plan_id) {
@@ -217,40 +240,40 @@ 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)
TextColumn::make('maximum_sites')
->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)
TextColumn::make('maximum_servers')
->formatStateUsing(fn (int $state) => $state === 0 ? __('Unlimited') : $state)
->label(__('Maximum servers')),
Tables\Columns\TextColumn::make('users_count')
TextColumn::make('users_count')
->counts('users'),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
->recordActions([
EditAction::make(),
DeleteAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
->toolbarActions([
DeleteBulkAction::make(),
]);
}
public static function getRelations(): array
{
return [
RelationManagers\UsersRelationManager::class,
UsersRelationManager::class,
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListPackages::route('/'),
'create' => Pages\CreatePackage::route('/create'),
'edit' => Pages\EditPackage::route('/{record}/edit'),
'index' => ListPackages::route('/'),
'create' => CreatePackage::route('/create'),
'edit' => EditPackage::route('/{record}/edit'),
];
}
}

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Filament\Resources\PackageResource\Pages;
namespace App\Filament\Resources\Packages\Pages;
use Filament\Resources\Pages\CreateRecord;
use App\Filament\Resources\PackageResource;
use App\Filament\Resources\Packages\PackageResource;
class CreatePackage extends CreateRecord
{

View File

@@ -1,10 +1,11 @@
<?php
namespace App\Filament\Resources\PackageResource\Pages;
namespace App\Filament\Resources\Packages\Pages;
use Filament\Actions\DeleteAction;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use App\Filament\Resources\PackageResource;
use App\Filament\Resources\Packages\PackageResource;
class EditPackage extends EditRecord
{
@@ -13,7 +14,7 @@ class EditPackage extends EditRecord
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
DeleteAction::make(),
];
}

View File

@@ -1,10 +1,11 @@
<?php
namespace App\Filament\Resources\PackageResource\Pages;
namespace App\Filament\Resources\Packages\Pages;
use Filament\Actions\CreateAction;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use App\Filament\Resources\PackageResource;
use App\Filament\Resources\Packages\PackageResource;
class ListPackages extends ListRecords
{
@@ -13,7 +14,7 @@ class ListPackages extends ListRecords
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
CreateAction::make(),
];
}
}

View File

@@ -1,13 +1,13 @@
<?php
namespace App\Filament\Resources\PackageResource\RelationManagers;
namespace App\Filament\Resources\Packages\RelationManagers;
use Filament\Schemas\Schema;
use Filament\Actions\Action;
use App\Models\User;
use Filament\Forms\Form;
use Filament\Tables\Table;
use Filament\Tables\Actions\Action;
use Filament\Forms\Components\Select;
use App\Filament\Resources\UserResource;
use App\Filament\Resources\Users\UserResource;
use Filament\Resources\RelationManagers\RelationManager;
class UsersRelationManager extends RelationManager
@@ -16,9 +16,9 @@ class UsersRelationManager extends RelationManager
protected static ?string $recordTitleAttribute = 'name';
public function form(Form $form): Form
public function form(Schema $schema): Schema
{
return UserResource::form($form);
return UserResource::form($schema);
}
public function table(Table $table): Table
@@ -28,7 +28,7 @@ class UsersRelationManager extends RelationManager
...$table->getHeaderActions(),
Action::make('add_user')
->label(__('Add user'))
->form(fn (self $livewire) => [
->schema(fn (self $livewire) => [
Select::make('user_id')
->label('User')
->options(User::orderBy('name')->get()->mapWithKeys(fn (User $user) => [$user->id => $user->name]))

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Filament\Resources\ProviderPlanResource\Pages;
namespace App\Filament\Resources\ProviderPlans\Pages;
use Filament\Resources\Pages\ListRecords;
use App\Filament\Resources\ProviderPlanResource;
use App\Filament\Resources\ProviderPlans\ProviderPlanResource;
class ListProviderPlans extends ListRecords
{

View File

@@ -1,11 +1,16 @@
<?php
namespace App\Filament\Resources;
namespace App\Filament\Resources\ProviderPlans;
use Filament\Schemas\Schema;
use Filament\Forms\Components\TextInput;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
use Filament\Actions\EditAction;
use App\Filament\Resources\ProviderPlans\Pages\ListProviderPlans;
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\Resource;
@@ -15,17 +20,17 @@ class ProviderPlanResource extends Resource
{
protected static ?string $model = ProviderPlan::class;
protected static ?string $navigationIcon = 'heroicon-o-cube';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-cube';
protected static ?string $navigationGroup = 'Providers';
protected static string | \UnitEnum | null $navigationGroup = 'Providers';
protected static ?int $navigationSort = 2;
public static function form(Form $form): Form
public static function form(Schema $schema): Schema
{
return $form
->schema([
Forms\Components\TextInput::make('label'),
return $schema
->components([
TextInput::make('label'),
]);
}
@@ -33,32 +38,32 @@ class ProviderPlanResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('id')
TextColumn::make('id')
->label('ID')
->searchable(),
Tables\Columns\TextColumn::make('provider.name')
TextColumn::make('provider.name')
->label(__('Provider'))
->searchable(),
Tables\Columns\TextColumn::make('plan_id')
TextColumn::make('plan_id')
->label(__('Plan ID'))
->searchable(),
Tables\Columns\TextColumn::make('label')
TextColumn::make('label')
->label(__('Label'))
->searchable(),
Tables\Columns\TextColumn::make('created_at')
TextColumn::make('created_at')
->label(__('Date'))
->sortable()
->dateTime(),
])
->filters([
Tables\Filters\SelectFilter::make('provider_id')
SelectFilter::make('provider_id')
->label(__('Provider'))
->options(fn () => Provider::orderBy('name')->get()->mapWithKeys(fn (Provider $provider) => [$provider->id => $provider->name])),
])
->actions([
Tables\Actions\EditAction::make(),
->recordActions([
EditAction::make(),
])
->bulkActions([
->toolbarActions([
//
])
->defaultSort('created_at', 'desc');
@@ -74,7 +79,7 @@ class ProviderPlanResource extends Resource
public static function getPages(): array
{
return [
'index' => Pages\ListProviderPlans::route('/'),
'index' => ListProviderPlans::route('/'),
];
}
}

View File

@@ -1,10 +1,11 @@
<?php
namespace App\Filament\Resources\ProviderRegionResource\Pages;
namespace App\Filament\Resources\ProviderRegions\Pages;
use Filament\Actions\CreateAction;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use App\Filament\Resources\ProviderRegionResource;
use App\Filament\Resources\ProviderRegions\ProviderRegionResource;
class ListProviderRegions extends ListRecords
{
@@ -13,7 +14,7 @@ class ListProviderRegions extends ListRecords
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
CreateAction::make(),
];
}
}

View File

@@ -1,10 +1,13 @@
<?php
namespace App\Filament\Resources;
namespace App\Filament\Resources\ProviderRegions;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
use App\Filament\Resources\ProviderRegions\Pages\ListProviderRegions;
use Filament\Tables;
use App\Models\Provider;
use Filament\Forms\Form;
use Filament\Tables\Table;
use App\Models\ProviderRegion;
use Filament\Resources\Resource;
@@ -14,16 +17,16 @@ class ProviderRegionResource extends Resource
{
protected static ?string $model = ProviderRegion::class;
protected static ?string $navigationIcon = 'heroicon-o-globe-americas';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-globe-americas';
protected static ?string $navigationGroup = 'Providers';
protected static string | \UnitEnum | null $navigationGroup = 'Providers';
protected static ?int $navigationSort = 3;
public static function form(Form $form): Form
public static function form(Schema $schema): Schema
{
return $form
->schema([
return $schema
->components([
//
]);
}
@@ -32,28 +35,28 @@ class ProviderRegionResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('id')
TextColumn::make('id')
->label('ID')
->searchable(),
Tables\Columns\TextColumn::make('provider.name')
TextColumn::make('provider.name')
->label(__('Provider'))
->searchable(),
Tables\Columns\TextColumn::make('region_id')
TextColumn::make('region_id')
->searchable()
->label(__('Region')),
Tables\Columns\TextColumn::make('label')
TextColumn::make('label')
->searchable()
->label(__('Label')),
])
->filters([
Tables\Filters\SelectFilter::make('provider_id')
SelectFilter::make('provider_id')
->label(__('Provider'))
->options(fn () => Provider::orderBy('name')->pluck('name', 'id'))
])
->actions([
->recordActions([
//
])
->bulkActions([
->toolbarActions([
//
]);
}
@@ -68,7 +71,7 @@ class ProviderRegionResource extends Resource
public static function getPages(): array
{
return [
'index' => Pages\ListProviderRegions::route('/'),
'index' => ListProviderRegions::route('/'),
];
}
}

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Filament\Resources\ProviderResource\Pages;
namespace App\Filament\Resources\Providers\Pages;
use Filament\Resources\Pages\EditRecord;
use App\Filament\Resources\ProviderResource;
use App\Filament\Resources\Providers\ProviderResource;
class EditProvider extends EditRecord
{

View File

@@ -1,23 +1,20 @@
<?php
namespace App\Filament\Resources\ProviderResource\Pages;
namespace App\Filament\Resources\Providers\Pages;
use Filament\Actions\Action;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use App\Filament\Resources\ProviderResource;
use App\Filament\Resources\Providers\ProviderResource;
class ListProviders extends ListRecords
{
protected $listeners = [
'$refresh',
];
protected static string $resource = ProviderResource::class;
protected function getHeaderActions(): array
{
return [
Actions\Action::make('synchronize_providers')
Action::make('synchronize_providers')
->label(__('Synchronize providers'))
->icon('heroicon-o-arrow-path')
->color('gray')

View File

@@ -1,22 +1,23 @@
<?php
namespace App\Filament\Resources\ProviderResource\Pages;
namespace App\Filament\Resources\Providers\Pages;
use App\Filament\Resources\Providers\Widgets\AvailableProvidersOverview;
use Filament\Resources\Pages\Page;
use App\Filament\Resources\ProviderResource;
use App\Filament\Resources\Providers\ProviderResource;
class SynchronizeProviders extends Page
{
protected static string $resource = ProviderResource::class;
protected static string $view = 'filament.resources.provider-resource.pages.synchronize-providers';
protected string $view = 'filament.resources.provider-resource.pages.synchronize-providers';
protected static ?string $title = 'Synchronize providers';
protected function getHeaderWidgets(): array
{
return [
ProviderResource\Widgets\AvailableProvidersOverview::class,
AvailableProvidersOverview::class,
];
}

View File

@@ -1,11 +1,19 @@
<?php
namespace App\Filament\Resources;
namespace App\Filament\Resources\Providers;
use Filament\Schemas\Schema;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\CheckboxList;
use Filament\Tables\Columns\TextColumn;
use Filament\Actions\EditAction;
use Filament\Actions\Action;
use App\Filament\Resources\Providers\Pages\ListProviders;
use App\Filament\Resources\Providers\Pages\SynchronizeProviders;
use App\Filament\Resources\Providers\Pages\EditProvider;
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\Resource;
@@ -13,32 +21,32 @@ use Filament\Notifications\Notification;
use Illuminate\Database\Eloquent\Builder;
use App\Filament\Resources\ProviderResource\Pages;
use App\Actions\Provider\SynchronizeProviderAction;
use App\Filament\Resources\ProviderResource\Widgets\AvailableProvidersOverview;
use App\Filament\Resources\Providers\Widgets\AvailableProvidersOverview;
class ProviderResource extends Resource
{
protected static ?string $model = Provider::class;
protected static ?string $navigationIcon = 'heroicon-o-cloud-arrow-up';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-cloud-arrow-up';
protected static ?string $navigationGroup = 'Providers';
protected static string | \UnitEnum | null $navigationGroup = 'Providers';
protected static ?int $navigationSort = 1;
public static function form(Form $form): Form
public static function form(Schema $schema): Schema
{
return $form
->schema([
Forms\Components\TextInput::make('name')
return $schema
->components([
TextInput::make('name')
->label(__('Name'))
->required()
->columnSpan(2),
Forms\Components\CheckboxList::make('allowed_plans')
CheckboxList::make('allowed_plans')
->options(function (Provider $record) {
return $record->plans->mapWithKeys(fn (ProviderPlan $plan) => [$plan->id => $plan->label ?? $plan->plan_id]);
})
->label(__('Allowed Plans')),
Forms\Components\CheckboxList::make('allowed_regions')
CheckboxList::make('allowed_regions')
->options(fn (Provider $record) => $record->regions->pluck('label', 'id'))
->label(__('Allowed Regions')),
]);
@@ -48,19 +56,19 @@ class ProviderResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('id')
TextColumn::make('id')
->label('ID')
->searchable(),
Tables\Columns\TextColumn::make('name')
TextColumn::make('name')
->description(function (Provider $record) {
return "{$record->plans_count} plan(s) · {$record->regions_count} region(s)";
})
->label(__('Name'))
->searchable(),
Tables\Columns\TextColumn::make('label')
TextColumn::make('label')
->label(__('Label'))
->searchable(),
Tables\Columns\TextColumn::make('created_at')
TextColumn::make('created_at')
->label(__('Date'))
->sortable()
->dateTime(),
@@ -68,9 +76,9 @@ class ProviderResource extends Resource
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\Action::make('synchronize_provider')
->recordActions([
EditAction::make(),
Action::make('synchronize_provider')
->label(__('Synchronize'))
->tooltip(__('This will synchronize the latest data from this provider to your Ploi Core installation'))
->icon('heroicon-o-arrow-path')
@@ -83,7 +91,7 @@ class ProviderResource extends Resource
->send();
}),
])
->bulkActions([
->toolbarActions([
//
])
->defaultSort('created_at', 'desc');
@@ -112,9 +120,9 @@ class ProviderResource extends Resource
public static function getPages(): array
{
return [
'index' => Pages\ListProviders::route('/'),
'synchronize' => Pages\SynchronizeProviders::route('/synchronize'),
'edit' => Pages\EditProvider::route('/{record}'),
'index' => ListProviders::route('/'),
'synchronize' => SynchronizeProviders::route('/synchronize'),
'edit' => EditProvider::route('/{record}'),
];
}
}

View File

@@ -1,10 +1,10 @@
<?php
namespace App\Filament\Resources\ProviderResource\Widgets;
namespace App\Filament\Resources\Providers\Widgets;
use Filament\Actions\Action;
use App\Models\AvailableProvider;
use Filament\Widgets\TableWidget;
use Filament\Tables\Actions\Action;
use Filament\Tables\Columns\TextColumn;
use Filament\Notifications\Notification;
use Illuminate\Database\Eloquent\Builder;
@@ -13,10 +13,6 @@ use Illuminate\Database\Eloquent\Relations\Relation;
class AvailableProvidersOverview extends TableWidget
{
protected $listeners = [
'$refresh',
];
protected int|string|array $columnSpan = 'full';
protected static ?string $heading = 'Available Providers';

View File

@@ -1,10 +1,11 @@
<?php
namespace App\Filament\Resources\RedirectResource\Pages;
namespace App\Filament\Resources\Redirects\Pages;
use Filament\Actions\CreateAction;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use App\Filament\Resources\RedirectResource;
use App\Filament\Resources\Redirects\RedirectResource;
class ListRedirects extends ListRecords
{
@@ -13,7 +14,7 @@ class ListRedirects extends ListRecords
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
CreateAction::make(),
];
}
}

View File

@@ -1,11 +1,14 @@
<?php
namespace App\Filament\Resources;
namespace App\Filament\Resources\Redirects;
use Filament\Schemas\Schema;
use Filament\Forms\Components\TextInput;
use Filament\Tables\Columns\TextColumn;
use App\Filament\Resources\Redirects\Pages\ListRedirects;
use Filament\Forms;
use Filament\Tables;
use App\Models\Redirect;
use Filament\Forms\Form;
use Filament\Tables\Table;
use Filament\Resources\Resource;
use App\Filament\Resources\RedirectResource\Pages;
@@ -14,23 +17,23 @@ class RedirectResource extends Resource
{
protected static ?string $model = Redirect::class;
protected static ?string $navigationIcon = 'heroicon-o-arrow-top-right-on-square';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-arrow-top-right-on-square';
protected static ?string $navigationGroup = 'Site management';
protected static string | \UnitEnum | null $navigationGroup = 'Site management';
protected static ?int $navigationSort = 5;
public static function form(Form $form): Form
public static function form(Schema $schema): Schema
{
return $form
->schema([
Forms\Components\TextInput::make('site_id'),
Forms\Components\TextInput::make('server_id'),
Forms\Components\TextInput::make('status'),
Forms\Components\TextInput::make('ploi_id'),
Forms\Components\TextInput::make('redirect_from'),
Forms\Components\TextInput::make('redirect_to'),
Forms\Components\TextInput::make('type'),
return $schema
->components([
TextInput::make('site_id'),
TextInput::make('server_id'),
TextInput::make('status'),
TextInput::make('ploi_id'),
TextInput::make('redirect_from'),
TextInput::make('redirect_to'),
TextInput::make('type'),
]);
}
@@ -38,23 +41,23 @@ class RedirectResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('redirect_from')
TextColumn::make('redirect_from')
->wrap()
->label(__('Redirect from'))
->searchable(),
Tables\Columns\TextColumn::make('redirect_to')
TextColumn::make('redirect_to')
->wrap()
->label(__('Redirect to'))
->searchable(),
Tables\Columns\TextColumn::make('server.name')
TextColumn::make('server.name')
->label(__('Server'))
->searchable(),
Tables\Columns\TextColumn::make('site.domain')
TextColumn::make('site.domain')
->label(__('Site'))
->searchable(),
Tables\Columns\TextColumn::make('type')
TextColumn::make('type')
->label(__('Type')),
Tables\Columns\TextColumn::make('status')
TextColumn::make('status')
->badge()
->formatStateUsing(fn (string $state) => match ($state) {
Redirect::STATUS_BUSY => __('Busy'),
@@ -66,7 +69,7 @@ class RedirectResource extends Resource
'success' => Redirect::STATUS_ACTIVE,
])
->label(__('Status')),
Tables\Columns\TextColumn::make('created_at')
TextColumn::make('created_at')
->label(__('Date'))
->sortable()
->dateTime(),
@@ -74,10 +77,10 @@ class RedirectResource extends Resource
->filters([
//
])
->actions([
->recordActions([
//
])
->bulkActions([
->toolbarActions([
//
])
->defaultSort('created_at', 'desc');
@@ -93,7 +96,7 @@ class RedirectResource extends Resource
public static function getPages(): array
{
return [
'index' => Pages\ListRedirects::route('/'),
'index' => ListRedirects::route('/'),
];
}
}

View File

@@ -1,8 +1,8 @@
<?php
namespace App\Filament\Resources\ServerResource\Pages;
namespace App\Filament\Resources\Servers\Pages;
use App\Filament\Resources\ServerResource;
use App\Filament\Resources\Servers\ServerResource;
use Filament\Resources\Pages\CreateRecord;
class CreateServer extends CreateRecord

View File

@@ -1,10 +1,11 @@
<?php
namespace App\Filament\Resources\ServerResource\Pages;
namespace App\Filament\Resources\Servers\Pages;
use Filament\Actions\DeleteAction;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use App\Filament\Resources\ServerResource;
use App\Filament\Resources\Servers\ServerResource;
class EditServer extends EditRecord
{
@@ -13,7 +14,7 @@ class EditServer extends EditRecord
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
DeleteAction::make(),
];
}
}

View File

@@ -1,10 +1,11 @@
<?php
namespace App\Filament\Resources\ServerResource\Pages;
namespace App\Filament\Resources\Servers\Pages;
use Filament\Actions\Action;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use App\Filament\Resources\ServerResource;
use App\Filament\Resources\Servers\ServerResource;
class ListServers extends ListRecords
{
@@ -13,7 +14,7 @@ class ListServers extends ListRecords
protected function getHeaderActions(): array
{
return [
Actions\Action::make('synchronize_servers')
Action::make('synchronize_servers')
->label(__('Synchronize servers'))
->icon('heroicon-o-arrow-path')
->color('gray')

View File

@@ -1,33 +1,35 @@
<?php
namespace App\Filament\Resources\ServerResource\Pages;
namespace App\Filament\Resources\Servers\Pages;
use App\Filament\Resources\Servers\Widgets\AvailableServersOverview;
use Filament\Actions\Action;
use Filament\Actions;
use App\Models\Server;
use App\Services\Ploi\Ploi;
use Filament\Resources\Pages\Page;
use Filament\Notifications\Notification;
use App\Filament\Resources\ServerResource;
use App\Filament\Resources\Servers\ServerResource;
class SynchronizeServers extends Page
{
protected static string $resource = ServerResource::class;
protected static string $view = 'filament.resources.server-resource.pages.synchronize-servers';
protected string $view = 'filament.resources.server-resource.pages.synchronize-servers';
protected static ?string $title = 'Synchronize servers';
protected function getHeaderWidgets(): array
{
return [
ServerResource\Widgets\AvailableServersOverview::class,
AvailableServersOverview::class,
];
}
protected function getHeaderActions(): array
{
return [
Actions\Action::make('synchronize_servers')
Action::make('synchronize_servers')
->label(__('Synchronize all servers'))
->icon('heroicon-o-arrow-path')
->requiresConfirmation()

View File

@@ -1,10 +1,10 @@
<?php
namespace App\Filament\Resources\ServerResource\RelationManagers;
namespace App\Filament\Resources\Servers\RelationManagers;
use Filament\Forms\Form;
use Filament\Schemas\Schema;
use Filament\Tables\Table;
use App\Filament\Resources\SiteResource;
use App\Filament\Resources\Sites\SiteResource;
use Filament\Resources\RelationManagers\RelationManager;
class SitesRelationManager extends RelationManager
@@ -23,9 +23,9 @@ class SitesRelationManager extends RelationManager
return __('Sites');
}
public function form(Form $form): Form
public function form(Schema $schema): Schema
{
return SiteResource::form($form);
return SiteResource::form($schema);
}
public function table(Table $table): Table

View File

@@ -1,11 +1,13 @@
<?php
namespace App\Filament\Resources\ServerResource\RelationManagers;
namespace App\Filament\Resources\Servers\RelationManagers;
use Filament\Schemas\Schema;
use Filament\Actions\AttachAction;
use Filament\Actions\DetachAction;
use Filament\Tables;
use Filament\Forms\Form;
use Filament\Tables\Table;
use App\Filament\Resources\UserResource;
use App\Filament\Resources\Users\UserResource;
use Filament\Resources\RelationManagers\RelationManager;
class UsersRelationManager extends RelationManager
@@ -24,9 +26,9 @@ class UsersRelationManager extends RelationManager
return __('Users');
}
public function form(Form $form): Form
public function form(Schema $schema): Schema
{
return UserResource::form($form);
return UserResource::form($schema);
}
public function table(Table $table): Table
@@ -34,12 +36,12 @@ class UsersRelationManager extends RelationManager
return UserResource::table($table)
->headerActions([
...$table->getHeaderActions(),
Tables\Actions\AttachAction::make()
AttachAction::make()
->preloadRecordSelect(),
])
->actions([
->recordActions([
...$table->getActions(),
Tables\Actions\DetachAction::make(),
DetachAction::make(),
]);
}
}

View File

@@ -1,12 +1,23 @@
<?php
namespace App\Filament\Resources;
namespace App\Filament\Resources\Servers;
use Filament\Schemas\Schema;
use Filament\Forms\Components\TextInput;
use Filament\Tables\Columns\TextColumn;
use Filament\Actions\EditAction;
use Filament\Actions\Action;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use App\Filament\Resources\Servers\RelationManagers\UsersRelationManager;
use App\Filament\Resources\Servers\RelationManagers\SitesRelationManager;
use App\Filament\Resources\Servers\Pages\ListServers;
use App\Filament\Resources\Servers\Pages\EditServer;
use App\Filament\Resources\Servers\Pages\SynchronizeServers;
use Filament\Forms;
use App\Models\User;
use Filament\Tables;
use App\Models\Server;
use Filament\Forms\Form;
use Filament\Tables\Table;
use Filament\Resources\Resource;
use Illuminate\Support\HtmlString;
@@ -19,9 +30,9 @@ class ServerResource extends Resource
{
protected static ?string $model = Server::class;
protected static ?string $navigationIcon = 'heroicon-o-server';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-server';
protected static ?string $navigationGroup = 'Server management';
protected static string | \UnitEnum | null $navigationGroup = 'Server management';
protected static ?string $recordTitleAttribute = 'name';
@@ -30,23 +41,23 @@ class ServerResource extends Resource
return ['name', 'ip', 'internal_ip', 'id'];
}
public static function form(Form $form): Form
public static function form(Schema $schema): Schema
{
return $form
->schema([
Forms\Components\TextInput::make('name')
return $schema
->components([
TextInput::make('name')
->required()
->label(__('Name'))
->columnSpan(2),
Forms\Components\TextInput::make('ip')
TextInput::make('ip')
->required()
->label('IP address')
->columnSpan(2),
Forms\Components\TextInput::make('internal_ip')
TextInput::make('internal_ip')
->required()
->label('Internal IP address')
->columnSpan(2),
Forms\Components\TextInput::make('maximum_sites')
TextInput::make('maximum_sites')
->label(__('Maximum sites'))
->integer()
->required()
@@ -58,10 +69,10 @@ class ServerResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('name')
TextColumn::make('name')
->label(__('Name'))
->searchable(),
Tables\Columns\TextColumn::make('status')
TextColumn::make('status')
->label(__('Status'))
->badge()
->formatStateUsing(fn (string $state) => match ($state) {
@@ -73,7 +84,7 @@ class ServerResource extends Resource
'warning' => Server::STATUS_BUSY,
'success' => Server::STATUS_ACTIVE,
]),
Tables\Columns\TextColumn::make('users')
TextColumn::make('users')
->label(__('Users'))
->wrap()
->formatStateUsing(function (Server $record) {
@@ -93,31 +104,31 @@ class ServerResource extends Resource
->orWhere('email', 'LIKE', "%{$search}%");
});
}),
Tables\Columns\TextColumn::make('maximum_sites')
TextColumn::make('maximum_sites')
->label(__('Max sites'))
->formatStateUsing(fn (Server $record) => $record->maximum_sites . " (Current: {$record->sites_count})")
->counts('sites'),
Tables\Columns\TextColumn::make('ip')
TextColumn::make('ip')
->label(__('IP')),
Tables\Columns\TextColumn::make('created_at')
TextColumn::make('created_at')
->label(__('Date'))
->dateTime(),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\Action::make('synchronize_server')
->recordActions([
EditAction::make(),
Action::make('synchronize_server')
->label(__('Synchronize'))
->tooltip(__('This will synchronize the latest data from this provider to your Ploi Core installation'))
->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(),
DeleteAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
->toolbarActions([
DeleteBulkAction::make(),
]);
}
@@ -131,17 +142,17 @@ class ServerResource extends Resource
public static function getRelations(): array
{
return [
RelationManagers\UsersRelationManager::class,
RelationManagers\SitesRelationManager::class,
UsersRelationManager::class,
SitesRelationManager::class,
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListServers::route('/'),
'edit' => Pages\EditServer::route('/{record}/edit'),
'synchronize' => Pages\SynchronizeServers::route('/synchronize'),
'index' => ListServers::route('/'),
'edit' => EditServer::route('/{record}/edit'),
'synchronize' => SynchronizeServers::route('/synchronize'),
];
}
}

View File

@@ -1,10 +1,10 @@
<?php
namespace App\Filament\Resources\ServerResource\Widgets;
namespace App\Filament\Resources\Servers\Widgets;
use Filament\Actions\Action;
use App\Models\AvailableServer;
use Filament\Widgets\TableWidget;
use Filament\Tables\Actions\Action;
use Filament\Tables\Columns\TextColumn;
use Illuminate\Database\Eloquent\Builder;
use App\Actions\Server\SynchronizeServerAction;
@@ -12,10 +12,6 @@ use Illuminate\Database\Eloquent\Relations\Relation;
class AvailableServersOverview extends TableWidget
{
protected $listeners = [
'$refresh',
];
protected int|string|array $columnSpan = 'full';
protected static ?string $heading = 'Available servers';

View File

@@ -1,10 +1,11 @@
<?php
namespace App\Filament\Resources\SiteSystemUserResource\Pages;
namespace App\Filament\Resources\SiteSystemUsers\Pages;
use Filament\Actions\CreateAction;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use App\Filament\Resources\SiteSystemUserResource;
use App\Filament\Resources\SiteSystemUsers\SiteSystemUserResource;
class ListSiteSystemUsers extends ListRecords
{
@@ -13,7 +14,7 @@ class ListSiteSystemUsers extends ListRecords
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
CreateAction::make(),
];
}
}

View File

@@ -1,9 +1,11 @@
<?php
namespace App\Filament\Resources;
namespace App\Filament\Resources\SiteSystemUsers;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn;
use App\Filament\Resources\SiteSystemUsers\Pages\ListSiteSystemUsers;
use Filament\Tables;
use Filament\Forms\Form;
use Filament\Tables\Table;
use App\Models\SiteSystemUser;
use Filament\Resources\Resource;
@@ -13,16 +15,16 @@ class SiteSystemUserResource extends Resource
{
protected static ?string $model = SiteSystemUser::class;
protected static ?string $navigationIcon = 'heroicon-o-user-group';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-user-group';
protected static ?string $navigationGroup = 'Site management';
protected static string | \UnitEnum | null $navigationGroup = 'Site management';
protected static ?int $navigationSort = 6;
public static function form(Form $form): Form
public static function form(Schema $schema): Schema
{
return $form
->schema([
return $schema
->components([
//
]);
}
@@ -31,13 +33,13 @@ class SiteSystemUserResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('user_name')
TextColumn::make('user_name')
->label(__('Username'))
->searchable(),
Tables\Columns\TextColumn::make('site.domain')
TextColumn::make('site.domain')
->label(__('Site'))
->searchable(),
Tables\Columns\TextColumn::make('created_at')
TextColumn::make('created_at')
->label(__('Date'))
->dateTime()
->sortable(),
@@ -45,10 +47,10 @@ class SiteSystemUserResource extends Resource
->filters([
//
])
->actions([
->recordActions([
//
])
->bulkActions([
->toolbarActions([
//
])
->defaultSort('created_at', 'desc');
@@ -64,7 +66,7 @@ class SiteSystemUserResource extends Resource
public static function getPages(): array
{
return [
'index' => Pages\ListSiteSystemUsers::route('/'),
'index' => ListSiteSystemUsers::route('/'),
];
}
}

View File

@@ -1,8 +1,8 @@
<?php
namespace App\Filament\Resources\SiteResource\Pages;
namespace App\Filament\Resources\Sites\Pages;
use App\Filament\Resources\SiteResource;
use App\Filament\Resources\Sites\SiteResource;
use Filament\Resources\Pages\CreateRecord;
class CreateSite extends CreateRecord

View File

@@ -1,9 +1,10 @@
<?php
namespace App\Filament\Resources\SiteResource\Pages;
namespace App\Filament\Resources\Sites\Pages;
use Filament\Actions\DeleteAction;
use Filament\Actions;
use App\Filament\Resources\SiteResource;
use App\Filament\Resources\Sites\SiteResource;
use Filament\Resources\Pages\EditRecord;
class EditSite extends EditRecord
@@ -13,7 +14,7 @@ class EditSite extends EditRecord
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
DeleteAction::make(),
];
}
}

View File

@@ -1,10 +1,11 @@
<?php
namespace App\Filament\Resources\SiteResource\Pages;
namespace App\Filament\Resources\Sites\Pages;
use Filament\Actions\Action;
use Filament\Actions;
use App\Traits\HasPloi;
use App\Filament\Resources\SiteResource;
use App\Filament\Resources\Sites\SiteResource;
use Filament\Resources\Pages\ListRecords;
class ListSites extends ListRecords
@@ -16,7 +17,7 @@ class ListSites extends ListRecords
protected function getHeaderActions(): array
{
return [
Actions\Action::make('synchronize_sites')
Action::make('synchronize_sites')
->label(__('Synchronize sites'))
->icon('heroicon-o-arrow-path')
->color('gray')

View File

@@ -1,32 +1,34 @@
<?php
namespace App\Filament\Resources\SiteResource\Pages;
namespace App\Filament\Resources\Sites\Pages;
use App\Filament\Resources\Sites\Widgets\AvailableSitesOverview;
use Filament\Actions\Action;
use App\Models\Site;
use Filament\Actions;
use App\Models\Server;
use App\Services\Ploi\Ploi;
use Filament\Resources\Pages\Page;
use App\Filament\Resources\SiteResource;
use App\Filament\Resources\Sites\SiteResource;
use Filament\Notifications\Notification;
class SynchronizeSites extends Page
{
protected static string $resource = SiteResource::class;
protected static string $view = 'filament.resources.site-resource.pages.synchronize-sites';
protected string $view = 'filament.resources.site-resource.pages.synchronize-sites';
public function getHeaderWidgets(): array
{
return [
SiteResource\Widgets\AvailableSitesOverview::class,
AvailableSitesOverview::class,
];
}
protected function getHeaderActions(): array
{
return [
Actions\Action::make('synchronize_sites')
Action::make('synchronize_sites')
->label(__('Synchronize all sites'))
->icon('heroicon-o-arrow-path')
->requiresConfirmation()

View File

@@ -1,10 +1,10 @@
<?php
namespace App\Filament\Resources\SiteResource\RelationManagers;
namespace App\Filament\Resources\Sites\RelationManagers;
use Filament\Forms\Form;
use Filament\Schemas\Schema;
use Filament\Tables\Table;
use App\Filament\Resources\CertificateResource;
use App\Filament\Resources\Certificates\CertificateResource;
use Filament\Resources\RelationManagers\RelationManager;
class CertificatesRelationManager extends RelationManager
@@ -13,9 +13,9 @@ class CertificatesRelationManager extends RelationManager
protected static ?string $recordTitleAttribute = 'domain';
public function form(Form $form): Form
public function form(Schema $schema): Schema
{
return CertificateResource::form($form);
return CertificateResource::form($schema);
}
public function table(Table $table): Table

View File

@@ -1,10 +1,10 @@
<?php
namespace App\Filament\Resources\SiteResource\RelationManagers;
namespace App\Filament\Resources\Sites\RelationManagers;
use Filament\Forms\Form;
use Filament\Schemas\Schema;
use Filament\Tables\Table;
use App\Filament\Resources\CronjobResource;
use App\Filament\Resources\Cronjobs\CronjobResource;
use Filament\Resources\RelationManagers\RelationManager;
class CronjobsRelationManager extends RelationManager
@@ -13,9 +13,9 @@ class CronjobsRelationManager extends RelationManager
protected static ?string $recordTitleAttribute = 'command';
public function form(Form $form): Form
public function form(Schema $schema): Schema
{
return CronjobResource::form($form);
return CronjobResource::form($schema);
}
public function table(Table $table): Table

View File

@@ -1,10 +1,10 @@
<?php
namespace App\Filament\Resources\SiteResource\RelationManagers;
namespace App\Filament\Resources\Sites\RelationManagers;
use Filament\Forms\Form;
use Filament\Schemas\Schema;
use Filament\Tables\Table;
use App\Filament\Resources\DatabaseResource;
use App\Filament\Resources\Databases\DatabaseResource;
use Filament\Resources\RelationManagers\RelationManager;
class DatabasesRelationManager extends RelationManager
@@ -13,9 +13,9 @@ class DatabasesRelationManager extends RelationManager
protected static ?string $recordTitleAttribute = 'name';
public function form(Form $form): Form
public function form(Schema $schema): Schema
{
return DatabaseResource::form($form);
return DatabaseResource::form($schema);
}
public function table(Table $table): Table

View File

@@ -1,10 +1,10 @@
<?php
namespace App\Filament\Resources\SiteResource\RelationManagers;
namespace App\Filament\Resources\Sites\RelationManagers;
use Filament\Forms\Form;
use Filament\Schemas\Schema;
use Filament\Tables\Table;
use App\Filament\Resources\RedirectResource;
use App\Filament\Resources\Redirects\RedirectResource;
use Filament\Resources\RelationManagers\RelationManager;
class RedirectsRelationManager extends RelationManager
@@ -13,9 +13,9 @@ class RedirectsRelationManager extends RelationManager
protected static ?string $recordTitleAttribute = 'from';
public function form(Form $form): Form
public function form(Schema $schema): Schema
{
return RedirectResource::form($form);
return RedirectResource::form($schema);
}
public function table(Table $table): Table

View File

@@ -1,10 +1,10 @@
<?php
namespace App\Filament\Resources\SiteResource\RelationManagers;
namespace App\Filament\Resources\Sites\RelationManagers;
use Filament\Forms\Form;
use Filament\Schemas\Schema;
use Filament\Tables\Table;
use App\Filament\Resources\SiteSystemUserResource;
use App\Filament\Resources\SiteSystemUsers\SiteSystemUserResource;
use Filament\Resources\RelationManagers\RelationManager;
class SystemUsersRelationManager extends RelationManager
@@ -13,9 +13,9 @@ class SystemUsersRelationManager extends RelationManager
protected static ?string $recordTitleAttribute = 'user_name';
public function form(Form $form): Form
public function form(Schema $schema): Schema
{
return SiteSystemUserResource::form($form);
return SiteSystemUserResource::form($schema);
}
public function table(Table $table): Table

View File

@@ -1,11 +1,13 @@
<?php
namespace App\Filament\Resources\SiteResource\RelationManagers;
namespace App\Filament\Resources\Sites\RelationManagers;
use Filament\Schemas\Schema;
use Filament\Actions\AttachAction;
use Filament\Actions\DetachAction;
use Filament\Tables;
use Filament\Forms\Form;
use Filament\Tables\Table;
use App\Filament\Resources\UserResource;
use App\Filament\Resources\Users\UserResource;
use Filament\Resources\RelationManagers\RelationManager;
class UsersRelationManager extends RelationManager
@@ -24,9 +26,9 @@ class UsersRelationManager extends RelationManager
return __('Users');
}
public function form(Form $form): Form
public function form(Schema $schema): Schema
{
return UserResource::form($form);
return UserResource::form($schema);
}
public function table(Table $table): Table
@@ -34,12 +36,12 @@ class UsersRelationManager extends RelationManager
return UserResource::table($table)
->headerActions([
...$table->getHeaderActions(),
Tables\Actions\AttachAction::make()
AttachAction::make()
->preloadRecordSelect(),
])
->actions([
->recordActions([
...$table->getActions(),
Tables\Actions\DetachAction::make(),
DetachAction::make(),
]);
}
}

View File

@@ -1,12 +1,26 @@
<?php
namespace App\Filament\Resources;
namespace App\Filament\Resources\Sites;
use Filament\Schemas\Schema;
use Filament\Forms\Components\TextInput;
use Filament\Tables\Columns\TextColumn;
use Filament\Actions\EditAction;
use Filament\Actions\Action;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use App\Filament\Resources\Sites\RelationManagers\UsersRelationManager;
use App\Filament\Resources\Sites\RelationManagers\CertificatesRelationManager;
use App\Filament\Resources\Sites\RelationManagers\CronjobsRelationManager;
use App\Filament\Resources\Sites\RelationManagers\RedirectsRelationManager;
use App\Filament\Resources\Sites\RelationManagers\SystemUsersRelationManager;
use App\Filament\Resources\Sites\Pages\ListSites;
use App\Filament\Resources\Sites\Pages\EditSite;
use App\Filament\Resources\Sites\Pages\SynchronizeSites;
use Filament\Forms;
use App\Models\Site;
use App\Models\User;
use Filament\Tables;
use Filament\Forms\Form;
use Filament\Tables\Table;
use Filament\Resources\Resource;
use Illuminate\Support\HtmlString;
@@ -19,9 +33,9 @@ class SiteResource extends Resource
{
protected static ?string $model = Site::class;
protected static ?string $navigationIcon = 'heroicon-o-code-bracket';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-code-bracket';
protected static ?string $navigationGroup = 'Site management';
protected static string | \UnitEnum | null $navigationGroup = 'Site management';
protected static ?int $navigationSort = 0;
@@ -37,11 +51,11 @@ class SiteResource extends Resource
return __('Sites');
}
public static function form(Form $form): Form
public static function form(Schema $schema): Schema
{
return $form
->schema([
Forms\Components\TextInput::make('domain')
return $schema
->components([
TextInput::make('domain')
->label(__('Domain'))
->required()
->hostname()
@@ -54,18 +68,18 @@ class SiteResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('domain')
TextColumn::make('domain')
->description(function (Site $record) {
return "PHP $record->php_version";
})
->label(__('Name'))
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('server.name')
TextColumn::make('server.name')
->label(__('Server'))
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('status')
TextColumn::make('status')
->badge()
->formatStateUsing(fn (string $state) => match ($state) {
Site::STATUS_BUSY => __('Busy'),
@@ -77,7 +91,7 @@ class SiteResource extends Resource
'success' => Site::STATUS_ACTIVE,
])
->label(__('Status')),
Tables\Columns\TextColumn::make('users')
TextColumn::make('users')
->label(__('Users'))
->wrap()
->formatStateUsing(function (Site $record) {
@@ -97,7 +111,7 @@ class SiteResource extends Resource
->orWhere('email', 'LIKE', "%{$search}%");
});
}),
Tables\Columns\TextColumn::make('created_at')
TextColumn::make('created_at')
->label(__('Date'))
->dateTime()
->sortable(),
@@ -105,9 +119,9 @@ class SiteResource extends Resource
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\Action::make('synchronize_site')
->recordActions([
EditAction::make(),
Action::make('synchronize_site')
->label(__('Synchronize'))
->tooltip(__('This will synchronize the latest data from this provider to your Ploi Core installation'))
->icon('heroicon-o-arrow-path')
@@ -115,10 +129,10 @@ class SiteResource extends Resource
app(SynchronizeSiteAction::class)->execute($record->server->ploi_id, $record->ploi_id);
})
->visible(fn (Site $record) => $record->status === Site::STATUS_ACTIVE),
Tables\Actions\DeleteAction::make(),
DeleteAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
->toolbarActions([
DeleteBulkAction::make(),
])
->defaultSort('sites.created_at', 'desc');
}
@@ -132,20 +146,20 @@ class SiteResource extends Resource
public static function getRelations(): array
{
return [
RelationManagers\UsersRelationManager::class,
RelationManagers\CertificatesRelationManager::class,
RelationManagers\CronjobsRelationManager::class,
RelationManagers\RedirectsRelationManager::class,
RelationManagers\SystemUsersRelationManager::class,
UsersRelationManager::class,
CertificatesRelationManager::class,
CronjobsRelationManager::class,
RedirectsRelationManager::class,
SystemUsersRelationManager::class,
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListSites::route('/'),
'edit' => Pages\EditSite::route('/{record}/edit'),
'synchronize' => Pages\SynchronizeSites::route('/synchronize'),
'index' => ListSites::route('/'),
'edit' => EditSite::route('/{record}/edit'),
'synchronize' => SynchronizeSites::route('/synchronize'),
];
}
}

View File

@@ -1,10 +1,10 @@
<?php
namespace App\Filament\Resources\SiteResource\Widgets;
namespace App\Filament\Resources\Sites\Widgets;
use Filament\Actions\Action;
use App\Models\AvailableSite;
use Filament\Widgets\TableWidget;
use Filament\Tables\Actions\Action;
use Filament\Tables\Columns\TextColumn;
use Illuminate\Database\Eloquent\Builder;
use App\Actions\Site\SynchronizeSiteAction;
@@ -12,10 +12,6 @@ use Illuminate\Database\Eloquent\Relations\Relation;
class AvailableSitesOverview extends TableWidget
{
protected $listeners = [
'$refresh',
];
protected int|string|array $columnSpan = 'full';
protected static ?string $heading = 'Available sites';

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Filament\Resources\SubscriptionResource\Pages;
namespace App\Filament\Resources\Subscriptions\Pages;
use Filament\Resources\Pages\CreateRecord;
use App\Filament\Resources\SubscriptionResource;
use App\Filament\Resources\Subscriptions\SubscriptionResource;
class CreateSubscription extends CreateRecord
{

View File

@@ -1,10 +1,11 @@
<?php
namespace App\Filament\Resources\SubscriptionResource\Pages;
namespace App\Filament\Resources\Subscriptions\Pages;
use Filament\Actions\DeleteAction;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use App\Filament\Resources\SubscriptionResource;
use App\Filament\Resources\Subscriptions\SubscriptionResource;
class EditSubscription extends EditRecord
{
@@ -13,7 +14,7 @@ class EditSubscription extends EditRecord
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
DeleteAction::make(),
];
}
}

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Filament\Resources\SubscriptionResource\Pages;
namespace App\Filament\Resources\Subscriptions\Pages;
use Filament\Resources\Pages\ListRecords;
use App\Filament\Resources\SubscriptionResource;
use App\Filament\Resources\Subscriptions\SubscriptionResource;
class ListSubscriptions extends ListRecords
{

View File

@@ -1,9 +1,14 @@
<?php
namespace App\Filament\Resources;
namespace App\Filament\Resources\Subscriptions;
use Filament\Panel;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use App\Filament\Resources\Subscriptions\Pages\ListSubscriptions;
use Filament\Tables;
use Filament\Forms\Form;
use Filament\Tables\Table;
use Filament\Resources\Resource;
use Laravel\Cashier\Subscription;
@@ -13,19 +18,19 @@ class SubscriptionResource extends Resource
{
protected static ?string $model = Subscription::class;
protected static ?string $navigationIcon = 'heroicon-o-banknotes';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-banknotes';
protected static ?int $navigationSort = 4;
public static function getSlug(): string
public static function getSlug(?Panel $panel = null): string
{
return 'subscriptions';
}
public static function form(Form $form): Form
public static function form(Schema $schema): Schema
{
return $form
->schema([
return $schema
->components([
//
]);
}
@@ -34,19 +39,19 @@ class SubscriptionResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('user.name')
TextColumn::make('user.name')
->searchable()
->url(fn ($record) => UserResource::getUrl('edit', ['record' => $record])),
Tables\Columns\TextColumn::make('stripe_id')->searchable(),
Tables\Columns\TextColumn::make('stripe_plan')->searchable(),
Tables\Columns\TextColumn::make('stripe_status')
TextColumn::make('stripe_id')->searchable(),
TextColumn::make('stripe_plan')->searchable(),
TextColumn::make('stripe_status')
->label('Status')
->badge()
->colors([
'success' => \Stripe\Subscription::STATUS_ACTIVE,
'warning' => \Stripe\Subscription::STATUS_PAST_DUE,
]),
Tables\Columns\TextColumn::make('created_at')
TextColumn::make('created_at')
->sortable()
->dateTime()
->label(__('Date'))
@@ -54,12 +59,12 @@ class SubscriptionResource extends Resource
->filters([
//
])
->actions([
->recordActions([
// Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
DeleteAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
->toolbarActions([
DeleteBulkAction::make(),
])
->defaultSort('created_at', 'desc');
}
@@ -74,7 +79,7 @@ class SubscriptionResource extends Resource
public static function getPages(): array
{
return [
'index' => Pages\ListSubscriptions::route('/'),
'index' => ListSubscriptions::route('/'),
// 'create' => Pages\CreateSubscription::route('/create'),
// 'edit' => Pages\EditSubscription::route('/{record}/edit'),
];

View File

@@ -1,10 +1,11 @@
<?php
namespace App\Filament\Resources\SupportTicketResource\Pages;
namespace App\Filament\Resources\SupportTickets\Pages;
use Filament\Actions\CreateAction;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
use App\Filament\Resources\SupportTicketResource;
use App\Filament\Resources\SupportTickets\SupportTicketResource;
class ListSupportTickets extends ListRecords
{
@@ -13,7 +14,7 @@ class ListSupportTickets extends ListRecords
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
CreateAction::make(),
];
}
}

View File

@@ -1,26 +1,27 @@
<?php
namespace App\Filament\Resources\SupportTicketResource\Pages;
namespace App\Filament\Resources\SupportTickets\Pages;
use Filament\Actions\Action;
use Filament\Actions;
use App\Models\SupportTicket;
use Filament\Resources\Pages\Page;
use Filament\Schemas\Schema;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Mail;
use Filament\Notifications\Notification;
use App\Mail\Support\TicketRepliedToEmail;
use Filament\Forms\Components\MarkdownEditor;
use App\Filament\Resources\SupportTicketResource;
use App\Filament\Resources\SupportTickets\SupportTicketResource;
class ViewSupportTicket extends Page
class ViewSupportTicket extends Page implements HasForms
{
protected $listeners = [
'$refresh',
];
use InteractsWithForms;
protected static string $resource = SupportTicketResource::class;
protected static string $view = 'filament.resources.support-ticket-resource.pages.view-support-ticket';
protected string $view = 'filament.resources.support-ticket-resource.pages.view-support-ticket';
public SupportTicket $record;
@@ -34,7 +35,7 @@ class ViewSupportTicket extends Page
protected function getHeaderActions(): array
{
return [
Actions\Action::make('close')
Action::make('close')
->label(__('Close'))
->action(function (self $livewire) {
$livewire->record->status = SupportTicket::STATUS_CLOSED;
@@ -45,11 +46,11 @@ class ViewSupportTicket extends Page
->success()
->send();
$livewire->redirect(SupportTicketResource::getUrl('view', ['record' => $livewire->getRecord()]));
$livewire->redirect(SupportTicketResource::getUrl('view', ['record' => $livewire->record]));
})
->visible(fn (self $livewire) => $livewire->record->status !== SupportTicket::STATUS_CLOSED)
->color('danger'),
Actions\Action::make('reopen')
Action::make('reopen')
->label(__('Reopen'))
->action(function (self $livewire) {
$livewire->record->status = SupportTicket::STATUS_OPEN;
@@ -60,7 +61,7 @@ class ViewSupportTicket extends Page
->success()
->send();
$livewire->redirect(SupportTicketResource::getUrl('view', ['record' => $livewire->getRecord()]));
$livewire->redirect(SupportTicketResource::getUrl('view', ['record' => $livewire->record]));
})
->visible(fn (self $livewire) => $livewire->record->status === SupportTicket::STATUS_CLOSED)
->color('primary'),
@@ -72,18 +73,15 @@ class ViewSupportTicket extends Page
$this->form->fill();
}
protected function getFormSchema(): array
public function form(Schema $schema): Schema
{
return [
MarkdownEditor::make('content')
->label(__('Reply'))
->required(),
];
}
protected function getFormStatePath(): ?string
{
return 'data';
return $schema
->statePath('data')
->components([
MarkdownEditor::make('content')
->label(__('Reply'))
->required(),
]);
}
public function reply(): void

View File

@@ -1,9 +1,13 @@
<?php
namespace App\Filament\Resources;
namespace App\Filament\Resources\SupportTickets;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
use App\Filament\Resources\SupportTickets\Pages\ListSupportTickets;
use App\Filament\Resources\SupportTickets\Pages\ViewSupportTicket;
use Filament\Tables;
use Filament\Forms\Form;
use Filament\Tables\Table;
use App\Models\SupportTicket;
use Filament\Resources\Resource;
@@ -14,9 +18,9 @@ class SupportTicketResource extends Resource
{
protected static ?string $model = SupportTicket::class;
protected static ?string $navigationGroup = 'Support';
protected static string | \UnitEnum | null $navigationGroup = 'Support';
protected static ?string $navigationIcon = 'heroicon-o-lifebuoy';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-lifebuoy';
protected static ?string $label = 'Ticket';
@@ -32,10 +36,10 @@ class SupportTicketResource extends Resource
return static::getEloquentQuery()->count();
}
public static function form(Form $form): Form
public static function form(Schema $schema): Schema
{
return $form
->schema([
return $schema
->components([
//
]);
}
@@ -44,7 +48,7 @@ class SupportTicketResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('status')
TextColumn::make('status')
->label(__('Status'))
->badge()
->formatStateUsing(fn (string $state) => match ($state) {
@@ -59,18 +63,18 @@ class SupportTicketResource extends Resource
'danger' => SupportTicket::STATUS_CLOSED,
])
->wrap(false),
Tables\Columns\TextColumn::make('title')
TextColumn::make('title')
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('replies_count')
TextColumn::make('replies_count')
->label(__('Replies'))
->getStateUsing(fn (SupportTicket $record) => $record->replies->count()),
Tables\Columns\TextColumn::make('user.name')
TextColumn::make('user.name')
->searchable()
->sortable(),
])
->filters([
Tables\Filters\SelectFilter::make('status')
SelectFilter::make('status')
->label(__('Status'))
->multiple()
->options([
@@ -96,8 +100,8 @@ class SupportTicketResource extends Resource
public static function getPages(): array
{
return [
'index' => Pages\ListSupportTickets::route('/'),
'view' => Pages\ViewSupportTicket::route('/{record}'),
'index' => ListSupportTickets::route('/'),
'view' => ViewSupportTicket::route('/{record}'),
];
}
}

View File

@@ -1,9 +1,9 @@
<?php
namespace App\Filament\Resources\UserResource\Pages;
namespace App\Filament\Resources\Users\Pages;
use Illuminate\Database\Eloquent\Model;
use App\Filament\Resources\UserResource;
use App\Filament\Resources\Users\UserResource;
use Filament\Resources\Pages\CreateRecord;
class CreateUser extends CreateRecord

View File

@@ -1,12 +1,13 @@
<?php
namespace App\Filament\Resources\UserResource\Pages;
namespace App\Filament\Resources\Users\Pages;
use Filament\Actions\Action;
use Filament\Actions;
use Filament\Forms\Components\Toggle;
use App\Actions\User\DeleteUserAction;
use Illuminate\Database\Eloquent\Model;
use App\Filament\Resources\UserResource;
use App\Filament\Resources\Users\UserResource;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\EditRecord;
@@ -25,7 +26,7 @@ class EditUser extends EditRecord
protected function getHeaderActions(): array
{
return [
Actions\Action::make('two_factor_authentication')
Action::make('two_factor_authentication')
->label(__('Disable two-factor authentication'))
->color('gray')
->action(function () {
@@ -38,8 +39,8 @@ class EditUser extends EditRecord
})
->visible(fn () => $this->record->hasTwoFactorEnabled())
->requiresConfirmation(),
Actions\Action::make('delete')
->form([
Action::make('delete')
->schema([
Toggle::make('remove_all_data')
->label(__('Delete all servers, sites, databases, etc.'))
->default(true)

View File

@@ -1,9 +1,10 @@
<?php
namespace App\Filament\Resources\UserResource\Pages;
namespace App\Filament\Resources\Users\Pages;
use Filament\Actions\CreateAction;
use Filament\Actions;
use App\Filament\Resources\UserResource;
use App\Filament\Resources\Users\UserResource;
use Filament\Resources\Pages\ListRecords;
class ListUsers extends ListRecords
@@ -13,7 +14,7 @@ class ListUsers extends ListRecords
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
CreateAction::make(),
];
}
}

View File

@@ -1,10 +1,10 @@
<?php
namespace App\Filament\Resources\UserResource\RelationManagers;
namespace App\Filament\Resources\Users\RelationManagers;
use Filament\Forms\Form;
use Filament\Schemas\Schema;
use Filament\Tables\Table;
use App\Filament\Resources\ServerResource;
use App\Filament\Resources\Servers\ServerResource;
use Filament\Resources\RelationManagers\RelationManager;
class ServersRelationManager extends RelationManager
@@ -13,9 +13,9 @@ class ServersRelationManager extends RelationManager
protected static ?string $recordTitleAttribute = 'name';
public function form(Form $form): Form
public function form(Schema $schema): Schema
{
return ServerResource::form($form);
return ServerResource::form($schema);
}
public function table(Table $table): Table

View File

@@ -1,10 +1,10 @@
<?php
namespace App\Filament\Resources\UserResource\RelationManagers;
namespace App\Filament\Resources\Users\RelationManagers;
use Filament\Forms\Form;
use Filament\Schemas\Schema;
use Filament\Tables\Table;
use App\Filament\Resources\SiteResource;
use App\Filament\Resources\Sites\SiteResource;
use Filament\Resources\RelationManagers\RelationManager;
class SitesRelationManager extends RelationManager
@@ -13,9 +13,9 @@ class SitesRelationManager extends RelationManager
protected static ?string $recordTitleAttribute = 'domain';
public function form(Form $form): Form
public function form(Schema $schema): Schema
{
return SiteResource::form($form);
return SiteResource::form($schema);
}
public function table(Table $table): Table

View File

@@ -1,14 +1,27 @@
<?php
namespace App\Filament\Resources;
namespace App\Filament\Resources\Users;
use Filament\Schemas\Schema;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\Checkbox;
use Filament\Tables\Columns\TextColumn;
use Filament\Actions\EditAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use App\Filament\Resources\Users\RelationManagers\SitesRelationManager;
use App\Filament\Resources\Users\RelationManagers\ServersRelationManager;
use App\Filament\Resources\Users\Pages\ListUsers;
use App\Filament\Resources\Users\Pages\CreateUser;
use App\Filament\Resources\Users\Pages\EditUser;
use Filament\Forms;
use App\Models\User;
use Filament\Tables;
use Filament\Forms\Form;
use Filament\Tables\Table;
use Filament\Resources\Resource;
use STS\FilamentImpersonate\Impersonate;
use STS\FilamentImpersonate\Actions\Impersonate;
use App\Filament\Resources\UserResource\Pages;
use App\Filament\Resources\UserResource\RelationManagers;
@@ -16,7 +29,7 @@ class UserResource extends Resource
{
protected static ?string $model = User::class;
protected static ?string $navigationIcon = 'heroicon-o-users';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-users';
protected static ?int $navigationSort = 2;
@@ -37,19 +50,19 @@ class UserResource extends Resource
return __('Users');
}
public static function form(Form $form): Form
public static function form(Schema $schema): Schema
{
return $form
->schema([
Forms\Components\TextInput::make('name')
return $schema
->components([
TextInput::make('name')
->label(__('Name'))
->required(),
Forms\Components\TextInput::make('email')
TextInput::make('email')
->label(__('E-mail address'))
->email()
->unique(table: User::class, column: 'email', ignoreRecord: true)
->required(),
Forms\Components\Select::make('role')
Select::make('role')
->options([
User::ADMIN => __('Administrator'),
User::USER => __('User'),
@@ -57,20 +70,20 @@ class UserResource extends Resource
->default(User::USER)
->columnSpan(2)
->required(),
Forms\Components\Select::make('package_id')
Select::make('package_id')
->label(__('Package'))
->relationship('package', 'name'),
Forms\Components\Select::make('language')
Select::make('language')
->label(__('Language'))
->default('en')
->options(collect(languages())->mapWithKeys(fn (string $language) => [$language => $language])),
Forms\Components\Textarea::make('notes')
Textarea::make('notes')
->label(__('Notes'))
->maxLength(65535),
Forms\Components\Textarea::make('blocked')
Textarea::make('blocked')
->helperText('Entering a reason here will block the user from accessing your panel. It will also display the typed message to the user.')
->label(__('Blocked')),
Forms\Components\Checkbox::make('requires_password_for_ftp')
Checkbox::make('requires_password_for_ftp')
->default(true)
->label(__('Require password to show FTP password'))
->helperText(__('Disabling this will allow this user to get the FTP password without entering their password.')),
@@ -81,40 +94,40 @@ class UserResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('name')
TextColumn::make('name')
->label(__('Name'))
->searchable(),
Tables\Columns\TextColumn::make('user_name')
TextColumn::make('user_name')
->label(__('User name'))
->searchable(),
Tables\Columns\TextColumn::make('email')
TextColumn::make('email')
->label(__('E-mail address'))
->searchable(),
Tables\Columns\TextColumn::make('servers_count')
TextColumn::make('servers_count')
->label(__('Servers'))
->counts('servers')
->sortable(),
Tables\Columns\TextColumn::make('sites_count')
TextColumn::make('sites_count')
->label(__('Sites'))
->counts('sites')
->sortable(),
Tables\Columns\TextColumn::make('role')
TextColumn::make('role')
->label(__('Role')),
Tables\Columns\TextColumn::make('package.name')
TextColumn::make('package.name')
->label(__('Package')),
])
->filters([
//
])
->actions([
->recordActions([
Impersonate::make('impersonate')
->tooltip('Login as this user (impersonate)')
->visible(fn () => config('core.impersonation')),
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
EditAction::make(),
DeleteAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
->toolbarActions([
DeleteBulkAction::make(),
])
->defaultSort('users.created_at', 'desc');
}
@@ -122,17 +135,17 @@ class UserResource extends Resource
public static function getRelations(): array
{
return [
RelationManagers\SitesRelationManager::class,
RelationManagers\ServersRelationManager::class,
SitesRelationManager::class,
ServersRelationManager::class,
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListUsers::route('/'),
'create' => Pages\CreateUser::route('/create'),
'edit' => Pages\EditUser::route('/{record}/edit'),
'index' => ListUsers::route('/'),
'create' => CreateUser::route('/create'),
'edit' => EditUser::route('/{record}/edit'),
];
}
}

View File

@@ -5,9 +5,9 @@ namespace App\Filament\Widgets;
use App\Models\Site;
use App\Models\User;
use App\Models\Server;
use App\Filament\Resources\SiteResource;
use App\Filament\Resources\UserResource;
use App\Filament\Resources\ServerResource;
use App\Filament\Resources\Sites\SiteResource;
use App\Filament\Resources\Users\UserResource;
use App\Filament\Resources\Servers\ServerResource;
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
class StatsOverview extends BaseWidget

View File

@@ -2,6 +2,7 @@
namespace App\Filament\Widgets;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables;
use App\Models\SystemLog;
use Filament\Tables\Table;
@@ -18,7 +19,7 @@ class SystemLogs extends BaseWidget
->query(fn (): Builder => SystemLog::query()->with('model'))
->defaultSort(fn (Builder $query) => $query->latest())
->columns([
Tables\Columns\TextColumn::make('title')
TextColumn::make('title')
->label(__('Title'))
->formatStateUsing(fn (SystemLog $record) => __($record->title, [
'site' => $record->model->domain ?? '-Unknown-',
@@ -30,7 +31,7 @@ class SystemLogs extends BaseWidget
]))
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
TextColumn::make('created_at')
->label(__('Date'))
->dateTime()
->sortable()

View File

@@ -2,6 +2,37 @@
namespace App\Http;
use App\Http\Middleware\TrustProxies;
use Illuminate\Http\Middleware\HandleCors;
use App\Http\Middleware\PreventRequestsDuringMaintenance;
use Illuminate\Foundation\Http\Middleware\ValidatePostSize;
use App\Http\Middleware\TrimStrings;
use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull;
use Inertia\Middleware;
use App\Http\Middleware\Demo;
use App\Http\Middleware\EncryptCookies;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\View\Middleware\ShareErrorsFromSession;
use App\Http\Middleware\VerifyCsrfToken;
use Illuminate\Routing\Middleware\SubstituteBindings;
use App\Http\Middleware\SetLocale;
use App\Http\Middleware\InstallationComplete;
use App\Http\Middleware\HandleInertiaRequests;
use App\Http\Middleware\Authenticate;
use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
use App\Http\Middleware\UserBlocked;
use App\Http\Middleware\EnforceTwoFactorAuthenticationIfEnabled;
use Illuminate\Http\Middleware\SetCacheHeaders;
use Illuminate\Auth\Middleware\Authorize;
use App\Http\Middleware\HasAccessToThisGroup;
use App\Http\Middleware\RedirectIfAuthenticated;
use App\Http\Middleware\GlobalApiAuthenticated;
use Illuminate\Auth\Middleware\RequirePassword;
use App\Http\Middleware\RoleMiddleware;
use Illuminate\Routing\Middleware\ValidateSignature;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Auth\Middleware\EnsureEmailIsVerified;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
@@ -15,17 +46,17 @@ class Kernel extends HttpKernel
*/
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Illuminate\Http\Middleware\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
TrustProxies::class,
HandleCors::class,
PreventRequestsDuringMaintenance::class,
ValidatePostSize::class,
TrimStrings::class,
ConvertEmptyStringsToNull::class,
];
protected $middlewarePriority = [
\Inertia\Middleware::class,
\App\Http\Middleware\Demo::class,
Middleware::class,
Demo::class,
];
/**
@@ -35,22 +66,22 @@ class Kernel extends HttpKernel
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\SetLocale::class,
\App\Http\Middleware\Demo::class,
\App\Http\Middleware\InstallationComplete::class,
\App\Http\Middleware\HandleInertiaRequests::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
SetLocale::class,
Demo::class,
InstallationComplete::class,
HandleInertiaRequests::class,
],
'api' => [
'throttle:60,1',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
SubstituteBindings::class,
],
];
@@ -62,20 +93,20 @@ class Kernel extends HttpKernel
* @var array
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.blocked' => \App\Http\Middleware\UserBlocked::class,
'auth.2fa' => \App\Http\Middleware\EnforceTwoFactorAuthenticationIfEnabled::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'has.access' => \App\Http\Middleware\HasAccessToThisGroup::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'global.api.authenticated' => \App\Http\Middleware\GlobalApiAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'role' => \App\Http\Middleware\RoleMiddleware::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'auth' => Authenticate::class,
'auth.basic' => AuthenticateWithBasicAuth::class,
'auth.blocked' => UserBlocked::class,
'auth.2fa' => EnforceTwoFactorAuthenticationIfEnabled::class,
'bindings' => SubstituteBindings::class,
'cache.headers' => SetCacheHeaders::class,
'can' => Authorize::class,
'has.access' => HasAccessToThisGroup::class,
'guest' => RedirectIfAuthenticated::class,
'global.api.authenticated' => GlobalApiAuthenticated::class,
'password.confirm' => RequirePassword::class,
'role' => RoleMiddleware::class,
'signed' => ValidateSignature::class,
'throttle' => ThrottleRequests::class,
'verified' => EnsureEmailIsVerified::class,
];
}

View File

@@ -2,6 +2,7 @@
namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class Authenticate extends Middleware
@@ -9,7 +10,7 @@ class Authenticate extends Middleware
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @param Request $request
* @return string|null
*/
protected function redirectTo($request)

View File

@@ -2,6 +2,7 @@
namespace App\Http\Middleware;
use Str;
use Closure;
use Illuminate\Http\Request;
@@ -19,7 +20,7 @@ class Demo
public function handle(Request $request, Closure $next)
{
if ($this->isNotAllowedToDoThis($request) && \Str::contains($request->route()->getName(), 'livewire')) {
if ($this->isNotAllowedToDoThis($request) && Str::contains($request->route()->getName(), 'livewire')) {
abort(404);
}

View File

@@ -2,6 +2,7 @@
namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Closure;
class InstallationComplete
@@ -9,8 +10,8 @@ class InstallationComplete
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param Request $request
* @param Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
@@ -38,7 +39,6 @@ class InstallationComplete
protected function isInstallationComplete()
{
return config('app.key') &&
config('services.ploi.token') &&
config('services.ploi.core-token');
config('services.ploi.token');
}
}

View File

@@ -2,6 +2,7 @@
namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Closure;
use Illuminate\Support\Facades\Auth;
use App\Providers\RouteServiceProvider;
@@ -11,8 +12,8 @@ class RedirectIfAuthenticated
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param Request $request
* @param Closure $next
* @param string|null $guard
* @return mixed
*/

View File

@@ -2,6 +2,7 @@
namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Closure;
use App\Models\User;
use App\Models\SupportTicket;
@@ -11,8 +12,8 @@ class RoleMiddleware
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param Request $request
* @param Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $role = null)

View File

@@ -2,6 +2,8 @@
namespace App\Http\Middleware;
use Cache;
use Illuminate\Http\Request;
use Closure;
use Carbon\Carbon;
@@ -10,8 +12,8 @@ class SetLocale
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param Request $request
* @param Closure $next
*
* @return mixed
*/
@@ -56,6 +58,6 @@ class SetLocale
return $resolver();
}
return \Cache::remember('translations-' . app()->getLocale(), now()->addDay(), $resolver);
return Cache::remember('translations-' . app()->getLocale(), now()->addDay(), $resolver);
}
}

View File

@@ -2,6 +2,7 @@
namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Closure;
class UserBlocked
@@ -9,8 +10,8 @@ class UserBlocked
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param Request $request
* @param Closure $next
* @return mixed
*/
public function handle($request, Closure $next)

Some files were not shown because too many files have changed in this diff Show More