diff --git a/app/Http/Controllers/WebsiteController.php b/app/Http/Controllers/WebsiteController.php new file mode 100644 index 0000000..1c7c5e1 --- /dev/null +++ b/app/Http/Controllers/WebsiteController.php @@ -0,0 +1,75 @@ +with(['user', 'phpVersion'])->orderBy('url')->get(); + + try { + $serverIp = Http::get('https://api.ipify.org')->body(); + } catch (\Exception $exception) { + $serverIp = 'N/A'; + } + + return Inertia::render('Websites/Index', compact('websites', 'serverIp')); + } + + /** + * Show the form for creating a new resource. + */ + public function create() + { + // + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request) + { + // + } + + /** + * Display the specified resource. + */ + public function show(string $id) + { + // + } + + /** + * Show the form for editing the specified resource. + */ + public function edit(string $id) + { + // + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, string $id) + { + // + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(string $id) + { + // + } +} diff --git a/app/Models/User.php b/app/Models/User.php index a4d4c84..c526057 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -15,6 +15,8 @@ class User extends Authenticatable /** @use HasFactory<\Database\Factories\UserFactory> */ use HasFactory, Notifiable, Impersonate; + public $appends = ['homedir']; + /** * The attributes that are mass assignable. * @@ -87,4 +89,9 @@ class User extends Authenticatable get: fn() => $this->username . '_ln', ); } + + public function websites(): \Illuminate\Database\Eloquent\Relations\HasMany + { + return $this->hasMany(Website::class); + } } diff --git a/app/Models/Website.php b/app/Models/Website.php new file mode 100644 index 0000000..d8c8d5f --- /dev/null +++ b/app/Models/Website.php @@ -0,0 +1,31 @@ +when(!auth()->user()->isAdmin(), fn($query) => $query->where('user_id', auth()->id())); + } + + public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(User::class)->select(['id', 'username', 'role']); + } + + public function phpVersion(): \Illuminate\Database\Eloquent\Relations\HasOne + { + return $this->hasOne(PhpVersion::class); + } +} diff --git a/database/migrations/2025_02_25_062355_create_websites_table.php b/database/migrations/2025_02_25_062355_create_websites_table.php new file mode 100644 index 0000000..b5ffd96 --- /dev/null +++ b/database/migrations/2025_02_25_062355_create_websites_table.php @@ -0,0 +1,31 @@ +id(); + $table->foreignId('user_id'); + $table->string('url'); + $table->string('document_root'); + $table->foreignId('php_version_id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('websites'); + } +}; diff --git a/package.json b/package.json index 6496aa4..4f74a10 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "chart.js": "^4.4.7", "prismjs": "^1.29.0", "react-chartjs-2": "^5.3.0", + "react-copy-to-clipboard": "^5.1.0", "react-data-table-component": "^7.6.2", "react-file-icon": "^1.5.0", "react-icons": "^5.4.0", diff --git a/resources/js/Components/TextInput.jsx b/resources/js/Components/TextInput.jsx index d583c47..b8a9341 100644 --- a/resources/js/Components/TextInput.jsx +++ b/resources/js/Components/TextInput.jsx @@ -1,7 +1,13 @@ import { forwardRef, useEffect, useImperativeHandle, useRef } from 'react'; export default forwardRef(function TextInput( - { type = 'text', className = '', isFocused = false, ...props }, + { + type = 'text', + className = '', + isFocused = false, + prependedText = '', + ...props + }, ref, ) { const localRef = useRef(null); @@ -17,14 +23,20 @@ export default forwardRef(function TextInput( }, [isFocused]); return ( - +
| ID | +URL | +Document Root | +PHP Version | + {auth.user.role == 'admin' && ( +User | + )} +Actions | +
|---|---|---|---|---|---|
| + {website.url} + | ++ {website.document_root} + | ++ {website.php_version.version} + | + {auth.user.role == 'admin' && ( +
+ {website.user.username}
+
+ {website.user.username}
+
+ {website.user.role == "admin" ? Admin : User}
+ |
+ )}
+ + {account.role == "admin" ? Admin : User} + | +
+
+
+ {/*
+
+ |
+