This commit is contained in:
Bozhidar 2024-05-13 11:04:28 +03:00
parent 046847302b
commit 996b219ed6
8 changed files with 209 additions and 1 deletions

View file

@ -0,0 +1,77 @@
<?php
namespace Modules\Minecraft\App\Filament\Resources;
use Modules\Minecraft\App\Filament\Resources\MinecraftServerResource\Pages;
use Modules\Minecraft\App\Filament\Resources\MinecraftServerResource\RelationManagers;
use Modules\Minecraft\App\Models\MinecraftServer;
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;
class MinecraftServerResource extends Resource
{
protected static ?string $model = MinecraftServer::class;
protected static ?string $navigationIcon = 'minecraft-logo';
protected static ?string $navigationGroup = 'Minecraft';
public static function form(Form $form): Form
{
return $form
->schema([
//
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('name')
->sortable(),
Tables\Columns\TextColumn::make('ip')
->sortable(),
Tables\Columns\TextColumn::make('port')
->sortable(),
Tables\Columns\TextColumn::make('status')
->sortable(),
Tables\Columns\TextColumn::make('players')
->sortable(),
Tables\Columns\TextColumn::make('world')
->sortable(),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListMinecraftServers::route('/'),
'create' => Pages\CreateMinecraftServer::route('/create'),
'edit' => Pages\EditMinecraftServer::route('/{record}/edit'),
];
}
}

View file

@ -0,0 +1,12 @@
<?php
namespace Modules\Minecraft\App\Filament\Resources\MinecraftServerResource\Pages;
use Modules\Minecraft\App\Filament\Resources\MinecraftServerResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreateMinecraftServer extends CreateRecord
{
protected static string $resource = MinecraftServerResource::class;
}

View file

@ -0,0 +1,19 @@
<?php
namespace Modules\Minecraft\App\Filament\Resources\MinecraftServerResource\Pages;
use Modules\Minecraft\App\Filament\Resources\MinecraftServerResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class EditMinecraftServer extends EditRecord
{
protected static string $resource = MinecraftServerResource::class;
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
}

View file

@ -0,0 +1,19 @@
<?php
namespace Modules\Minecraft\App\Filament\Resources\MinecraftServerResource\Pages;
use Modules\Minecraft\App\Filament\Resources\MinecraftServerResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListMinecraftServers extends ListRecords
{
protected static string $resource = MinecraftServerResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}

View file

@ -0,0 +1,19 @@
<?php
namespace Modules\Minecraft\App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Modules\Minecraft\Database\factories\MinecraftServerFactory;
class MinecraftServer extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*/
protected $fillable = [];
}

View file

@ -0,0 +1,47 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('minecraft_servers', function (Blueprint $table) {
$table->id();
$table->bigInteger('customer_id')->nullable();
$table->string('name')->nullable();
$table->string('ip')->nullable();
$table->string('port')->nullable();
$table->string('rcon_port')->nullable();
$table->string('rcon_password')->nullable();
$table->string('status')->nullable();
$table->string('version')->nullable();
$table->string('memory')->nullable();
$table->string('disk')->nullable();
$table->string('cpu')->nullable();
$table->string('players')->nullable();
$table->string('max_players')->nullable();
$table->string('world')->nullable();
$table->string('seed')->nullable();
$table->string('difficulty')->nullable();
$table->string('game_mode')->nullable();
$table->string('level_type')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('minecraft_servers');
}
};

View file

@ -11,6 +11,17 @@ echo \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update sudo apt-get update
sudo apt-get install docker-compose docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y DEPENDENCIES_LIST=(
"docker-compose"
"docker-ce"
"docker-ce-cli"
"containerd.io"
"docker-buildx-plugin"
"docker-compose-plugin"
)
for DEPENDENCY in "${DEPENDENCIES_LIST[@]}"; do
sudo apt install -y $DEPENDENCY
done
echo "Done!" echo "Done!"

View file

@ -123,6 +123,10 @@ class AdminPanelProvider extends PanelProvider
if (is_dir($modulePathPages)) { if (is_dir($modulePathPages)) {
$panel->discoverPages(in: $modulePathPages, for: 'Modules\\' . $module->name . '\\Filament\\Pages'); $panel->discoverPages(in: $modulePathPages, for: 'Modules\\' . $module->name . '\\Filament\\Pages');
} }
$modulePathResources = module_path($module->name, 'App/Filament/Resources');
if (is_dir($modulePathResources)) {
$panel->discoverResources(in: $modulePathResources, for: 'Modules\\' . $module->name . '\\App\\Filament\\Resources');
}
} }
} }
} }