Skip to content

Commit 824041f

Browse files
committed
Fix service creation/updates, closes pterodactyl#306
1 parent 99497ad commit 824041f

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
1212
* `[pre.2]` — Fixes inability to delete accounts due to SQL changes.
1313
* `[pre.2]` — Fixes bug with checking power-permissions that showed the wrong buttons. Also adds check back to sidebar to only show options a user can use.
1414
* `[pre.2]` — Fixes allocation listing on node allocations tab as well as bug preventing deletion of port.
15+
* `[pre.2]` — Fixes bug in services that prevented saving updated settings or creating new services.
1516

1617
### Changed
1718
* `[pre.2]` — File Manager now displays relevant information on all screen sizes, and includes better button clicking mechanics for dropdown menu.

app/Models/Service.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ class Service extends Model
3636
protected $table = 'services';
3737

3838
/**
39-
* Fields that are not mass assignable.
39+
* Fields that are mass assignable.
4040
*
4141
* @var array
4242
*/
43-
protected $fillable = ['id', 'created_at', 'updated_at'];
43+
protected $fillable = [
44+
'name', 'description', 'file', 'executable', 'startup',
45+
];
4446

4547
/**
4648
* Gets all service options associated with this service.

app/Repositories/ServiceRepository/Service.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@ public function create(array $data)
5353
throw new DisplayValidationException($validator->errors());
5454
}
5555

56-
$data['author'] = env('SERVICE_AUTHOR', (string) Uuid::generate(4));
57-
5856
DB::beginTransaction();
5957
try {
60-
$service = Models\Service::create($data);
58+
$service = new Models\Service;
59+
$service->author = env('SERVICE_AUTHOR', (string) Uuid::generate(4));
60+
$service->fill($data);
61+
$service->save();
62+
6163
Storage::put('services/' . $service->file . '/main.json', '{}');
6264
Storage::copy('services/.templates/index.js', 'services/' . $service->file . '/index.js');
6365
DB::commit();

0 commit comments

Comments
 (0)