Workshop นี้เป็นส่วนหนึ่งของคอร์ส สอนทำระบบแจ้งซ่อมออนไลน์ Laravel
คอร์สเรียนออนไลน์ สอนทำระบบแจ้งซ่อม ราคา 999 บาท จะได้ Template ตั้งต้น สอนทำเต็มระบบ
- repair_detail.blade.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
@extends('layouts.master') @section('title', 'Repair Detail') @section('content') <style> .light-blue-header { background-color: #E0F7FA; /* Light blue background */ padding: 10px; border-radius: 5px; /* Optional: Rounded corners */ } </style> <div class="col-md-12"> <div class="card"> <div class="card-header light-blue-header"> <h4>รายละเอียดการแจ้งซ่อม</h4> </div> <div class="card-body"> <p><strong>ใบแจ้งซ่อม:</strong> {{ $data->id }}</p> <p><strong>ประเภทอุปกรณ์:</strong> {{ $data->eq_name }}</p> <p><strong>ชื่ออุปกรณ์:</strong> {{ $data->r_name }}</p> <p><strong>ผู้แจ้งซ่อม:</strong> {{ $data->firstname }} {{ $data->lastname }}</p> <p><strong>หมายเลขเครื่อง:</strong> {{ $data->r_serialnumber }}</p> <p><strong>อาการ/สาเหตุ:</strong> {{ $data->r_detail }}</p> <p><strong>สถานที่แจ้งซ่อม:</strong> {{ $data->build_name }}, Floor: {{ $data->floor }}, Room: {{ $data->room }}</p> <p><strong>สถานะ:</strong> {{ $data->s_status }}</p> <p><strong>วันที่แจ้งซ่อม:</strong> {{ \Carbon\Carbon::parse($data->r_date)->format('d/m/Y') }}</p> <p><strong>ช่างผู้ดำเนินการซ่อม:</strong> </p> <a href="{{ url('managers/repair') }}" class="btn btn-primary">กลับหน้ารายการ</a> <button class="btn btn-success" onclick="window.print()">พิมพ์</button> </div> </div> </div> @endsection |
- RepairController.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
public function show_detail($id) { $data = Repair::select( 'repair.*', 'users.firstname', 'users.lastname', 'equipment.eq_name', 'building.build_name', 'status.s_status' ) ->join('users', 'repair.u_id', '=', 'users.id') ->join('equipment', 'repair.eq_id', '=', 'equipment.id') ->join('building', 'repair.build_id', '=', 'building.id') ->join('status', 'repair.s_id', '=', 'status.id') ->where('repair.id', $id) ->firstOrFail(); return view('managers/repair_detail', compact('data')); } |
- repair_assign.blade.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
@extends('layouts.master') @section('title') Manager @endsection @section('content') @component('common-components.breadcrumb') @slot('pagetitle') Manager @endslot @slot('title') Technician List @endslot @endcomponent <div class="row"> @foreach ($technicians as $technician) <div class="col-xl-3 col-sm-6"> <form action="{{ url('managers/assign_work') }}" method="POST"> @csrf <div class="card text-center"> <div class="card-body"> <div class="dropdown float-end"> <a class="text-body dropdown-toggle font-size-16" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true"> <i class="uil uil-ellipsis-h"></i> </a> </div> <div class="clearfix"></div> <div class="mb-4"> @if ($technician->avatar) <img src="{{ url('storage/images/'.$technician->image) }}" alt="" class="avatar-lg rounded-circle img-thumbnail"> @else <img src="{{ url('storage/images/'.$technician->image) }}" alt="" class="avatar-lg rounded-circle img-thumbnail"> @endif </div> <h5 class="font-size-16 mb-1"><a href="#" class="text-reset">{{ $technician->firstname }} {{ $technician->lastname }}</a></h5> <p class="text-muted mb-1">ตำแหน่ง {{ $technician->position_name }}</p> <p class="text-muted mb-1">แผนก {{ $technician->dep_name }}</p> </div> <div class="btn-group" role="group"> <input type="hidden" name="repair_id" value="{{ $repair_id }}"> <input type="hidden" name="technician_id" value="{{ $technician->id }}"> <button type="submit" class="btn btn-outline-light text-truncate assign-btn" data-technician-id="{{ $technician->id }}"> <i class="uil-file-check-alt"></i> มอบงาน </button> <button type="button" class="btn btn-outline-light text-truncate"> <i class="uil-calender"></i> ดูตารางงาน</button> </div> </div> </form> </div> @endforeach </div> @endsection |
- repair_edit.blade.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
@extends('layouts.master') @section('title') @lang('Repair') @endsection @section('content') @component('common-components.breadcrumb') @slot('pagetitle') Manager @endslot @slot('title') แบบฟอร์มแจ้งซ่อม @endslot @endcomponent <style> .form-control { border: 1px solid rgba(0, 0, 0, 0.073); } </style> <div class="row"> <div class="col-lg-12"> <div class="card"> <div class="card-body"> <form action="{{ url('managers/repair_edit', $repair->id) }}" method="POST"> @csrf <!-- Full Name (Read-Only) --> <div class="row mb-3"> <div class="col-md-6"> <label for="full_name" class="form-label">ผู้แจ้งซ่อม</label> <input type="text" class="form-control" id="full_name" name="full_name" value="{{ $fullName }}" readonly> </div> </div> <!-- Equipment Fields --> <div class="row mb-3"> <div class="col-md-3"> <label for="eq_id" class="form-label">ประเภทอุปกรณ์</label> <select class="form-select" id="eq_id" name="eq_id" required> <option value="" disabled>เลือกอุปกรณ์</option> @foreach($equipment as $eq) <option value="{{ $eq->id }}" {{ $eq->id == $repair->eq_id ? 'selected' : '' }}> {{ $eq->eq_name }} </option> @endforeach </select> </div> <div class="col-md-6"> <label for="r_name" class="form-label">ชื่ออุปกรณ์</label> <input type="text" class="form-control" id="r_name" name="r_name" value="{{ $repair->r_name }}" required> </div> <div class="col-md-3"> <label for="r_serialnumber" class="form-label">หมายเลขเครื่อง</label> <input type="text" class="form-control" id="r_serialnumber" name="r_serialnumber" value="{{ $repair->r_serialnumber }}" required> </div> </div> <!-- Additional Fields --> <div class="row mb-3"> <div class="col-md-4"> <label for="r_detail" class="form-label">อาการ/สาเหตุ</label> <textarea class="form-control" id="r_detail" name="r_detail" rows="3" required>{{ $repair->r_detail }}</textarea> </div> <div class="col-md-3"> <label for="build_id" class="form-label">อาคาร/ตึก</label> <select class="form-select" id="build_id" name="build_id" required> <option value="" disabled>เลือกอาคาร/ตึก</option> @foreach($buildings as $building) <option value="{{ $building->id }}" {{ $building->id == $repair->build_id ? 'selected' : '' }}> {{ $building->build_name }} </option> @endforeach </select> </div> <div class="col-md-2"> <label for="floor" class="form-label">ชั้น</label> <input type="text" class="form-control" id="floor" name="floor" value="{{ $repair->floor }}"> </div> <div class="col-md-2"> <label for="room" class="form-label">ห้อง</label> <input type="text" class="form-control" id="room" name="room" value="{{ $repair->room }}"> </div> </div> <!-- Submit Button --> <div class="text-end"> <button type="submit" class="btn btn-success">แก้ไขข้อมูล</button> </div> </form> </div> </div> </div> </div> <!-- end row --> @endsection @section('script') <script> // Optional JavaScript for form enhancements can go here. </script> @endsection |
-
assign & assign_work
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
public function assign($id) { $technicians = User::select('users.*', 'position.position_name', 'department.dep_name', 'user_level.level_name') ->join('position', 'users.p_id', '=', 'position.id') ->join('department', 'users.dep_id', '=', 'department.id') ->join('user_level', 'users.level_id', '=', 'user_level.id') ->where('user_level.level_name', '=', 'technician') ->get(); $repair_id = $id; return view('managers/repair_assign', compact('technicians', 'repair_id')); } public function assignWork(Request $request) { try { $technicianId = $request->input('technician_id'); $repairId = $request->input('repair_id'); $repair = Repair::findOrFail($repairId); $repair->technician_id = $technicianId; $repair->s_id = 2; $repair->head_id = Auth::id(); $repair->save(); return redirect(url('managers/repair'))->with('success', 'มอบหมายช่างเรียบร้อยแล้ว!'); } catch (\Exception $e) { return redirect()->back()->with('error', 'เกิดข้อผิดพลาดในการมอบหมายงาน: ' . $e->getMessage()); } } |
- ManagerController.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
public function edit($id) { $repair = Repair::findOrFail($id); $equipment = Equipment::all(); $buildings = Building::all(); $user = User::findOrFail($repair->u_id); $fullName = $user->firstname . ' ' . $user->lastname; return view('managers.repair_edit', compact('repair', 'equipment', 'buildings', 'fullName')); } public function update(Request $request, $id) { $repair = Repair::findOrFail($id); $repair->update([ 'eq_id' => $request->eq_id, 'r_name' => $request->r_name, 'r_serialnumber' => $request->r_serialnumber, 'r_detail' => $request->r_detail, 'build_id' => $request->build_id, 'floor' => $request->floor, 'room' => $request->room, ]); return redirect(url('managers/repair'))->with('success', 'แก้ไขข้อมูลเรียบร้อยแล้ว'); } public function del(Request $request) { $repair = Repair::findOrFail($request->id); $repair->delete(); return response()->json([ 'mgs' => 'ข้อมูลถูกลบเรียบร้อยแล้ว', 'icon' => 'success' ]); } |

สนใจจ้างพัฒนาระบบ เขียนระบบ
ทำเว็บไซต์ รับสอนเขียนโปรแกรม
inbox มาที่เพจ หรือติดต่อ 098-373-8651
ช่องทางการชำระเงิน
เงินสด หรือ e-banking
ธนาคารกสิกรไทย
เลขบัญชี : 0951168564
ชื่อบัญชี : นายวัยวุฒิ ชุมเมืองปัก