new modules

This commit is contained in:
Mark Gregory
2026-07-24 09:25:27 +01:00
parent d7d2a3f610
commit 73f7a918c1
88 changed files with 2342 additions and 1 deletions
+6
View File
@@ -0,0 +1,6 @@
<?php
return [
'name' => 'Media',
'enabled' => true,
];
@@ -0,0 +1,3 @@
<?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('media', function(Blueprint $table): void { $table->id(); $table->uuid('uuid')->unique(); $table->nullableMorphs('attachable'); $table->string('collection')->default('default')->index(); $table->string('disk')->default('public'); $table->string('path'); $table->string('original_name'); $table->string('mime_type')->nullable(); $table->unsignedBigInteger('size')->default(0); $table->string('title')->nullable(); $table->string('alt_text')->nullable(); $table->text('caption')->nullable(); $table->json('metadata')->nullable(); $table->unsignedInteger('sort_order')->default(0); $table->foreignId('uploaded_by')->nullable()->constrained('users')->nullOnDelete(); $table->timestamps(); $table->softDeletes(); $table->index(['attachable_type','attachable_id','collection','sort_order'],'media_attachable_collection_index'); }); } public function down(): void { Schema::dropIfExists('media'); } };
+3
View File
@@ -0,0 +1,3 @@
<?php
namespace Modules\Media\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Str;
final class Media extends Model { use SoftDeletes; protected $table='media'; protected $guarded=[]; protected static function booted(): void { static::creating(fn(self $m) => $m->uuid ??= (string) Str::uuid()); } protected function casts(): array { return ['metadata'=>'array','size'=>'integer','sort_order'=>'integer']; } }
@@ -0,0 +1,21 @@
<?php
namespace Modules\Media\Providers;
use Illuminate\Support\ServiceProvider;
use Modules\Media\Support\ModuleInfo;
final class MediaServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->app->register(RouteServiceProvider::class);
$this->mergeConfigFrom(module_path(ModuleInfo::name(), 'Config/config.php'), ModuleInfo::nameLower());
}
public function boot(): void
{
$this->loadMigrationsFrom(module_path(ModuleInfo::name(), 'Database/Migrations'));
$this->loadViewsFrom(module_path(ModuleInfo::name(), 'Resources/views'), ModuleInfo::nameLower());
}
}
@@ -0,0 +1,17 @@
<?php
namespace Modules\Media\Providers;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;
final class RouteServiceProvider extends ServiceProvider
{
public function boot(): void
{
parent::boot();
$this->routes(function (): void {
Route::middleware('web')->group(module_path('Media', 'Routes/web.php'));
});
}
}
+5
View File
@@ -0,0 +1,5 @@
<?php
use Illuminate\Support\Facades\Route;
// Module routes are intentionally registered by each feature as it is enabled.
+9
View File
@@ -0,0 +1,9 @@
<?php
namespace Modules\Media\Support;
final class ModuleInfo
{
public static function name(): string { return 'Media'; }
public static function nameLower(): string { return 'media'; }
}
@@ -0,0 +1,5 @@
<?php
it('boots the Media module', function (): void {
expect(config('media.name'))->toBe('Media');
});
+10
View File
@@ -0,0 +1,10 @@
{
"name": "absdev/media-module",
"description": "Media foundation module for the ABSDEV Laravel application platform.",
"type": "laravel-module",
"autoload": {
"psr-4": {
"Modules\\Media\\": ""
}
}
}
+20
View File
@@ -0,0 +1,20 @@
{
"name": "Media",
"alias": "media",
"version": "1.0.0",
"description": "Media foundation module for the ABSDEV Laravel application platform.",
"keywords": [
"laravel",
"modules",
"media"
],
"priority": 10,
"providers": [
"Modules\\Media\\Providers\\MediaServiceProvider"
],
"aliases": {},
"files": [],
"requires": [
"Core"
]
}