feat. 兌換碼

This commit is contained in:
ukyo 2025-02-18 11:45:37 +08:00
parent 1ce473133d
commit dc2535723c
4 changed files with 52 additions and 20 deletions

View File

@ -4,13 +4,14 @@
use App\Http\Controllers\Controller;
use App\Models\Member;
use App\Models\Promocode;
class MemberController extends Controller
{
public function index()
{
$data = Member::paginate(20);
return view('admin.member.index', ['data' => $data]);
$total =Promocode::where('used_count','>',0)->count();
return view('admin.member.index', ['data' => $data,'total'=>$total]);
}
}

View File

@ -32,7 +32,9 @@ public function index()
$code->save();
}
return view('front.member.index', ['code' => $code]);
return view('front.member.index', ['code' => $code ]);
} else {
Auth::guard('member')->logout();
return redirect()->route('login');

View File

@ -242,7 +242,6 @@
@if (session('error'))
<script>
document.addEventListener("DOMContentLoaded", function() {
console.log('go there');
Swal.fire({
title: '失敗'
, text: "{{ session('error') }}"

View File

@ -3,7 +3,7 @@
@endsection
@section('content')
<style>
.table th{
.table th {
white-space: nowrap;
/* 禁止文字換行 */
text-align: center;
@ -13,7 +13,8 @@
text-overflow: ellipsis;
/* 超出用省略號顯示 */
}
.table td{
.table td {
white-space: nowrap;
}
@ -31,8 +32,6 @@
table {
position: static !important;
}
</style>
<div class="row">
<div class="col-md-12">
@ -138,7 +137,9 @@
</div>
</div>
</div>
@php
$pageTotal = 0;
@endphp
<!-- Users List Table -->
<div class="card">
<div class="card-header border-bottom">
@ -209,12 +210,16 @@ class="rounded-circle">
{{ $item->getPromoCode[0]->code }}
</span>
@endif
@php
$pageTotal += count($item->getPromoCode) ;
@endphp
@if (count($item->getPromoCode) > 1)
<a class="text-danger" style="font-size:20px" data-bs-toggle="collapse"
href="#multiCollapseExample-{{ $item->id }}" role="button"
aria-expanded="false" aria-controls="multiCollapseExample1">
{{ $item->getPromoCode[0]->code }} ({{ count($item->getPromoCode) }}
)
</a>
@endif
</td>
@ -273,13 +278,16 @@ class="d-grid d-sm-flex p-4 border justify-content-center table-responsive text-
</tr>
</thead>
<tbody>
@php $i = 1 ; @endphp
@foreach ($item->getPromoCode as $key => $val)
@php
$i=1;
$promoCodes = $item->getPromoCode()->paginate(30); // 每頁30筆優惠碼
@endphp
@foreach ($promoCodes as $val)
@if ($i == 1)
<tr>
@endif
<td>{{ $i }} {{ $val->code }}</td>
<td>{{ $val->give_to }}</td>
<td class="text-danger"> {{ $val->code }}</td>
<td class="text-info">{{ $val->give_to }}</td>
@if ($i == 5)
</tr>
@php $i = 0 @endphp
@ -287,6 +295,13 @@ class="d-grid d-sm-flex p-4 border justify-content-center table-responsive text-
@php $i++; @endphp
@endforeach
</tbody>
<tfoot>
<th colspan="10">
@if($promoCodes->count()>30)
{{ $promoCodes->links() }}
@endif
</th>
</tfoot>
</table>
{{-- <span class="text-danger " style="font-size:20px">
@foreach ($item->getPromoCode as $key => $val)
@ -303,6 +318,16 @@ class="d-grid d-sm-flex p-4 border justify-content-center table-responsive text-
</tr>
@endforeach
</tbody>
<tfoot>
<tr>
<th colspan="3">本頁兌換碼計數</th>
<th colspan="4">總兌換碼計數</th>
</tr>
<tr>
<th colspan="3" class="text-start-center"><h3 class="mb-1 me-2 text-info">{{ $pageTotal }}</h3></th>
<th colspan="4" class="text-start-center"><h3 class="mb-1 me-2 text-info">{{ $total}} </h3></th>
</tr>
</tfoot>
</table>
</div>
</div>
@ -362,20 +387,25 @@ function changeLevel(id, lv) {
console.log(lv);
// lv = response.level;
name = response.name;
var view ='';
var view = '';
if (lv == 0) {
view = '<i class = "ri-user-line ri-22px text-danger me-2" ></i>' + name;
view = '<i class = "ri-user-line ri-22px text-danger me-2" ></i>' +
name;
}
if (lv == 1) {
view = '<i class = "ri-user-line ri-22px text-info me-2" ></i>'+ name;
view = '<i class = "ri-user-line ri-22px text-info me-2" ></i>' +
name;
}
if (lv == 2) {
view = '<i class = "ri-user-line ri-22px text-sucess me-2" > </i>'+ name;
view = '<i class = "ri-user-line ri-22px text-sucess me-2" > </i>' +
name;
}
if (lv == 9) {
view = '<i class = "ri-user-line ri-22px text-warning me-2" > </i>'+ name;
view =
'<i class = "ri-user-line ri-22px text-warning me-2" > </i>' +
name;
}
$("#user-"+id).html(view);
$("#user-" + id).html(view);
}