canCreate = Auth::user()?->can('song-edit') ?? false; } public function openModal() { $this->showModal = true; } public function closeModal() { $this->showModal = false; } public function import() { // 檢查檔案是否有上傳 $this->validate([ 'file' => 'required|file|mimes:csv,xlsx,xls' ]); if ($this->canCreate) { // 儲存檔案至 storage $path = $this->file->storeAs('imports', uniqid() . '_' . $this->file->getClientOriginalName()); // 丟到 queue 執行 ImportArtistJob::dispatch($path); $this->reset('file'); $this->showModal = false; session()->flash('message', '已排入背景匯入作業,請稍候查看結果'); } } public function render() { return view('livewire.admin.artist-import-data'); } }