Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
curtisdelicata committed Aug 31, 2024
1 parent 5bfe41b commit 97e143d
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 116 deletions.
48 changes: 34 additions & 14 deletions app/Filament/App/Resources/DatabaseResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,43 @@

namespace App\Filament\App\Resources;

use App\Filament\App\Resources\ResourceResource\Pages;
use App\Filament\App\Resources\ResourceResource\RelationManagers;
use App\Models\Resource as ResourceModel;
use App\Filament\App\Resources\DatabaseResource\Pages;
use App\Models\Database;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use App\Services\MySqlDatabaseService;

class ResourceResource extends Resource
class DatabaseResource extends Resource
{
protected static ?string $model = Database::class;

protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';

public static function form(Form $form): Form
public static function form(Forms\Form $form): Forms\Form
{
return $form
->schema([
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\TextInput::make('user_id')
Forms\Components\Select::make('charset')
->required()
->numeric(),
->options([
'utf8mb4' => 'UTF-8 Unicode (utf8mb4)',
'latin1' => 'Latin1 (latin1)',
// Add more options as needed
])
->default('utf8mb4'),
Forms\Components\Select::make('collation')
->required()
->options([
'utf8mb4_unicode_ci' => 'UTF-8 Unicode (utf8mb4_unicode_ci)',
'latin1_swedish_ci' => 'Latin1 Swedish (latin1_swedish_ci)',
// Add more options as needed
])
->default('utf8mb4_unicode_ci'),
]);
}

Expand All @@ -38,19 +48,29 @@ public static function table(Table $table): Table
->columns([
Tables\Columns\TextColumn::make('name')
->searchable(),
Tables\Columns\TextColumn::make('user_id')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('charset'),
Tables\Columns\TextColumn::make('collation'),
Tables\Columns\TextColumn::make('created_at')
->dateTime(),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make()
->before(function (Database $record, MySqlDatabaseService $service) {
$service->dropDatabase($record->name);
}),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\DeleteBulkAction::make()
->before(function (Collection $records, MySqlDatabaseService $service) {
foreach ($records as $record) {
$service->dropDatabase($record->name);
}
}),
]),
]);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php

namespace App\Filament\App\Resources\ResourceResource\Pages;
namespace App\Filament\App\Resources\DatabaseResource\Pages;

use App\Filament\App\Resources\ResourceResource;
use App\Filament\App\Resources\DatabaseResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
use App\Services\MySqlDatabaseService;
use Filament\Notifications\Notification;

class CreateResource extends CreateRecord
{
protected static string $resource = ResourceResource::class;
protected static string $resource = DatabaseResource::class;

protected function handleRecordCreation(array $data): Model
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php

namespace App\Filament\App\Resources\ResourceResource\Pages;
namespace App\Filament\App\Resources\DatabaseResource\Pages;

use App\Filament\App\Resources\ResourceResource;
use App\Filament\App\Resources\DatabaseResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use App\Services\MySqlDatabaseService;
use Filament\Notifications\Notification;

class EditResource extends EditRecord
{
protected static string $resource = ResourceResource::class;
protected static string $resource = DatabaseResource::class;

protected function getHeaderActions(): array
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace App\Filament\App\Resources\ResourceResource\Pages;
namespace App\Filament\App\Resources\DatabaseResource\Pages;

use App\Filament\App\Resources\ResourceResource;
use App\Filament\App\Resources\DatabaseResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;

class ListResources extends ListRecords
{
protected static string $resource = ResourceResource::class;
protected static string $resource = DatabaseResource::class;

protected function getHeaderActions(): array
{
Expand Down
93 changes: 0 additions & 93 deletions app/Filament/App/Resources/ResourceResource.php

This file was deleted.

0 comments on commit 97e143d

Please sign in to comment.