202508131406

加入 OtherSet 放相關設定
調整 心跳 回傳 OtherSet 資料
修正 包廂移除問題
修正 包廂無法新增問題
This commit is contained in:
allen.yan 2025-08-13 14:09:03 +08:00
parent 1c0853451b
commit 6c30932855
7 changed files with 87 additions and 6 deletions

View File

@ -14,6 +14,7 @@ use App\Models\User;
use App\Models\Branch;
use App\Models\Room;
use App\Models\MachineStatus;
use App\Models\OtherSet;
use App\Enums\RoomStatus;
use App\Http\Responses\ApiResponse;
use App\Http\Resources\RoomResource;
@ -94,9 +95,11 @@ class RoomControlController extends Controller
}
$branch = Branch::first();
$otherSet = OtherSet::pluck('value', 'name')->toArray();
return ApiResponse::success([
'token' => $token,
'branch_name' => $branch->name,
'other_set' => $otherSet
]);
}

View File

@ -8,6 +8,7 @@ use Illuminate\Support\Facades\Auth;
use Livewire\Component;
use WireUi\Traits\WireUiActions;
use App\Models\Branch;
use App\Models\Room;
use App\Enums\RoomType;
@ -22,6 +23,7 @@ class RoomForm extends Component
public bool $canDelect;
public bool $showModal = false;
public int $branchId ;
public ?int $roomId = null;
public array $typeOptions =[];
@ -35,6 +37,8 @@ class RoomForm extends Component
public function mount()
{
$branch = Branch::first();
$this->branchId=$branch->id ?? 0;
$this->typeOptions = collect(RoomType::cases())->map(fn ($type) => [
'name' => $type->labels(),
'value' => $type->value,
@ -75,6 +79,7 @@ class RoomForm extends Component
} else {
if ($this->canCreate) {
$room = Room::create([
'branch_id' =>$this->branchId,
'floor' => $this->fields['floor'],
'type' => $this->fields['type'],
'name' => $this->fields['name'],
@ -92,14 +97,14 @@ class RoomForm extends Component
$this->dispatch('pg:eventRefresh-room-table');
}
public function deleteBranch($id)
public function deleteRoom($id)
{
if ($this->canDelect) {
Room::findOrFail($id)->delete();
$this->notification()->send([
'icon' => 'success',
'title' => '成功',
'description' => '分店已刪除',
'description' => '包廂已刪除',
]);
$this->dispatch('pg:eventRefresh-room-table');
@ -115,7 +120,6 @@ class RoomForm extends Component
$this->fields[$key] = '';
}
}
$this->branchId = null;
}
public function render()

View File

@ -103,6 +103,7 @@ final class RoomTable extends PowerGridComponent
})
->add('name')
->add('internal_ip')
->add('port')
->add('is_online', fn ($model) => $model->is_online===true ? '在線' : '斷線')
->add('status_str',function (Room $model){
return $model->status->labelPowergridFilter();
@ -130,7 +131,8 @@ final class RoomTable extends PowerGridComponent
fallback: 'N/A',
saveOnMouseOut: true
);
$column[]=Column::make(__('rooms.isOnline'), 'internal_ip');
$column[]=Column::make(__('rooms.internal_ip'), 'internal_ip');
$column[]=Column::make(__('rooms.internal_port'), 'port');
$column[]=Column::make(__('rooms.isOnline'), 'is_online');
$column[]=Column::make(__('rooms.status'), 'status_str','room.status')->sortable()->searchable()->hidden(true, false);
$column[]=Column::make(__('rooms.started_at'), 'str_started_at', 'started_at')->sortable()->hidden(true, false);
@ -188,7 +190,7 @@ final class RoomTable extends PowerGridComponent
}
private function noUpdated($id,$field,$value){
dd($id,$field,$value);
//dd($id,$field,$value);
$room = Room::find($id);
if ($room) {
$room->{$field} = $value;

10
app/Models/OtherSet.php Normal file
View File

@ -0,0 +1,10 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class OtherSet extends Model
{
protected $fillable = ['name', 'value'];
}

View File

@ -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('other_sets', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('value');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('other_sets');
}
};

View File

@ -0,0 +1,33 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\OtherSet;
class OtherSetsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$txs = [
'DBServer' => '192.168.11.4',
'DBPort' => '3306',
'DBUser' => 'KaraokeKingpin',
'DBPassword' => 'ESM7yTPMnavFmbBH',
'Database' => 'KaraokeKingpin',
'IsCursor' => 'false'
];
foreach ($txs as $name => $value) {
OtherSet::create([
'name' => $name,
'value' => $value,
]);
}
}
}

View File

@ -42,7 +42,7 @@ valet paths
php artisan db:seed --class=PermissionTableSeeder
php artisan db:seed --class=CreateAdminUserSeeder
php artisan db:seed --class=OtherSetsTableSeeder
//console.log();
php artisan route:list
php artisan config:clear