added url and call to action to entries migraiton and model

updated unit tests
This commit is contained in:
jon brookes 2026-01-17 16:35:14 +00:00
parent 0d688a0f82
commit 6731b4c487
5 changed files with 53 additions and 14 deletions

View file

@ -163,6 +163,11 @@ class EntryForm
->toArray();
})
->searchable(),
TextInput::make('call_to_action_text')
->label('Call to Action Text'),
TextInput::make('call_to_action_link')
->label('Call to Action URL'),
RichEditor::make('content')
->columnSpanFull()
->hintAction(

View file

@ -25,6 +25,8 @@ class EntryResource extends JsonResource
'content' => $this->content,
'category' => $this->category->name ?? null,
'featured_image_url' => $this->getFirstMediaUrl('featured-image') ?: null,
'call_to_action_text' => $this->call_to_action_text,
'call_to_action_link' => $this->call_to_action_link,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];

View file

@ -17,6 +17,7 @@ use Spatie\Tags\HasTags;
Entry model with rich content and media library integration
This is the main article / blog rich content model
*/
class Entry extends Model implements HasMedia, HasRichContent
{
use HasFactory, HasTags, InteractsWithMedia, InteractsWithRichContent;
@ -29,7 +30,8 @@ class Entry extends Model implements HasMedia, HasRichContent
'is_featured',
'published_at',
'content',
'category_id',
'call_to_action_link',
'call_to_action_text',
];
/**

View file

@ -0,0 +1,29 @@
<?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::table('entries', function (Blueprint $table) {
$table->string('call_to_action_text')->nullable()->after('title');
$table->string('call_to_action_link')->nullable()->after('url');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('entries', function (Blueprint $table) {
$table->dropColumn('call_to_action_text');
$table->dropColumn('call_to_action_link');
});
}
};

View file

@ -11,7 +11,8 @@ it('has correct fillable attributes', function () {
'is_featured',
'published_at',
'content',
'category_id',
'call_to_action_link',
'call_to_action_text',
];
$entry = new Entry;