mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-21 23:20:24 +00:00
update
This commit is contained in:
parent
cacaa5c452
commit
08d3a9729c
3 changed files with 32 additions and 2 deletions
|
@ -25,7 +25,12 @@ class MinecraftServerResource extends Resource
|
|||
{
|
||||
return $form
|
||||
->schema([
|
||||
//
|
||||
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name')
|
||||
->placeholder('Enter the name of the server'),
|
||||
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,9 @@ class MinecraftServer extends Model
|
|||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [];
|
||||
protected $fillable = [
|
||||
'name',
|
||||
];
|
||||
|
||||
|
||||
protected static function booted(): void
|
||||
|
@ -33,6 +35,27 @@ class MinecraftServer extends Model
|
|||
|
||||
static::creating(function ($model) {
|
||||
|
||||
$minectaftId = 1;
|
||||
$findLastMinecraftServer = MinecraftServer::orderBy('id', 'desc')->first();
|
||||
if ($findLastMinecraftServer) {
|
||||
$minectaftId = $findLastMinecraftServer->id + 1;
|
||||
$model->name = 'Server #'.$minectaftId;
|
||||
} else {
|
||||
$model->name = 'Server #1';
|
||||
}
|
||||
|
||||
$minecraftServersPath = '/home/minecraft/servers';
|
||||
$minecraftServerPath = $minecraftServersPath . '/'.$minectaftId;
|
||||
shell_exec('mkdir -p '.$minecraftServerPath);
|
||||
|
||||
$minecraftServerDocker = view('minecraft::actions.docker-compose', [
|
||||
'id' => $minectaftId
|
||||
])->render();
|
||||
|
||||
file_put_contents($minecraftServerPath.'/docker-compose.yml', $minecraftServerDocker);
|
||||
$docker = shell_exec('cd '.$minecraftServerPath.' && docker-compose up -d');
|
||||
|
||||
dd($docker);
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -7,3 +7,5 @@ services:
|
|||
- "25565:25565"
|
||||
environment:
|
||||
EULA: "TRUE"
|
||||
GAMEMODE: survival
|
||||
DIFFICULTY: normal
|
Loading…
Reference in a new issue