First setup: module registry, switchable modules, permissions

This commit is contained in:
Matthijs Iriks committed 2026-12-04 01:18:14 +01:00
commit 936c794597
52 files changed
+1304

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
<?php
namespace IriksIT\Manager\Modules\Media;
use IriksIT\Manager\Models\Media;
class MediaController
{
/** First opzet: lists the records as JSON. The screens come with the frontend. */
public function index()
{
return response()->json(Media::query()->latest()->paginate(25));
}
}
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace IriksIT\Manager\Modules\Media;
use IriksIT\Manager\Modules\BaseModule;
class MediaModule extends BaseModule
{
public function key(): string
{
return 'media';
}
public function label(): string
{
return 'Media';
}
public function enabledByDefault(): bool
{
return true;
}
public function permissions(): array
{
return [
'media.view' => 'See the media library',
'media.upload' => 'Upload files',
'media.edit' => 'Change name and description of a file',
'media.delete' => 'Delete files',
];
}
public function navigation(): array
{
return [
['label' => 'Media', 'route' => 'manager.media.index', 'permission' => 'media.view'],
];
}
}
@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create(config('manager.table_prefix').'media', function (Blueprint $table) {
$table->id();
$table->string('disk');
$table->string('path');
$table->string('filename');
$table->string('mime_type');
$table->unsignedBigInteger('size');
$table->unsignedInteger('width')->nullable();
$table->unsignedInteger('height')->nullable();
$table->string('title')->nullable();
$table->text('description')->nullable();
$table->unsignedBigInteger('uploaded_by')->nullable()->index();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists(config('manager.table_prefix').'media');
}
};
+6
View File
@@ -0,0 +1,6 @@
<?php
use Illuminate\Support\Facades\Route;
use IriksIT\Manager\Modules\Media\MediaController;
Route::get('/media', [MediaController::class, 'index'])->name('media.index')->middleware('can:media.view');