Workshop นี้เป็นส่วนหนึ่งของคอร์ส สอนทำระบบแจ้งซ่อมออนไลน์ Laravel
คอร์สเรียนออนไลน์ สอนทำระบบแจ้งซ่อม ราคา 999 บาท จะได้ Template ตั้งต้น สอนทำเต็มระบบ
- https://mailtrap.io/
- สมัคร mailtrap ให้เรียบร้อย
- ตั้งค่า .env
- php artisan make:mail RepairAssigned
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 |
<?php namespace App\Mail; use Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; class RepairAssigned extends Mailable { use Queueable, SerializesModels; public $repairDetails; public function __construct($repairDetails) { $this->repairDetails = $repairDetails; } public function build() { return $this->subject('Repair Assignment Notification') ->view('mail.repair_assigned') ->with([ 'repairDetails' => $this->repairDetails ]); } } |
- repair_assigned.blade.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<h1>Repair Assignment Notification</h1> <p>รายละเอียดใบแจ้งซ่อม</p> <p><strong>Repair ID:</strong> {{ $repairDetails->id }}</p> <p><strong>ประเภทอุปกรณ์:</strong> {{ $repairDetails->eq_name }}</p> <p><strong>ชื่ออุปกรณ์:</strong> {{ $repairDetails->r_name }}</p> <p><strong>หมายเลขเครื่อง:</strong> {{ $repairDetails->r_serialnumber }}</p> <p><strong>สาเหตุ:</strong> {{ $repairDetails->r_detail }}</p> <p><strong>ผู้แจ้งซ่อม:</strong> {{ $repairDetails->firstname }} {{ $repairDetails->lastname }}</p> <p><strong>สถานที่แจ้งซ่อม:</strong> {{ $repairDetails->build_name }} ชั้น {{ $repairDetails->floor }} ห้อง {{ $repairDetails->room }}</p> <p><strong>หัวหน้าที่มอบหมาย:</strong> {{ $repairDetails->head_firstname }} {{ $repairDetails->head_lastname }}</p> <p><strong>ช่างที่ได้รับมอบหมาย:</strong> {{ $repairDetails->technician_firstname }} {{ $repairDetails->technician_lastname }}</p> <p><strong>สถานะ:</strong> {{ $repairDetails->s_status }}</p> <p><strong>วันที่แจ้งซ่อม:</strong> {{ $repairDetails->r_date }}</p> |
-
function assignWork update
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 |
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(); $repairDetails = Repair::select( 'repair.*', 'users.firstname', 'users.lastname', 'equipment.eq_name', 'building.build_name', 'status.s_status', 'technician.firstname AS technician_firstname', 'technician.lastname AS technician_lastname', 'head.firstname AS head_firstname', 'head.lastname AS head_lastname' ) ->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') ->leftJoin('users AS technician', 'repair.technician_id', '=', 'technician.id') ->leftJoin('users AS head', 'repair.head_id', '=', 'head.id') ->where('repair.id', '=', $repairId) ->first(); // Send email with detailed data Mail::to("waiyawootlove@gmail.com")->send(new RepairAssigned($repairDetails)); return redirect(url('managers/repair'))->with('success', 'มอบหมายช่างเรียบร้อยแล้ว!'); } catch (\Exception $e) { return redirect()->back()->with('error', 'เกิดข้อผิดพลาดในการมอบหมายงาน: ' . $e->getMessage()); } |

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