feat: add published_url column to posts
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
30095519e4
commit
80423301c4
@@ -25,6 +25,7 @@ class Post extends Model
|
||||
'body',
|
||||
'status',
|
||||
'scheduled_at',
|
||||
'published_url',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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('posts', function (Blueprint $table) {
|
||||
$table->string('published_url')->nullable()->after('scheduled_at');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('posts', function (Blueprint $table) {
|
||||
$table->dropColumn('published_url');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -83,3 +83,17 @@ test('deleting a social account nulls out the post link but keeps the post', fun
|
||||
->not->toBeNull()
|
||||
->social_account_id->toBeNull();
|
||||
});
|
||||
|
||||
test('a post can store a published_url', function () {
|
||||
$post = Post::factory()->create(['published_url' => null]);
|
||||
|
||||
$post->update(['published_url' => 'https://example.com/2026/07/my-post']);
|
||||
|
||||
expect($post->fresh()->published_url)->toBe('https://example.com/2026/07/my-post');
|
||||
});
|
||||
|
||||
test('published_url defaults to null', function () {
|
||||
$post = Post::factory()->create();
|
||||
|
||||
expect($post->fresh()->published_url)->toBeNull();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user