Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52ef42a81d | ||
|
|
e225499905 | ||
|
|
9522b28b9d | ||
|
|
e3b944f450 | ||
|
|
e197a915b3 | ||
|
|
db1240c43f |
0
.ai/mcp/mcp.json
Normal file
0
.ai/mcp/mcp.json
Normal file
551
.junie/guidelines.md
Normal file
551
.junie/guidelines.md
Normal 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
11
.junie/mcp/mcp.json
Normal 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
11
.mcp.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"mcpServers": {
|
||||
"laravel-boost": {
|
||||
"command": "php",
|
||||
"args": [
|
||||
"artisan",
|
||||
"boost:mcp"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
556
CLAUDE.md
556
CLAUDE.md
@@ -119,4 +119,558 @@ STRIPE_SECRET= # Stripe secret key
|
||||
- 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.
|
||||
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>
|
||||
|
||||
@@ -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.')
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -11,20 +11,19 @@ use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Services\VersionChecker;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use function Laravel\Prompts\text;
|
||||
use function Laravel\Prompts\password;
|
||||
use function Laravel\Prompts\confirm;
|
||||
use function Laravel\Prompts\select;
|
||||
use function Laravel\Prompts\info;
|
||||
use function Laravel\Prompts\error;
|
||||
use function Laravel\Prompts\warning;
|
||||
use function Laravel\Prompts\note;
|
||||
use function Laravel\Prompts\spin;
|
||||
use function Laravel\Prompts\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 function Laravel\Prompts\confirm;
|
||||
use function Laravel\Prompts\warning;
|
||||
use function Laravel\Prompts\password;
|
||||
|
||||
class Install extends Command
|
||||
{
|
||||
@@ -60,7 +59,7 @@ class Install extends Command
|
||||
);
|
||||
|
||||
return Command::SUCCESS;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
error('Installation failed: ' . $e->getMessage());
|
||||
return Command::FAILURE;
|
||||
}
|
||||
@@ -266,7 +265,7 @@ class Install extends Command
|
||||
try {
|
||||
$this->writeToEnvironmentFile('APP_URL', $url);
|
||||
info('✓ Application URL configured');
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
error('Failed to save application URL: ' . $e->getMessage());
|
||||
exit(1);
|
||||
}
|
||||
@@ -284,7 +283,7 @@ class Install extends Command
|
||||
}
|
||||
|
||||
info('✓ Installation marker created');
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
error('Error creating installation file: ' . $e->getMessage());
|
||||
exit(1);
|
||||
}
|
||||
@@ -306,7 +305,7 @@ class Install extends Command
|
||||
try {
|
||||
symlink($storagePath, $publicPath);
|
||||
info('✓ Storage symlink created');
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
warning('Could not create storage symlink (may need manual creation)');
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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}'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -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'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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]))
|
||||
@@ -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
|
||||
{
|
||||
@@ -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('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
@@ -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')
|
||||
@@ -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,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -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}'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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';
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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')
|
||||
@@ -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()
|
||||
@@ -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
|
||||
@@ -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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -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'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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';
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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')
|
||||
@@ -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()
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -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'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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';
|
||||
@@ -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
|
||||
{
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
@@ -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'),
|
||||
];
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -49,7 +50,7 @@ class ViewSupportTicket extends Page
|
||||
})
|
||||
->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;
|
||||
@@ -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
|
||||
@@ -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}'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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)
|
||||
@@ -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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class DocumentationCategoryRouteResource extends JsonResource
|
||||
@@ -9,7 +10,7 @@ class DocumentationCategoryRouteResource extends JsonResource
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class DocumentationItemResource extends JsonResource
|
||||
@@ -9,7 +10,7 @@ class DocumentationItemResource extends JsonResource
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ServerResource extends JsonResource
|
||||
@@ -9,7 +10,7 @@ class ServerResource extends JsonResource
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user