Files
star-cloud/app/Http/Controllers/Admin/MachineController.php

144 lines
3.6 KiB
PHP
Raw Normal View History

2025-11-21 17:15:27 +08:00
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\Machine;
use Illuminate\Http\Request;
class MachineController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
$machines = Machine::latest()->paginate(10);
return view('admin.machines.index', compact('machines'));
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('admin.machines.create');
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
$validated = $request->validate([
'name' => 'required|string|max:255',
'location' => 'nullable|string|max:255',
'status' => 'required|in:online,offline,error',
'temperature' => 'nullable|numeric',
'firmware_version' => 'nullable|string|max:50',
]);
Machine::create($validated);
return redirect()->route('admin.machines.index')
->with('success', '機台建立成功');
}
/**
* Display the specified resource.
*/
public function show(Machine $machine)
{
return view('admin.machines.show', compact('machine'));
}
/**
* Show the form for editing the specified resource.
*/
public function edit(Machine $machine)
{
return view('admin.machines.edit', compact('machine'));
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, Machine $machine)
{
$validated = $request->validate([
'name' => 'required|string|max:255',
'location' => 'nullable|string|max:255',
'status' => 'required|in:online,offline,error',
'temperature' => 'nullable|numeric',
'firmware_version' => 'nullable|string|max:50',
]);
$machine->update($validated);
return redirect()->route('admin.machines.index')
->with('success', '機台更新成功');
}
/**
* Remove the specified resource from storage.
*/
public function destroy(Machine $machine)
{
$machine->delete();
return redirect()->route('admin.machines.index')
->with('success', '機台已刪除');
}
// 機台日誌
public function logs()
{
return view('admin.placeholder', [
'title' => '機台日誌',
'description' => '機台操作歷史紀錄回溯',
'features' => [
'操作時間戳記',
'事件類型分類',
'操作人員記錄',
'詳細描述查詢',
]
]);
}
// 機台權限
public function permissions()
{
return view('admin.placeholder', [
'title' => '機台權限',
'description' => '機台存取權限控管',
]);
}
// 機台稼動率
public function utilization()
{
return view('admin.placeholder', [
'title' => '機台稼動率',
'description' => '機台運行效率分析',
]);
}
// 效期管理
public function expiry()
{
return view('admin.placeholder', [
'title' => '效期管理',
'description' => '商品效期與貨道出貨控制',
]);
}
// 維修管理單
public function maintenance()
{
return view('admin.placeholder', [
'title' => '維修管理單',
'description' => '機台維修工單系統',
]);
}
2025-11-21 17:15:27 +08:00
}