Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions app/Livewire/RecentConversionsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ public function render(): View
]);
}

public function toggleStar(int $conversionJobId): void
{
$job = ConversionJob::query()
->where('user_id', auth()->id())
->find($conversionJobId);

if (! $job) {
return;
}

$job->forceFill([
'is_starred' => ! $job->is_starred,
])->save();
}

public function convertAgain(int $conversionJobId): void
{
$job = ConversionJob::query()
Expand Down
3 changes: 3 additions & 0 deletions app/Models/ConversionJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* @property string $converter_key
* @property array<string, mixed> $options_json
* @property ConversionStatus $status
* @property bool $is_starred
* @property int $progress
* @property string|null $error_code
* @property string|null $error_message
Expand All @@ -40,6 +41,7 @@
'converter_key',
'options_json',
'status',
'is_starred',
'progress',
'error_code',
'error_message',
Expand All @@ -56,6 +58,7 @@ protected function casts(): array
{
return [
'status' => ConversionStatus::class,
'is_starred' => 'boolean',
'options_json' => 'array',
'progress' => 'integer',
'started_at' => 'datetime',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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('conversion_jobs', function (Blueprint $table) {
$table->boolean('is_starred')->default(false)->after('status');
});
}

public function down(): void
{
Schema::table('conversion_jobs', function (Blueprint $table) {
$table->dropColumn('is_starred');
});
}
};
6 changes: 6 additions & 0 deletions resources/views/livewire/recent-conversions-table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ class="text-sm font-medium text-[var(--ca-primary)] hover:underline"
class="text-sm font-medium text-[var(--ca-muted)] hover:text-[var(--ca-text)]"
>Convert again</button>
@endif

<button
type="button"
wire:click="toggleStar({{ $job->id }})"
class="text-sm font-medium text-[var(--ca-muted)] hover:text-[var(--ca-text)]"
>{{ $job->is_starred ? 'Starred' : 'Star' }}</button>
</div>
</td>
</tr>
Expand Down