diff --git a/app/Http/Controllers/RoomControlController.php b/app/Http/Controllers/RoomControlController.php index f32b614..d89c12c 100644 --- a/app/Http/Controllers/RoomControlController.php +++ b/app/Http/Controllers/RoomControlController.php @@ -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 ]); } diff --git a/app/Livewire/Forms/RoomForm.php b/app/Livewire/Forms/RoomForm.php index f6307aa..fbd4fd2 100644 --- a/app/Livewire/Forms/RoomForm.php +++ b/app/Livewire/Forms/RoomForm.php @@ -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() diff --git a/app/Livewire/Tables/RoomTable.php b/app/Livewire/Tables/RoomTable.php index 1131d3d..fc7ef8b 100644 --- a/app/Livewire/Tables/RoomTable.php +++ b/app/Livewire/Tables/RoomTable.php @@ -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; diff --git a/app/Models/OtherSet.php b/app/Models/OtherSet.php new file mode 100644 index 0000000..60f3a2f --- /dev/null +++ b/app/Models/OtherSet.php @@ -0,0 +1,10 @@ +id(); + $table->string('name'); + $table->string('value'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('other_sets'); + } +}; diff --git a/database/seeders/OtherSetsTableSeeder.php b/database/seeders/OtherSetsTableSeeder.php new file mode 100644 index 0000000..fecef15 --- /dev/null +++ b/database/seeders/OtherSetsTableSeeder.php @@ -0,0 +1,33 @@ + '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, + ]); + } + } +} diff --git a/開發手冊.ini b/開發手冊.ini index 8fa77bf..d66e286 100644 --- a/開發手冊.ini +++ b/開發手冊.ini @@ -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