Merge pull request 'added url and call to action to entries migraiton and model' (#13) from feat/add-url-envents into dev
Reviewed-on: https://codeberg.org/headshed/share-lt/pulls/13
This commit is contained in:
commit
9f77f8b8d3
5 changed files with 53 additions and 14 deletions
|
|
@ -67,11 +67,11 @@ class EntryForm
|
||||||
$fileName = e($item->file_name);
|
$fileName = e($item->file_name);
|
||||||
$name = e($item->name ?? '');
|
$name = e($item->name ?? '');
|
||||||
|
|
||||||
$html = "<div class='flex items-center gap-3'>".
|
$html = "<div class='flex items-center gap-3'>" .
|
||||||
"<img src='{$url}' class='rounded' style='width:60px;height:60px;object-fit:cover;' alt='{$fileName}' loading='lazy' />".
|
"<img src='{$url}' class='rounded' style='width:60px;height:60px;object-fit:cover;' alt='{$fileName}' loading='lazy' />" .
|
||||||
"<div class='flex flex-col'>".
|
"<div class='flex flex-col'>" .
|
||||||
"<span class='font-medium text-sm'>{$name}</span>".
|
"<span class='font-medium text-sm'>{$name}</span>" .
|
||||||
"<span class='text-xs text-gray-500'>{$fileName}</span>".
|
"<span class='text-xs text-gray-500'>{$fileName}</span>" .
|
||||||
'</div></div>';
|
'</div></div>';
|
||||||
|
|
||||||
return [$item->id => $html];
|
return [$item->id => $html];
|
||||||
|
|
@ -111,7 +111,7 @@ class EntryForm
|
||||||
}
|
}
|
||||||
|
|
||||||
$sourceFile = $sourceMedia->getPath();
|
$sourceFile = $sourceMedia->getPath();
|
||||||
$tempCopy = sys_get_temp_dir().'/'.uniqid().'_'.$sourceMedia->file_name;
|
$tempCopy = sys_get_temp_dir() . '/' . uniqid() . '_' . $sourceMedia->file_name;
|
||||||
copy($sourceFile, $tempCopy);
|
copy($sourceFile, $tempCopy);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -141,7 +141,7 @@ class EntryForm
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\Filament\Notifications\Notification::make()
|
\Filament\Notifications\Notification::make()
|
||||||
->danger()
|
->danger()
|
||||||
->title('Error: '.$e->getMessage())
|
->title('Error: ' . $e->getMessage())
|
||||||
->send();
|
->send();
|
||||||
} finally {
|
} finally {
|
||||||
if (file_exists($tempCopy)) {
|
if (file_exists($tempCopy)) {
|
||||||
|
|
@ -163,6 +163,11 @@ class EntryForm
|
||||||
->toArray();
|
->toArray();
|
||||||
})
|
})
|
||||||
->searchable(),
|
->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')
|
RichEditor::make('content')
|
||||||
->columnSpanFull()
|
->columnSpanFull()
|
||||||
->hintAction(
|
->hintAction(
|
||||||
|
|
@ -193,11 +198,11 @@ class EntryForm
|
||||||
$name = e($item->name ?? '');
|
$name = e($item->name ?? '');
|
||||||
|
|
||||||
// Smaller image preview for better performance
|
// Smaller image preview for better performance
|
||||||
$html = "<div class='flex items-center gap-3'>".
|
$html = "<div class='flex items-center gap-3'>" .
|
||||||
"<img src='{$url}' class='rounded' style='width:60px;height:60px;object-fit:cover;' alt='{$fileName}' loading='lazy' />".
|
"<img src='{$url}' class='rounded' style='width:60px;height:60px;object-fit:cover;' alt='{$fileName}' loading='lazy' />" .
|
||||||
"<div class='flex flex-col'>".
|
"<div class='flex flex-col'>" .
|
||||||
"<span class='font-medium text-sm'>{$name}</span>".
|
"<span class='font-medium text-sm'>{$name}</span>" .
|
||||||
"<span class='text-xs text-gray-500'>{$fileName}</span>".
|
"<span class='text-xs text-gray-500'>{$fileName}</span>" .
|
||||||
'</div></div>';
|
'</div></div>';
|
||||||
|
|
||||||
return [$url => $html];
|
return [$url => $html];
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ class EntryResource extends JsonResource
|
||||||
'content' => $this->content,
|
'content' => $this->content,
|
||||||
'category' => $this->category->name ?? null,
|
'category' => $this->category->name ?? null,
|
||||||
'featured_image_url' => $this->getFirstMediaUrl('featured-image') ?: 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,
|
'created_at' => $this->created_at,
|
||||||
'updated_at' => $this->updated_at,
|
'updated_at' => $this->updated_at,
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ use Spatie\Tags\HasTags;
|
||||||
Entry model with rich content and media library integration
|
Entry model with rich content and media library integration
|
||||||
This is the main article / blog rich content model
|
This is the main article / blog rich content model
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Entry extends Model implements HasMedia, HasRichContent
|
class Entry extends Model implements HasMedia, HasRichContent
|
||||||
{
|
{
|
||||||
use HasFactory, HasTags, InteractsWithMedia, InteractsWithRichContent;
|
use HasFactory, HasTags, InteractsWithMedia, InteractsWithRichContent;
|
||||||
|
|
@ -29,7 +30,8 @@ class Entry extends Model implements HasMedia, HasRichContent
|
||||||
'is_featured',
|
'is_featured',
|
||||||
'published_at',
|
'published_at',
|
||||||
'content',
|
'content',
|
||||||
'category_id',
|
'call_to_action_link',
|
||||||
|
'call_to_action_text',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
29
database/migrations/2026_01_17_162204_add-url-to-entries.php
Normal file
29
database/migrations/2026_01_17_162204_add-url-to-entries.php
Normal 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');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -11,7 +11,8 @@ it('has correct fillable attributes', function () {
|
||||||
'is_featured',
|
'is_featured',
|
||||||
'published_at',
|
'published_at',
|
||||||
'content',
|
'content',
|
||||||
'category_id',
|
'call_to_action_link',
|
||||||
|
'call_to_action_text',
|
||||||
];
|
];
|
||||||
|
|
||||||
$entry = new Entry;
|
$entry = new Entry;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue