修正新增變數錯誤問題 20250510
This commit is contained in:
parent
ea0e10bb64
commit
aeb14074d2
@ -77,7 +77,7 @@ class ArtistForm extends Component
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
if ($canCreate) {
|
||||
if ($this->canCreate) {
|
||||
$artist = Artist::create($this->fields);
|
||||
$this->notification()->send([
|
||||
'icon' => 'success',
|
||||
|
@ -71,7 +71,7 @@ class RoleForm extends Component
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
if ($canCreate) {
|
||||
if ($this->canCreate) {
|
||||
$role = Role::create(['name' => $this->name]);
|
||||
$role->syncPermissions($this->selectedPermissions);
|
||||
$this->notification()->send([
|
||||
|
@ -96,24 +96,32 @@ class SongForm extends Component
|
||||
//$this->validate();
|
||||
|
||||
if ($this->songId) {
|
||||
$song = Song::findOrFail($this->songId);
|
||||
$song->update($this->fields);
|
||||
$this->notification()->send([
|
||||
'icon' => 'success',
|
||||
'title' => '成功',
|
||||
'description' => '歌曲已更新',
|
||||
]);
|
||||
if ($this->canEdit) {
|
||||
$song = Song::findOrFail($this->songId);
|
||||
$song->update($this->fields);
|
||||
// ⭐ 同步多對多關聯
|
||||
$song->artists()->sync($this->selectedArtists ?? []);
|
||||
$song->categories()->sync($this->selectedCategories ?? []);
|
||||
$this->notification()->send([
|
||||
'icon' => 'success',
|
||||
'title' => '成功',
|
||||
'description' => '歌曲已更新',
|
||||
]);
|
||||
|
||||
}
|
||||
} else {
|
||||
$song = Song::create($this->fields);
|
||||
$this->notification()->send([
|
||||
'icon' => 'success',
|
||||
'title' => '成功',
|
||||
'description' => '歌曲已新增',
|
||||
]);
|
||||
if ($this->canCreate) {
|
||||
$song = Song::create($this->fields);
|
||||
// ⭐ 同步多對多關聯
|
||||
$song->artists()->sync($this->selectedArtists ?? []);
|
||||
$song->categories()->sync($this->selectedCategories ?? []);
|
||||
$this->notification()->send([
|
||||
'icon' => 'success',
|
||||
'title' => '成功',
|
||||
'description' => '歌曲已新增',
|
||||
]);
|
||||
}
|
||||
}
|
||||
// ⭐ 同步多對多關聯
|
||||
$song->artists()->sync($this->selectedArtists ?? []);
|
||||
$song->categories()->sync($this->selectedCategories ?? []);
|
||||
|
||||
$this->resetFields();
|
||||
$this->showModal = false;
|
||||
@ -122,12 +130,14 @@ class SongForm extends Component
|
||||
|
||||
public function deleteSong($id)
|
||||
{
|
||||
Song::findOrFail($id)->delete();
|
||||
$this->notification()->send([
|
||||
'icon' => 'success',
|
||||
'title' => '成功',
|
||||
'description' => '歌曲已刪除',
|
||||
]);
|
||||
if ($this->canDelect) {
|
||||
Song::findOrFail($id)->delete();
|
||||
$this->notification()->send([
|
||||
'icon' => 'success',
|
||||
'title' => '成功',
|
||||
'description' => '歌曲已刪除',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function resetFields()
|
||||
|
@ -98,7 +98,7 @@ class UserForm extends Component
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
if ($canCreate) {
|
||||
if ($this->canCreate) {
|
||||
$user = User::create($this->fields);
|
||||
$user->syncRoles($this->selectedRoles);
|
||||
$this->notification()->send([
|
||||
|
Loading…
x
Reference in New Issue
Block a user