Workshop นี้เป็นส่วนหนึ่งของคอร์สสอนทำระบบ POS Laravel + PostgreSQL + AdminLTE
- ระบบจัดการสาขา เป็นฟีเจอร์สำคัญที่ช่วยให้ผู้ดูแลระบบสามารถบริหารข้อมูลสาขาขององค์กรได้อย่างมีประสิทธิภาพ โดยสามารถเพิ่ม แก้ไข ตรวจสอบสถานะ และลบข้อมูลสาขาได้อย่างสะดวกผ่านหน้า Admin
-
การสร้างโครงสร้างฐานข้อมูลสาขา
- ขั้นตอนแรกของระบบ คือการสร้างตาราง
branchesเพื่อเก็บข้อมูลสาขาภายในฐานข้อมูล
- ขั้นตอนแรกของระบบ คือการสร้างตาราง
- ตั้งชื่อไฟล์ create_branches_table.php แล้วรันคำสั่ง php artisan migrate
|
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 |
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { public function up() { Schema::create('branches', function (Blueprint $table) { $table->id(); $table->string('code')->unique(); $table->string('name'); $table->text('address')->nullable(); $table->string('subdistrict')->nullable(); $table->string('district')->nullable(); $table->string('province')->nullable(); $table->string('zipcode', 10)->nullable(); $table->boolean('status')->default(1); $table->unsignedBigInteger('created_by')->nullable(); $table->unsignedBigInteger('updated_by')->nullable(); $table->timestamps(); $table->foreign('created_by')->references('id')->on('users')->onDelete('set null'); $table->foreign('updated_by')->references('id')->on('users')->onDelete('set null'); }); } public function down() { Schema::dropIfExists('branches'); } }; |
-
ข้อมูลที่ระบบรองรับมีดังนี้
-
รหัสสาขา (code)
-
ชื่อสาขา (name)
-
ที่อยู่แบบละเอียด (address)
-
ตำบล / อำเภอ / จังหวัด
-
รหัสไปรษณีย์
-
สถานะ (เปิดใช้งาน / ปิดใช้งาน)
-
ผู้สร้างข้อมูล และผู้แก้ไขล่าสุด
✅ ตารางนี้ถูกออกแบบให้รองรับหลายสาขา และสามารถตรวจสอบย้อนกลับได้ว่าใครเป็นผู้ดำเนินการ
-
-
การสร้าง Model สำหรับสาขา
- หลังจากสร้างตารางแล้ว ระบบจะมีการสร้าง Model ชื่อ Branch.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 |
<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class Branch extends Model { use HasFactory; protected $fillable = [ 'code', 'name', 'address', 'subdistrict', 'district', 'province', 'zipcode', 'status', 'created_by', 'updated_by' ]; protected $casts = [ 'status' => 'boolean', ]; public function creator() { return $this->belongsTo(User::class, 'created_by'); } public function updater() { return $this->belongsTo(User::class, 'updated_by'); } } |
-
Model นี้ทำหน้าที่เชื่อมต่อกับฐานข้อมูลและช่วยให้สามารถจัดการข้อมูลสาขาได้ง่าย เช่น
-
บันทึกข้อมูลใหม่
-
แก้ไขข้อมูลเดิม
-
ลบข้อมูล
-
แสดงข้อมูลทั้งหมด
นอกจากนี้ยังรองรับการเชื่อมโยงกับ User ผ่านฟิลด์
-
created_by → ผู้สร้าง
-
updated_by → ผู้แก้ไขล่าสุด
✅ ทำให้ระบบสามารถติดตามประวัติการจัดการข้อมูลได้อย่างชัดเจน
-
-
การจัดการข้อมูลผ่าน BranchController
-
ระบบจัดการสาขาทำงานผ่าน Controller ซึ่งเป็นตัวกลางระหว่างหน้าเว็บและฐานข้อมูล Controller นี้ครอบคลุมฟังก์ชันหลักทั้งหมด ได้แก่
- แสดงรายการสาขาทั้งหมด
- เพิ่มสาขาใหม่
- แก้ไขข้อมูลสาขา
- ลบข้อมูลสาขา
-
|
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 |
<?php namespace App\Http\Controllers; use App\Http\Controllers\Controller; use App\Models\Branch; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; class BranchController extends Controller { public function index() { $branches = Branch::orderBy('created_at', 'desc')->paginate(10); return view('admins.branch.index', compact('branches')); } public function create() { return view('admins.branch.create'); } public function store(Request $request) { $validated = $request->validate([ 'code' => 'required|unique:branches,code', 'name' => 'required|string|max:255', 'address' => 'nullable|string', 'subdistrict' => 'nullable|string|max:255', 'district' => 'nullable|string|max:255', 'province' => 'nullable|string|max:255', 'zipcode' => 'nullable|string|max:10', 'status' => 'required|boolean', ]); $validated['created_by'] = Auth::id(); Branch::create($validated); $notification = array( 'message' => 'เพิ่มสาขาสำเร็จ', 'alert-type' => 'success' ); return redirect()->route('admin.branches.index')->with($notification); } public function edit(Branch $branch) { return view('admins.branch.edit', compact('branch')); } public function update(Request $request, Branch $branch) { $validated = $request->validate([ 'code' => 'required|unique:branches,code,' . $branch->id, 'name' => 'required|string|max:255', 'address' => 'nullable|string', 'subdistrict' => 'nullable|string|max:255', 'district' => 'nullable|string|max:255', 'province' => 'nullable|string|max:255', 'zipcode' => 'nullable|string|max:10', 'status' => 'required|boolean', ]); $validated['updated_by'] = Auth::id(); $branch->update($validated); $notification = array( 'message' => 'แก้ไขสาขาสำเร็จ', 'alert-type' => 'success' ); return redirect()->route('admin.branches.index')->with($notification); } public function destroy(Branch $branch) { $branch->delete(); $notification = array( 'message' => 'ลบสาขาสำเร็จ', 'alert-type' => 'success' ); return redirect()->route('admin.branches.index')->with($notification); } } |
-
Routes สำหรับระบบจัดการสาขา (Admin Branch Routes)
- โค้ดชุดนี้ใช้สำหรับสร้างเส้นทาง (Route) ใน Laravel เพื่อให้ผู้ดูแลระบบสามารถเข้าไปจัดการ “สาขา” ได้ เช่น
- ดูรายการสาขา
- เพิ่มสาขาใหม่
- แก้ไขสาขา
- ลบสาขา
- โดยทั้งหมดนี้ถูกจัดการผ่าน BranchController
- โค้ดชุดนี้ใช้สำหรับสร้างเส้นทาง (Route) ใน Laravel เพื่อให้ผู้ดูแลระบบสามารถเข้าไปจัดการ “สาขา” ได้ เช่น
|
1 2 3 4 |
// routes for admin Route::prefix('admin')->name('admin.')->middleware('auth')->group(function () { Route::resource('branches', BranchController::class); }); |
- Route Prefix:
adminจะเพิ่มคำว่าadminนำหน้าทุก URL ภายในกลุ่มนี้ - Middleware
authRoute ทั้งหมดนี้จะถูกป้องกันด้วยระบบ Login - Group Routes รวม Route หลายตัวให้อยู่ภายใต้กฎเดียวกัน เช่น prefix admin middleware auth name admin.
- Resource Route สำหรับ BranchController Laravel จะสร้าง Route CRUD ให้ครบอัตโนมัติทันที

