202508131406
加入 OtherSet 放相關設定 調整 心跳 回傳 OtherSet 資料 修正 包廂移除問題 修正 包廂無法新增問題
This commit is contained in:
parent
1c0853451b
commit
6c30932855
@ -14,6 +14,7 @@ use App\Models\User;
|
|||||||
use App\Models\Branch;
|
use App\Models\Branch;
|
||||||
use App\Models\Room;
|
use App\Models\Room;
|
||||||
use App\Models\MachineStatus;
|
use App\Models\MachineStatus;
|
||||||
|
use App\Models\OtherSet;
|
||||||
use App\Enums\RoomStatus;
|
use App\Enums\RoomStatus;
|
||||||
use App\Http\Responses\ApiResponse;
|
use App\Http\Responses\ApiResponse;
|
||||||
use App\Http\Resources\RoomResource;
|
use App\Http\Resources\RoomResource;
|
||||||
@ -94,9 +95,11 @@ class RoomControlController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$branch = Branch::first();
|
$branch = Branch::first();
|
||||||
|
$otherSet = OtherSet::pluck('value', 'name')->toArray();
|
||||||
return ApiResponse::success([
|
return ApiResponse::success([
|
||||||
'token' => $token,
|
'token' => $token,
|
||||||
'branch_name' => $branch->name,
|
'branch_name' => $branch->name,
|
||||||
|
'other_set' => $otherSet
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use WireUi\Traits\WireUiActions;
|
use WireUi\Traits\WireUiActions;
|
||||||
|
|
||||||
|
use App\Models\Branch;
|
||||||
use App\Models\Room;
|
use App\Models\Room;
|
||||||
use App\Enums\RoomType;
|
use App\Enums\RoomType;
|
||||||
|
|
||||||
@ -22,6 +23,7 @@ class RoomForm extends Component
|
|||||||
public bool $canDelect;
|
public bool $canDelect;
|
||||||
|
|
||||||
public bool $showModal = false;
|
public bool $showModal = false;
|
||||||
|
public int $branchId ;
|
||||||
public ?int $roomId = null;
|
public ?int $roomId = null;
|
||||||
|
|
||||||
public array $typeOptions =[];
|
public array $typeOptions =[];
|
||||||
@ -35,6 +37,8 @@ class RoomForm extends Component
|
|||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
|
$branch = Branch::first();
|
||||||
|
$this->branchId=$branch->id ?? 0;
|
||||||
$this->typeOptions = collect(RoomType::cases())->map(fn ($type) => [
|
$this->typeOptions = collect(RoomType::cases())->map(fn ($type) => [
|
||||||
'name' => $type->labels(),
|
'name' => $type->labels(),
|
||||||
'value' => $type->value,
|
'value' => $type->value,
|
||||||
@ -75,6 +79,7 @@ class RoomForm extends Component
|
|||||||
} else {
|
} else {
|
||||||
if ($this->canCreate) {
|
if ($this->canCreate) {
|
||||||
$room = Room::create([
|
$room = Room::create([
|
||||||
|
'branch_id' =>$this->branchId,
|
||||||
'floor' => $this->fields['floor'],
|
'floor' => $this->fields['floor'],
|
||||||
'type' => $this->fields['type'],
|
'type' => $this->fields['type'],
|
||||||
'name' => $this->fields['name'],
|
'name' => $this->fields['name'],
|
||||||
@ -92,14 +97,14 @@ class RoomForm extends Component
|
|||||||
$this->dispatch('pg:eventRefresh-room-table');
|
$this->dispatch('pg:eventRefresh-room-table');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteBranch($id)
|
public function deleteRoom($id)
|
||||||
{
|
{
|
||||||
if ($this->canDelect) {
|
if ($this->canDelect) {
|
||||||
Room::findOrFail($id)->delete();
|
Room::findOrFail($id)->delete();
|
||||||
$this->notification()->send([
|
$this->notification()->send([
|
||||||
'icon' => 'success',
|
'icon' => 'success',
|
||||||
'title' => '成功',
|
'title' => '成功',
|
||||||
'description' => '分店已刪除',
|
'description' => '包廂已刪除',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->dispatch('pg:eventRefresh-room-table');
|
$this->dispatch('pg:eventRefresh-room-table');
|
||||||
@ -115,7 +120,6 @@ class RoomForm extends Component
|
|||||||
$this->fields[$key] = '';
|
$this->fields[$key] = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->branchId = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
|
@ -103,6 +103,7 @@ final class RoomTable extends PowerGridComponent
|
|||||||
})
|
})
|
||||||
->add('name')
|
->add('name')
|
||||||
->add('internal_ip')
|
->add('internal_ip')
|
||||||
|
->add('port')
|
||||||
->add('is_online', fn ($model) => $model->is_online===true ? '在線' : '斷線')
|
->add('is_online', fn ($model) => $model->is_online===true ? '在線' : '斷線')
|
||||||
->add('status_str',function (Room $model){
|
->add('status_str',function (Room $model){
|
||||||
return $model->status->labelPowergridFilter();
|
return $model->status->labelPowergridFilter();
|
||||||
@ -130,7 +131,8 @@ final class RoomTable extends PowerGridComponent
|
|||||||
fallback: 'N/A',
|
fallback: 'N/A',
|
||||||
saveOnMouseOut: true
|
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.isOnline'), 'is_online');
|
||||||
$column[]=Column::make(__('rooms.status'), 'status_str','room.status')->sortable()->searchable()->hidden(true, false);
|
$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);
|
$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){
|
private function noUpdated($id,$field,$value){
|
||||||
dd($id,$field,$value);
|
//dd($id,$field,$value);
|
||||||
$room = Room::find($id);
|
$room = Room::find($id);
|
||||||
if ($room) {
|
if ($room) {
|
||||||
$room->{$field} = $value;
|
$room->{$field} = $value;
|
||||||
|
10
app/Models/OtherSet.php
Normal file
10
app/Models/OtherSet.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class OtherSet extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = ['name', 'value'];
|
||||||
|
}
|
@ -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');
|
||||||
|
}
|
||||||
|
};
|
33
database/seeders/OtherSetsTableSeeder.php
Normal file
33
database/seeders/OtherSetsTableSeeder.php
Normal 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,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
2
開發手冊.ini
2
開發手冊.ini
@ -42,7 +42,7 @@ valet paths
|
|||||||
|
|
||||||
php artisan db:seed --class=PermissionTableSeeder
|
php artisan db:seed --class=PermissionTableSeeder
|
||||||
php artisan db:seed --class=CreateAdminUserSeeder
|
php artisan db:seed --class=CreateAdminUserSeeder
|
||||||
|
php artisan db:seed --class=OtherSetsTableSeeder
|
||||||
//console.log();
|
//console.log();
|
||||||
php artisan route:list
|
php artisan route:list
|
||||||
php artisan config:clear
|
php artisan config:clear
|
||||||
|
Loading…
x
Reference in New Issue
Block a user