Compare commits
No commits in common. "9721325bbb5141888b0b95018dedbb01d374846d" and "f395da76ec11077132c26b79e938adadcfb1cf9f" have entirely different histories.
9721325bbb
...
f395da76ec
@ -24,8 +24,8 @@ class RoomObserver
|
||||
*/
|
||||
public function updated(Room $room): void
|
||||
{
|
||||
// 如果有變動才記錄
|
||||
if ($this->hasChangesExcept($room, ['updated_at'])) {
|
||||
// 檢查是否有變更狀態
|
||||
if ($room->wasChanged()) {
|
||||
$this->createStatusLog($room);
|
||||
}
|
||||
if ($room->isDirty('status')) {
|
||||
@ -69,14 +69,6 @@ class RoomObserver
|
||||
);
|
||||
$this->createStatusLog($room,$message);
|
||||
}
|
||||
protected function hasChangesExcept($model, array $except = ['updated_at']): bool
|
||||
{
|
||||
$changes = $model->getChanges();
|
||||
foreach ($except as $key) {
|
||||
unset($changes[$key]);
|
||||
}
|
||||
return !empty($changes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 建立 RoomStatusLog
|
||||
|
@ -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::create('FavoriteSongs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('songNumber',20);
|
||||
$table->string('userPhone', 10);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('FavoriteSongs');
|
||||
}
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user