-
เมนูสำหรับจัดการสาขา (Branch Menu)
|
1 2 3 4 5 6 7 8 9 |
<li class="nav-header">ข้อมูลบริษัท</li> <li class="nav-item"> <a href="{{ route('admin.branches.index') }}" class="nav-link {{ request()->routeIs('admin.branches.*') ? 'active' : '' }}"> <i class="nav-icon fas fa-store"></i> <p> สาขา </p> </a> </li> |
-
อธิบายโค้ด jquery.Thailand.js (กรอกที่อยู่ไทยอัตโนมัติ)
- โหลดไฟล์ CSS ของ jquery.Thailand
- โหลด Library ที่จำเป็น (Dependencies)
- โหลดไฟล์หลัก jquery.Thailand.js
- เริ่มการทำงานเมื่อหน้าเว็บโหลดเสร็จ เรียกใช้ระบบ Auto Address Thailand
- กำหนดฐานข้อมูลที่อยู่ไทย
-
ปลั๊กอินใช้ฐานข้อมูล JSON ที่รวมข้อมูล
-
ตำบล
-
อำเภอ
-
จังหวัด
-
รหัสไปรษณีย์
✅ ดึงข้อมูลจาก URL นี้เพื่อนำมาใช้เติมอัตโนมัติ
-
-
- ระบุช่อง Input ที่ต้องการให้ระบบเติมข้อมูล
-
ตัวอย่างการใช้งานในระบบสาขา
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<!-- Thailand --> <link rel="stylesheet" href="https://earthchie.github.io/jquery.Thailand.js/jquery.Thailand.js/dist/jquery.Thailand.min.css"> <!-- jquery.Thailand. --> <script type="text/javascript" src="https://earthchie.github.io/jquery.Thailand.js/jquery.Thailand.js/dependencies/JQL.min.js"></script> <script type="text/javascript" src="https://earthchie.github.io/jquery.Thailand.js/jquery.Thailand.js/dependencies/typeahead.bundle.js"></script> <script type="text/javascript" src="https://earthchie.github.io/jquery.Thailand.js/jquery.Thailand.js/dist/jquery.Thailand.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $.Thailand({ database: 'https://earthchie.github.io/jquery.Thailand.js/jquery.Thailand.js/database/db.json', $district: $('#subdistrict'), $amphoe: $('#district'), $province: $('#province'), $zipcode: $('#zipcode'), onDataFill: function(data) { console.log('ข้อมูลที่เลือก:', data); } }); }); </script> |
-
DataTables & Plugins ใน Laravel
|
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 |
<!-- DataTables --> <link rel="stylesheet" href="{{ asset('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css') }}"> <link rel="stylesheet" href="{{ asset('plugins/datatables-responsive/css/responsive.bootstrap4.min.css') }}"> <!-- DataTables & Plugins --> <script src="{{ URL::asset('plugins/datatables/jquery.dataTables.min.js')}}"></script> <script src="{{ URL::asset('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js')}}"></script> <script src="{{ URL::asset('plugins/datatables-responsive/js/dataTables.responsive.min.js')}}"></script> <script src="{{ URL::asset('plugins/datatables-responsive/js/responsive.bootstrap4.min.js')}}"></script> <script src="{{ URL::asset('plugins/datatables-buttons/js/dataTables.buttons.min.js')}}"></script> <script src="{{ URL::asset('plugins/datatables-buttons/js/buttons.bootstrap4.min.js')}}"></script> <script> $(document).ready(function() { $('#data-table').DataTable({ language: { "sEmptyTable": "ไม่พบข้อมูลในตาราง", "sInfo": "แสดง _START_ ถึง _END_ จาก _TOTAL_ รายการ", "sInfoEmpty": "แสดง 0 ถึง 0 จาก 0 รายการ", "sInfoFiltered": "(กรองจากทั้งหมด _MAX_ รายการ)", "sInfoPostFix": "", "sInfoThousands": ",", "sLengthMenu": "แสดง _MENU_ รายการ", "sLoadingRecords": "กำลังโหลด...", "sProcessing": "กำลังประมวลผล...", "sSearch": "ค้นหา:", "sZeroRecords": "ไม่พบรายการที่ค้นหา", "oPaginate": { "sFirst": "หน้าแรก", "sLast": "หน้าสุดท้าย", "sNext": "ถัดไป", "sPrevious": "ก่อนหน้า" }, "oAria": { "sSortAscending": ": เปิดการเรียงข้อมูลจากน้อยไปมาก", "sSortDescending": ": เปิดการเรียงข้อมูลจากมากไปน้อย" } } }); }); </script> |
-
SweetAlert 2
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<!-- SweetAlert2 --> <link rel="stylesheet" href="{{ asset('plugins/sweetalert2/sweetalert2.min.css') }}"> <!-- SweetAlert2 --> <script src="{{ URL::asset('plugins/sweetalert2/sweetalert2.min.js')}}"></script> <script> // SweetAlert2 Delete Confirmation function confirmDelete(event, id) { event.preventDefault(); Swal.fire({ text: "คุณแน่ใจที่จะลบข้อมูลหรือไม่?", icon: "warning", showCancelButton: true, confirmButtonColor: "#3085d6", cancelButtonColor: "#d33", confirmButtonText: "ตกลง", cancelButtonText: "ยกเลิก" }).then((result) => { if (result.isConfirmed) { document.getElementById('delete-form-' + id).submit(); } }); } </script> |
-
การแสดงผลในหน้า Admin (Branch Index)
- index.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 |
@extends('themes.index') @section('title', 'สาขา') @section('content') <div class="content"> <div class="container-fluid"> <div class="row"> <div class="col-12"> <div class="card"> <div class="card-header"> <h3 class="card-title">จัดการสาขา</h3> <div class="card-tools"> <a href="{{ route('admin.branches.create') }}" class="btn btn-primary btn-sm"> <i class="fas fa-plus"></i> เพิ่มสาขา </a> </div> </div> <div class="card-body"> <table class="table table-bordered table-striped dataTable dtr-inline collapsed" id="data-table"> <thead> <tr> <th width="5%">#</th> <th width="5%">สาขา</th> <th>ชื่อสาขา</th> <th width="40%">ที่อยู่</th> <th>สถานะ</th> <th>วันที่สร้าง</th> <th width="10%">จัดการ</th> </tr> </thead> <tbody> @forelse($branches as $branch) <tr> <td>{{ $loop->iteration }}</td> <td>{{ $branch->code }}</td> <td>{{ $branch->name }}</td> <td> {{ $branch->address }} @if($branch->subdistrict || $branch->district || $branch->province || $branch->zipcode) @if($branch->subdistrict) ต.{{ $branch->subdistrict }} @endif @if($branch->district) อ.{{ $branch->district }} @endif @if($branch->province) จ.{{ $branch->province }} @endif @if($branch->zipcode) {{ $branch->zipcode }} @endif @endif </td> <td> <span class="badge badge-{{ $branch->status ? 'success' : 'danger' }}"> {{ $branch->status ? 'เปิดใช้งาน' : 'ปิดใช้งาน' }} </span> </td> <td>{{ $branch->created_at ? $branch->created_at->format('d/m/Y') : '' }}</td> <td> <a href="{{ route('admin.branches.edit', $branch->id) }}" class="btn btn-sm btn-warning"> <i class="fas fa-edit"></i> </a> <form id="delete-form-{{ $branch->id }}" action="{{ route('admin.branches.destroy', $branch->id) }}" method="POST" style="display:inline;"> @csrf @method('DELETE') <button type="button" class="btn btn-sm btn-danger" onclick="confirmDelete(event, {{ $branch->id }})"> <i class="fas fa-trash"></i> </button> </form> </td> </tr> @empty <tr> <td colspan="7" class="text-center">ไม่มีข้อมูลสาขา</td> </tr> @endforelse </tbody> </table> </div> </div> </div> </div> </div> </div> @endsection |
-
- create.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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
@extends('themes.index') @section('title', 'เพิ่มสาขา') @section('content') <div class="content"> <div class="container-fluid"> <div class="row"> <div class="col-12"> <div class="card"> <div class="card-header"> <h3 class="card-title">เพิ่มสาขาใหม่</h3> </div> <form action="{{ route('admin.branches.store') }}" method="POST"> @csrf <div class="card-body"> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="code">รหัสสาขา <span class="text-danger">*</span></label> <input type="text" class="form-control @error('code') is-invalid @enderror" id="code" name="code" value="{{ old('code') }}" required> @error('code') <span class="invalid-feedback">{{ $message }}</span> @enderror </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="name">ชื่อสาขา <span class="text-danger">*</span></label> <input type="text" class="form-control @error('name') is-invalid @enderror" id="name" name="name" value="{{ old('name') }}" required> @error('name') <span class="invalid-feedback">{{ $message }}</span> @enderror </div> </div> </div> <div class="form-group"> <label for="address">ที่อยู่</label> <textarea class="form-control @error('address') is-invalid @enderror" id="address" name="address" rows="3">{{ old('address') }}</textarea> @error('address') <span class="invalid-feedback">{{ $message }}</span> @enderror </div> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="subdistrict">ตำบล/แขวง</label> <input type="text" class="form-control @error('subdistrict') is-invalid @enderror" id="subdistrict" name="subdistrict" value="{{ old('subdistrict') }}" autocomplete="off"> @error('subdistrict') <span class="invalid-feedback">{{ $message }}</span> @enderror </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="district">อำเภอ/เขต</label> <input type="text" class="form-control @error('district') is-invalid @enderror" id="district" name="district" value="{{ old('district') }}" autocomplete="off"> @error('district') <span class="invalid-feedback">{{ $message }}</span> @enderror </div> </div> </div> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="province">จังหวัด</label> <input type="text" class="form-control @error('province') is-invalid @enderror" id="province" name="province" value="{{ old('province') }}" autocomplete="off"> @error('province') <span class="invalid-feedback">{{ $message }}</span> @enderror </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="zipcode">รหัสไปรษณีย์</label> <input type="text" class="form-control @error('zipcode') is-invalid @enderror" id="zipcode" name="zipcode" value="{{ old('zipcode') }}" maxlength="10" autocomplete="off"> @error('zipcode') <span class="invalid-feedback">{{ $message }}</span> @enderror </div> </div> </div> <div class="form-group"> <label for="status">สถานะ</label> <select class="form-control @error('status') is-invalid @enderror" id="status" name="status" required> <option value="1" {{ old('status', 1) == 1 ? 'selected' : '' }}>เปิดใช้งาน</option> <option value="0" {{ old('status') == 0 ? 'selected' : '' }}>ปิดใช้งาน</option> </select> @error('status') <span class="invalid-feedback">{{ $message }}</span> @enderror </div> </div> <div class="card-footer"> <button type="submit" class="btn btn-primary"> <i class="fas fa-save"></i> บันทึก </button> <a href="{{ route('admin.branches.index') }}" class="btn btn-secondary"> <i class="fas fa-times"></i> ยกเลิก </a> </div> </form> </div> </div> </div> </div> </div> @endsection @push('script') <script type="text/javascript"> $(document).ready(function() { try { //jquery.Thailand.js $.Thailand({ $district: $('#subdistrict'), $amphoe: $('#district'), $province: $('#province'), $zipcode: $('#zipcode'), }); } catch (e) { console.error('Thailand.js error:', e); } }); @if ($errors->any()) @foreach ($errors->all() as $error) toastr.error('{{ $error }}'); @endforeach @endif </script> @endpush |
-
- 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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
@extends('themes.index') @section('title', 'แก้ไขสาขา') @section('content') <div class="content"> <div class="container-fluid"> <div class="row"> <div class="col-12"> <div class="card"> <div class="card-header"> <h3 class="card-title">แก้ไขข้อมูลสาขา</h3> </div> <form action="{{ route('admin.branches.update', $branch->id) }}" method="POST"> @csrf @method('PUT') <div class="card-body"> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="code">รหัสสาขา <span class="text-danger">*</span></label> <input type="text" class="form-control @error('code') is-invalid @enderror" id="code" name="code" value="{{ old('code', $branch->code) }}" required> @error('code') <span class="invalid-feedback">{{ $message }}</span> @enderror </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="name">ชื่อสาขา <span class="text-danger">*</span></label> <input type="text" class="form-control @error('name') is-invalid @enderror" id="name" name="name" value="{{ old('name', $branch->name) }}" required> @error('name') <span class="invalid-feedback">{{ $message }}</span> @enderror </div> </div> </div> <div class="form-group"> <label for="address">ที่อยู่</label> <textarea class="form-control @error('address') is-invalid @enderror" id="address" name="address" rows="3">{{ old('address', $branch->address) }}</textarea> @error('address') <span class="invalid-feedback">{{ $message }}</span> @enderror </div> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="subdistrict">ตำบล/แขวง</label> <input type="text" class="form-control @error('subdistrict') is-invalid @enderror" id="subdistrict" name="subdistrict" value="{{ old('subdistrict', $branch->subdistrict) }}" autocomplete="off"> @error('subdistrict') <span class="invalid-feedback">{{ $message }}</span> @enderror </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="district">อำเภอ/เขต</label> <input type="text" class="form-control @error('district') is-invalid @enderror" id="district" name="district" value="{{ old('district', $branch->district) }}" autocomplete="off"> @error('district') <span class="invalid-feedback">{{ $message }}</span> @enderror </div> </div> </div> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label for="province">จังหวัด</label> <input type="text" class="form-control @error('province') is-invalid @enderror" id="province" name="province" value="{{ old('province', $branch->province) }}" autocomplete="off"> @error('province') <span class="invalid-feedback">{{ $message }}</span> @enderror </div> </div> <div class="col-md-6"> <div class="form-group"> <label for="zipcode">รหัสไปรษณีย์</label> <input type="text" class="form-control @error('zipcode') is-invalid @enderror" id="zipcode" name="zipcode" value="{{ old('zipcode', $branch->zipcode) }}" maxlength="10" autocomplete="off"> @error('zipcode') <span class="invalid-feedback">{{ $message }}</span> @enderror </div> </div> </div> <div class="form-group"> <label for="status">สถานะ</label> <select class="form-control @error('status') is-invalid @enderror" id="status" name="status" required> <option value="1" {{ old('status', $branch->status) == 1 ? 'selected' : '' }}>เปิดใช้งาน</option> <option value="0" {{ old('status', $branch->status) == 0 ? 'selected' : '' }}>ปิดใช้งาน</option> </select> @error('status') <span class="invalid-feedback">{{ $message }}</span> @enderror </div> </div> <div class="card-footer"> <button type="submit" class="btn btn-primary"> <i class="fas fa-save"></i> บันทึก </button> <a href="{{ route('admin.branches.index') }}" class="btn btn-secondary"> <i class="fas fa-times"></i> ยกเลิก </a> </div> </form> </div> </div> </div> </div> </div> @endsection @push('scripts') <script type="text/javascript"> $(document).ready(function() { try { //jquery.Thailand.js $.Thailand({ $district: $('#subdistrict'), // input ของตำบล $amphoe: $('#district'), // input ของอำเภอ $province: $('#province'), // input ของจังหวัด $zipcode: $('#zipcode'), // input ของรหัสไปรษณีย์ }); } catch (e) { console.error('Thailand.js error:', e); } }); </script> @endpush |

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