feat(attachment): add cropping functionality for images and update metadata storage

This commit is contained in:
2026-08-18 12:04:39 -03:00
parent 1c2f6c4127
commit 460ed528cf
5 changed files with 269 additions and 2 deletions

View File

@@ -0,0 +1,33 @@
<?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::table('attachments', function (Blueprint $table): void {
$table->decimal('crop_horizontal_start_percent', 7, 4)->nullable()->after('size');
$table->decimal('crop_vertical_start_percent', 7, 4)->nullable()->after('crop_horizontal_start_percent');
$table->foreignId('cropped_attachment_id')
->nullable()
->after('crop_vertical_start_percent')
->constrained('attachments')
->nullOnDelete();
});
}
public function down(): void
{
Schema::table('attachments', function (Blueprint $table): void {
$table->dropForeign(['cropped_attachment_id']);
$table->dropColumn([
'cropped_attachment_id',
'crop_horizontal_start_percent',
'crop_vertical_start_percent',
]);
});
}
};