Images can be uploaded with alt text
This means associating images to notes via a pivot table, we also finish off the migration of medai from S3.
This commit is contained in:
parent
76db869af5
commit
9e788e0fe8
9 changed files with 200 additions and 19 deletions
|
|
@ -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
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('media_note', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('note_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignId('media_id')->constrained('media_endpoint')->onDelete('cascade');
|
||||
$table->text('alt_text')->nullable();
|
||||
$table->integer('order')->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['note_id', 'media_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('media_note');
|
||||
}
|
||||
};
|
||||
|
|
@ -84,7 +84,9 @@ class NotesTableSeeder extends Seeder
|
|||
// copy aaron’s profile pic in place
|
||||
$spl = new SplFileInfo(public_path() . '/assets/profile-images/aaronparecki.com');
|
||||
if ($spl->isDir() === false) {
|
||||
mkdir(public_path() . '/assets/profile-images/aaronparecki.com', 0755);
|
||||
if (! mkdir($concurrentDirectory = public_path() . '/assets/profile-images/aaronparecki.com', 0755) && ! is_dir($concurrentDirectory)) {
|
||||
throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory));
|
||||
}
|
||||
copy(base_path() . '/tests/aaron.png', public_path() . '/assets/profile-images/aaronparecki.com/image');
|
||||
}
|
||||
|
||||
|
|
@ -171,7 +173,9 @@ class NotesTableSeeder extends Seeder
|
|||
$noteWithOnlyImage->setCreatedAt($now);
|
||||
$noteWithOnlyImage->setUpdatedAt($now);
|
||||
$noteWithOnlyImage->save();
|
||||
$noteWithOnlyImage->media()->save($media);
|
||||
$noteWithOnlyImage->media()->attach($media->id, [
|
||||
'alt_text' => 'Test alt text',
|
||||
]);
|
||||
DB::table('notes')
|
||||
->where('id', $noteWithOnlyImage->id)
|
||||
->update(['updated_at' => $now->toDateTimeString()]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue