diff --git a/app/Http/Controllers/Admin/MountController.php b/app/Http/Controllers/Admin/MountController.php
index c0a506299..a9be8d7dd 100644
--- a/app/Http/Controllers/Admin/MountController.php
+++ b/app/Http/Controllers/Admin/MountController.php
@@ -54,6 +54,21 @@ class MountController extends Controller
]);
}
+ /**
+ * Return the mount view page.
+ *
+ * @param string $id
+ * @return \Illuminate\View\View
+ *
+ * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
+ */
+ public function view($id)
+ {
+ return view('admin.mounts.view', [
+ 'mount' => $this->repository->getWithRelations($id),
+ ]);
+ }
+
/**
* Handle request to create new mount.
*
diff --git a/app/Models/Mount.php b/app/Models/Mount.php
index cf05ac89c..c580697c5 100644
--- a/app/Models/Mount.php
+++ b/app/Models/Mount.php
@@ -3,7 +3,8 @@
namespace Pterodactyl\Models;
/**
- * @property string $id
+ * @property int $id
+ * @property string $uuid
* @property string $name
* @property string $description
* @property string $source
@@ -11,8 +12,8 @@ namespace Pterodactyl\Models;
* @property bool $read_only
* @property bool $user_mountable
*
- * @property \Illuminate\Database\Eloquent\Relations\BelongsToMany $nodes
* @property \Illuminate\Database\Eloquent\Relations\BelongsToMany $eggs
+ * @property \Illuminate\Database\Eloquent\Relations\BelongsToMany $nodes
*/
class Mount extends Model
{
@@ -34,7 +35,7 @@ class Mount extends Model
*
* @var array
*/
- protected $guarded = ['id', 'name', 'description', 'source', 'target'];
+ protected $guarded = ['id', 'uuid', 'name', 'description', 'source', 'target'];
/**
* Default values for specific fields in the database.
@@ -42,6 +43,12 @@ class Mount extends Model
* @var array
*/
protected $attributes = [
+ 'id' => 'int',
+ 'uuid' => 'string',
+ 'name' => 'string',
+ 'description' => 'string',
+ 'source' => 'string',
+ 'target' => 'string',
'read_only' => 'bool',
'user_mountable' => 'bool',
];
@@ -52,7 +59,7 @@ class Mount extends Model
* @var string
*/
public static $validationRules = [
- // 'id' => 'required|string|size:36|unique:mounts,id',
+ // 'uuid' => 'required|string|size:36|unique:mounts,uuid',
'name' => 'required|string|min:2|max:64|unique:mounts,name',
'description' => 'nullable|string|max:255',
'source' => 'required|string',
diff --git a/app/Repositories/Eloquent/MountRepository.php b/app/Repositories/Eloquent/MountRepository.php
index 2bf953566..26766b88b 100644
--- a/app/Repositories/Eloquent/MountRepository.php
+++ b/app/Repositories/Eloquent/MountRepository.php
@@ -5,6 +5,8 @@ namespace Pterodactyl\Repositories\Eloquent;
use Pterodactyl\Models\Mount;
use Illuminate\Support\Collection;
use Pterodactyl\Repositories\Concerns\Searchable;
+use Illuminate\Database\Eloquent\ModelNotFoundException;
+use Pterodactyl\Exceptions\Repository\RecordNotFoundException;
class MountRepository extends EloquentRepository
{
@@ -29,4 +31,21 @@ class MountRepository extends EloquentRepository
{
return $this->getBuilder()->withCount('eggs', 'nodes')->get($this->getColumns());
}
+
+ /**
+ * Return all of the mounts and their respective relations.
+ *
+ * @param string $id
+ * @return mixed
+ *
+ * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
+ */
+ public function getWithRelations(string $id): Mount
+ {
+ try {
+ return $this->getBuilder()->with('eggs', 'nodes')->findOrFail($id, $this->getColumns());
+ } catch (ModelNotFoundException $exception) {
+ throw new RecordNotFoundException;
+ }
+ }
}
diff --git a/app/Services/Mounts/MountCreationService.php b/app/Services/Mounts/MountCreationService.php
index ac6a8e00f..923ba9abb 100644
--- a/app/Services/Mounts/MountCreationService.php
+++ b/app/Services/Mounts/MountCreationService.php
@@ -34,7 +34,7 @@ class MountCreationService
public function handle(array $data)
{
return $this->repository->create(array_merge($data, [
- 'id' => Uuid::uuid4()->toString(),
+ 'uuid' => Uuid::uuid4()->toString(),
]), true, true);
}
}
diff --git a/database/migrations/2020_05_20_234655_add_mounts_table.php b/database/migrations/2020_05_20_234655_add_mounts_table.php
index ffc933aba..3bc25d036 100644
--- a/database/migrations/2020_05_20_234655_add_mounts_table.php
+++ b/database/migrations/2020_05_20_234655_add_mounts_table.php
@@ -14,8 +14,9 @@ class AddMountsTable extends Migration
public function up()
{
Schema::create('mounts', function (Blueprint $table) {
- $table->char('id', 36)->unique();
- $table->string('name');
+ $table->increments('id')->unique();
+ $table->char('uuid', 36)->unique();
+ $table->string('name')->unique();
$table->text('description')->nullable();
$table->string('source');
$table->string('target');
@@ -24,13 +25,13 @@ class AddMountsTable extends Migration
});
Schema::create('egg_mount', function (Blueprint $table) {
- $table->increments('egg_id')->unique();
- $table->char('mount_id', 36)->unique();
+ $table->integer('egg_id');
+ $table->char('mount_id', 36);
});
Schema::create('mount_node', function (Blueprint $table) {
- $table->increments('node_id')->unique();
- $table->char('mount_id', 36)->unique();
+ $table->integer('node_id');
+ $table->char('mount_id', 36);
});
}
diff --git a/resources/views/admin/mounts/index.blade.php b/resources/views/admin/mounts/index.blade.php
index 765c62fbe..57835001a 100644
--- a/resources/views/admin/mounts/index.blade.php
+++ b/resources/views/admin/mounts/index.blade.php
@@ -46,7 +46,7 @@
@foreach ($mounts as $mount)
{{ $mount->id }} |
- {{ $mount->name }} |
+ {{ $mount->name }} |
{{ $mount->source }} |
{{ $mount->target }} |
{{ $mount->eggs_count }} |
diff --git a/resources/views/admin/mounts/view.blade.php b/resources/views/admin/mounts/view.blade.php
new file mode 100644
index 000000000..ef93ec9ba
--- /dev/null
+++ b/resources/views/admin/mounts/view.blade.php
@@ -0,0 +1,148 @@
+{{-- Pterodactyl - Panel --}}
+{{-- Copyright (c) 2015 - 2017 Dane Everitt --}}
+
+{{-- This software is licensed under the terms of the MIT license. --}}
+{{-- https://opensource.org/licenses/MIT --}}
+
+@extends('layouts.admin')
+
+@section('title')
+ Mounts → View → {{ $mount->id }}
+@endsection
+
+@section('content-header')
+ {{ $mount->name }}{{ str_limit($mount->description, 75) }}
+
+ - Admin
+ - Mounts
+ - {{ $mount->name }}
+
+@endsection
+
+@section('content')
+
+
+
+
+
+
+
+
+
+
+ ID |
+ Name |
+
+
+ @foreach($mount->eggs as $egg)
+
+ {{ $egg->id }} |
+ {{ $egg->name }} |
+
+ @endforeach
+
+
+
+
+
+
+
+
+
+
+ ID |
+ Name |
+ FQDN |
+
+
+ @foreach($mount->nodes as $node)
+
+ {{ $node->id }} |
+ {{ $node->name }} |
+ {{ $node->fqdn }} |
+
+ @endforeach
+
+
+
+
+
+@endsection
diff --git a/routes/admin.php b/routes/admin.php
index f1d95cc10..f552e6a33 100644
--- a/routes/admin.php
+++ b/routes/admin.php
@@ -175,6 +175,7 @@ Route::group(['prefix' => 'nodes'], function () {
*/
Route::group(['prefix' => 'mounts'], function () {
Route::get('/', 'MountController@index')->name('admin.mounts');
+ Route::get('/view/{mount}', 'MountController@view')->name('admin.mounts.view');
Route::post('/', 'MountController@create');
});