KTV/app/Livewire/Modals/BranchSyncModal.php
allen.yan 3228031528 20250803
Branch 加入 同步畫面
修面包廂 分頁問題
調整 is_online 改成圖示顯示
2025-08-03 16:20:50 +08:00

77 lines
1.9 KiB
PHP

<?php
namespace App\Livewire\Modals;
use App\Models\Branch;
use Livewire\Component;
use App\Jobs\ExportSqliteBranchJob;
use App\Jobs\ExportSqliteSongJob;
use App\Jobs\ExportSqliteFavoriteJob;
use App\Jobs\ExportSqliteTextAdJob;
use App\Jobs\ExportSqliteUserJob;
use WireUi\Traits\WireUiActions;
class BranchSyncModal extends Component
{
use WireUiActions;
protected $listeners = [
'openModal','closeModal'
];
public int $branch_id;
public string $branch_name;
public bool $syncBranch = false;
public bool $syncSong = false;
public bool $syncFavorite = false;
public bool $syncTextAds = false;
public bool $syncUser = false;
public bool $showModal = false;
public function openModal($branch_id)
{
$this->branch_id = $branch_id;
$this->branch_name = Branch::find($branch_id)->name;
$this->reset('syncBranch', 'syncSong', 'syncFavorite', 'syncTextAds', 'syncUser');
$this->showModal = true;
}
public function closeModal()
{
$this->showModal = false;
}
public function save()
{
if ($this->syncBranch) {
ExportSqliteBranchJob::dispatch($this->branch_id);
}
if ($this->syncSong) {
ExportSqliteSongJob::dispatch($this->branch_id);
}
if ($this->syncFavorite) {
ExportSqliteFavoriteJob::dispatch($this->branch_id);
}
if($this->syncTextAds){
ExportSqliteTextAdJob::dispatch($this->branch_id);
}
if ($this->syncUser) {
ExportSqliteUserJob::dispatch(true, $this->branch_id);
}
$this->notification()->send([
'icon' => 'success',
'title' => '同步任務',
'description' => '已加入排程',
]);
$this->showModal = false;
}
public function render()
{
return view('livewire.modals.branch-sync-modal');
}
}