Compare commits
10 Commits
265e5799a3
...
2b8c5be3d1
| Author | SHA1 | Date | |
|---|---|---|---|
| 2b8c5be3d1 | |||
| 75cc5c95e7 | |||
| 20f1bcfbae | |||
| d2bcfd817c | |||
| dc2535723c | |||
| 1ce473133d | |||
| b2c644ccb6 | |||
| e86160cb63 | |||
| ffede88eec | |||
| c880210f61 |
@ -4,13 +4,14 @@
|
|||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
|
use App\Models\Promocode;
|
||||||
class MemberController extends Controller
|
class MemberController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$data = Member::paginate(20);
|
$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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,14 +5,14 @@
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Imports\PromoImport;
|
use App\Imports\PromoImport;
|
||||||
use App\Models\Promocode;
|
use App\Models\Promocode;
|
||||||
|
use App\Models\User;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Log;
|
use Log;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
use App\Models\User;
|
|
||||||
class SettingController extends Controller
|
class SettingController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
public function promoCode(Request $request)
|
public function promoCode(Request $request)
|
||||||
{
|
{
|
||||||
$start = Carbon::now()->month(1)->startOfMonth();
|
$start = Carbon::now()->month(1)->startOfMonth();
|
||||||
@ -33,6 +33,7 @@ public function promoCodeCreate(Request $request)
|
|||||||
$request->validate([
|
$request->validate([
|
||||||
'file' => 'required|mimes:xlsx,xls,csv|max:2048',
|
'file' => 'required|mimes:xlsx,xls,csv|max:2048',
|
||||||
]);
|
]);
|
||||||
|
$from = $request->input('from'); // 默認來源為 cafeg
|
||||||
|
|
||||||
if ($request->hasFile('file')) {
|
if ($request->hasFile('file')) {
|
||||||
$file = $request->file('file');
|
$file = $request->file('file');
|
||||||
@ -55,7 +56,7 @@ public function promoCodeCreate(Request $request)
|
|||||||
|
|
||||||
// 讀取並導入 Excel 文件
|
// 讀取並導入 Excel 文件
|
||||||
try {
|
try {
|
||||||
Excel::import(new PromoImport, $file);
|
Excel::import(new PromoImport($from), $file);
|
||||||
return back()->with('success', '促銷代碼已成功導入!');
|
return back()->with('success', '促銷代碼已成功導入!');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return back()->with('error', '導入失敗: ' . $e->getMessage());
|
return back()->with('error', '導入失敗: ' . $e->getMessage());
|
||||||
@ -81,7 +82,6 @@ public function loginStatus(Request $request)
|
|||||||
'can_login' => $user->can_login,
|
'can_login' => $user->can_login,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,12 +42,22 @@ public function redirectToProvider(Request $request)
|
|||||||
*/
|
*/
|
||||||
public function handleProviderCallback(Request $request)
|
public function handleProviderCallback(Request $request)
|
||||||
{
|
{
|
||||||
|
// 如果用户取消了授权
|
||||||
// 从 Session 获取 $redirectTo
|
if ($request->has('error') && $request->get('error') === 'access_denied') {
|
||||||
$redirectTo = session('redirect_to', 'member');
|
$redirectTo = session('redirect_to', 'member');
|
||||||
|
|
||||||
|
if ($redirectTo === 'admin') {
|
||||||
|
return redirect()->route('admin.login')->with('error', '您已取消 LINE 授权');
|
||||||
|
} else {
|
||||||
|
return redirect()->route('login')->with('error', '您已取消 LINE 授权');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 获取 LINE 用户信息
|
||||||
$user = Socialite::driver('line')->user();
|
$user = Socialite::driver('line')->user();
|
||||||
Log::info('line', ['user' => $user]);
|
Log::info('line', ['user' => $user]);
|
||||||
|
|
||||||
$lineId = $user->getId();
|
$lineId = $user->getId();
|
||||||
$name = $user->getName();
|
$name = $user->getName();
|
||||||
$avatar = $user->getAvatar() ?? '';
|
$avatar = $user->getAvatar() ?? '';
|
||||||
@ -55,9 +65,12 @@ public function handleProviderCallback(Request $request)
|
|||||||
|
|
||||||
Log::info('email', [$email]);
|
Log::info('email', [$email]);
|
||||||
|
|
||||||
if ($redirectTo == 'admin') {
|
// 从 Session 获取跳转路径
|
||||||
|
$redirectTo = session('redirect_to', 'member');
|
||||||
|
|
||||||
|
if ($redirectTo === 'admin') {
|
||||||
// Admin 登录逻辑
|
// Admin 登录逻辑
|
||||||
$existingUser = $user = User::where('line_id', $lineId)
|
$existingUser = User::where('line_id', $lineId)
|
||||||
->orWhere('email', $email)
|
->orWhere('email', $email)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
@ -94,7 +107,6 @@ public function handleProviderCallback(Request $request)
|
|||||||
'password' => bcrypt(env('DEFAULT_PASSWORD')),
|
'password' => bcrypt(env('DEFAULT_PASSWORD')),
|
||||||
'source' => 'cafeg',
|
'source' => 'cafeg',
|
||||||
'avatar' => $avatar,
|
'avatar' => $avatar,
|
||||||
|
|
||||||
'email' => $email,
|
'email' => $email,
|
||||||
]);
|
]);
|
||||||
Auth::guard('member')->login($newUser);
|
Auth::guard('member')->login($newUser);
|
||||||
@ -105,7 +117,14 @@ public function handleProviderCallback(Request $request)
|
|||||||
? redirect()->route('member.index')
|
? redirect()->route('member.index')
|
||||||
: redirect()->route('member.profile');
|
: redirect()->route('member.profile');
|
||||||
}
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('LINE 登录失败: ' . $e->getMessage());
|
||||||
|
|
||||||
|
// 发生异常时,返回登录页面并提示错误
|
||||||
|
return redirect()->route('login')->with('error', 'LINE 登录失败,请稍后再试');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function adminLogout()
|
public function adminLogout()
|
||||||
{
|
{
|
||||||
@ -138,7 +157,7 @@ public function memberNormalLogin(Request $request)
|
|||||||
return redirect()->route('member.index');
|
return redirect()->route('member.index');
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return redirect()->route('front.login.view')->with('error', '帳號密碼錯誤');
|
return redirect()->route('login')->with('error', '帳號密碼錯誤');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers\front;
|
namespace App\Http\Controllers\front;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\EmailVerifications;
|
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\Promocode;
|
use App\Models\Promocode;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Mail;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
|
||||||
class MemberController extends Controller
|
class MemberController extends Controller
|
||||||
@ -19,25 +19,55 @@ class MemberController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$code = null;
|
$user = Auth::guard('member')->user();
|
||||||
|
|
||||||
if (isset(Auth::guard('member')->user()->id)) {
|
if (! $user) {
|
||||||
$user_id = Auth::guard('member')->user()->id;
|
Auth::guard('member')->logout();
|
||||||
$code = Promocode::where('used_count', $user_id)->latest()->first();
|
return redirect()->route('login');
|
||||||
|
}
|
||||||
|
|
||||||
if (!$code) {
|
$user_id = $user->id;
|
||||||
$code = Promocode::where('used_count', 0)->first();
|
$today = Carbon::today()->format('Y-m-d');
|
||||||
|
|
||||||
|
// 建立一個回傳符合條件的 Promocode 的 function
|
||||||
|
$getAvailableCode = function ($from) use ($today) {
|
||||||
|
return Promocode::where('used_count', 0)
|
||||||
|
->where('from', $from)
|
||||||
|
->whereDate('valid_from', '<=', $today)
|
||||||
|
->whereDate('valid_to', '>=', $today)
|
||||||
|
->latest()
|
||||||
|
->first();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 試著找一個未使用的
|
||||||
|
$code = $getAvailableCode('cafeg');
|
||||||
|
$teacode = $getAvailableCode('teamaster');
|
||||||
|
|
||||||
|
// 如果找不到,就再次找一個未使用的然後標記成首次給予
|
||||||
|
if (! $code) {
|
||||||
|
$code = $getAvailableCode('cafeg');
|
||||||
|
if ($code) {
|
||||||
$code->give_to = '首次';
|
$code->give_to = '首次';
|
||||||
$code->used_count = $user_id;
|
$code->used_count = $user_id;
|
||||||
$code->save();
|
$code->save();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return view('front.member.index', ['code' => $code]);
|
if (! $teacode) {
|
||||||
} else {
|
$teacode = $getAvailableCode('teacode');
|
||||||
Auth::guard('member')->logout();
|
if ($teacode) {
|
||||||
return redirect()->route('front.login.view');
|
$teacode->give_to = '首次';
|
||||||
|
$teacode->used_count = $user_id;
|
||||||
|
$teacode->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return view('front.member.index', [
|
||||||
|
'code' => $code,
|
||||||
|
'teacode' => $teacode,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Summary of profile 登入後個人資訊沒有menu
|
* Summary of profile 登入後個人資訊沒有menu
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Http\Controllers\front;
|
namespace App\Http\Controllers\front;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Promocode;
|
use App\Models\Promocode;
|
||||||
use Auth;
|
use Auth;
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class PromoCodeController extends Controller
|
class PromoCodeController extends Controller
|
||||||
{
|
{
|
||||||
@ -22,17 +23,25 @@ public function index()
|
|||||||
*/
|
*/
|
||||||
public function create(Request $request)
|
public function create(Request $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$user_id = Auth::guard('member')->user()->id;
|
$user_id = Auth::guard('member')->user()->id;
|
||||||
$count = Promocode::where('used_count', $user_id)->count();
|
$count = Promocode::where('used_count', $user_id)->count();
|
||||||
$give_to = $request->input('give_to');
|
$give_to = $request->input('give_to');
|
||||||
|
$from = $request->input('from');
|
||||||
|
$row = Promocode::where('used_count', 0)
|
||||||
|
->where('from', $from)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!$row) {
|
||||||
|
return response()->json(['status' => 'error', 'msg' => '目前無可用的優惠碼']);
|
||||||
|
}
|
||||||
|
|
||||||
$row = Promocode::where('used_count', 0)->first();
|
|
||||||
$row->used_count = $user_id;
|
$row->used_count = $user_id;
|
||||||
$row->give_to = $give_to;
|
$row->give_to = $give_to;
|
||||||
$row->save();
|
$row->save();
|
||||||
return response()->json(['status' => 'success', 'msg' => '已成功取得', 'promocode' => $row->code, 'give_to' => $row->give_to]);
|
return response()->json(['status' => 'success', 'msg' => '已成功取得', 'promocode' => $row->code, 'give_to' => $row->give_to]);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Summary of morePromocode
|
* Summary of morePromocode
|
||||||
@ -57,7 +66,6 @@ public function morePromocode()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store a newly created resource in storage.
|
* Store a newly created resource in storage.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -35,14 +35,8 @@ public function create(Request $request)
|
|||||||
'phone' => $request->phone ?? '',
|
'phone' => $request->phone ?? '',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (isset($newUser->email)) {
|
return redirect()->route('login')->with('sucess', '完成註冊,請登入');
|
||||||
|
|
||||||
return redirect()->route('member.index')->with('sucess', '完成註冊');
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
return redirect()->route('member.profile')->with('sucess', '完成註冊,請完善你得資料');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +125,7 @@ public function resetPassword(Request $request)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return redirect()->route('front.login.view')->with('error', '驗證密碼token 失敗');
|
return redirect()->route('login')->with('error', '驗證密碼token 失敗');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Imports;
|
namespace App\Imports;
|
||||||
|
|
||||||
use App\Models\Promocode;
|
use App\Models\Promocode;
|
||||||
@ -6,31 +7,109 @@
|
|||||||
use Log;
|
use Log;
|
||||||
use Maatwebsite\Excel\Concerns\ToCollection;
|
use Maatwebsite\Excel\Concerns\ToCollection;
|
||||||
|
|
||||||
|
use function Illuminate\Log\log;
|
||||||
|
|
||||||
class PromoImport implements ToCollection
|
class PromoImport implements ToCollection
|
||||||
{
|
{
|
||||||
|
protected $from;
|
||||||
|
|
||||||
|
public function __construct($from = 'cafeg')
|
||||||
|
{
|
||||||
|
$this->from = $from;
|
||||||
|
}
|
||||||
public function collection(Collection $rows)
|
public function collection(Collection $rows)
|
||||||
{
|
{
|
||||||
// 打印每一行數據(這是從 Excel 讀取的行)
|
if ($this->from == 'cafeg') {
|
||||||
|
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
|
$data = $row->toArray();
|
||||||
|
|
||||||
Log::info('Row data: ', ['value' => $row->toArray()[3]]);
|
if ($data[3] != '提货码') { // 跳過標題行
|
||||||
|
$code = $data[3];
|
||||||
|
|
||||||
if ($row->toArray()[3] != '提货码') // 跳過第一行
|
$promo = Promocode::where('code', $code)
|
||||||
{
|
->where('from', 'cafeg')
|
||||||
Promocode::create([
|
->first();
|
||||||
'code' => $row->toArray()[3], // 使用 "提货码" 列
|
|
||||||
'discount' => 100, // 假設折扣為固定值 100
|
if ($promo) {
|
||||||
'type' => 'percent', // 默認為百分比
|
// 如果已存在,且 give_to 不為 null,就更新
|
||||||
'usage_limit' => 1, // 默認每個代碼只能使用一次
|
if ($promo->give_to !== null) {
|
||||||
'valid_from' => date('Y-m-d'), // 當前日期
|
$promo->update([
|
||||||
'valid_to' => date('Y-m-d', strtotime('1 day')), // 默認有效期至第二天
|
'discount' => 100,
|
||||||
'is_active' => 1, // 默認啟用
|
'type' => 'percent',
|
||||||
|
'usage_limit' => 1,
|
||||||
|
'valid_from' => date('Y-m-d'),
|
||||||
|
'valid_to' => date('Y-m-d', strtotime('+1 day')),
|
||||||
|
'is_active' => 1,
|
||||||
|
'from' => 'cafeg',
|
||||||
]);
|
]);
|
||||||
|
Log::info("已更新:{$code}");
|
||||||
|
} else {
|
||||||
|
Log::info("跳過(give_to 為 null):{$code}");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 不存在就新增
|
||||||
|
Promocode::create([
|
||||||
|
'code' => $code,
|
||||||
|
'discount' => 100,
|
||||||
|
'type' => 'percent',
|
||||||
|
'usage_limit' => 1,
|
||||||
|
'valid_from' => date('Y-m-d'),
|
||||||
|
'valid_to' => date('Y-m-d', strtotime('+1 day')),
|
||||||
|
'is_active' => 1,
|
||||||
|
'from' => 'cafeg',
|
||||||
|
]);
|
||||||
|
Log::info("已新增:{$code}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->from == 'teamaster') {
|
||||||
|
Log::info('import-from: teamaster');
|
||||||
|
Log::info('row', );
|
||||||
|
foreach ($rows->toArray() as $row) {
|
||||||
|
|
||||||
|
$code = $row[0];
|
||||||
|
$promo = Promocode::where('code', $code)
|
||||||
|
->where('from', 'teamaster')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($promo) {
|
||||||
|
// 如果已存在,且 give_to 不為 null,就更新
|
||||||
|
if ($promo->give_to != null) {
|
||||||
|
$promo->update([
|
||||||
|
'discount' => 70,
|
||||||
|
'type' => 'amount',
|
||||||
|
'usage_limit' => 1,
|
||||||
|
'valid_from' => date('Y-m-d'),
|
||||||
|
'valid_to' => date('Y-m-d', strtotime('+7 day')),
|
||||||
|
'is_active' => 1,
|
||||||
|
'from' => 'teamaster',
|
||||||
|
]);
|
||||||
|
Log::info("已更新:{$code}");
|
||||||
|
} else {
|
||||||
|
Log::info("跳過(give_to 為 null):{$code}");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log::info("新增代碼:{$code}");
|
||||||
|
// 不存在就新增
|
||||||
|
Promocode::create([
|
||||||
|
'code' => $code,
|
||||||
|
'discount' => 70,
|
||||||
|
'type' => 'amount',
|
||||||
|
'usage_limit' => 1,
|
||||||
|
'valid_from' => date('Y-m-d'),
|
||||||
|
'valid_to' => date('Y-m-d', strtotime('+7 day')),
|
||||||
|
'is_active' => 1,
|
||||||
|
'from' => 'teamaster',
|
||||||
|
]);
|
||||||
|
Log::info("已新增:{$code}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,8 @@
|
|||||||
|
|
||||||
class Member extends Authenticatable
|
class Member extends Authenticatable
|
||||||
{
|
{
|
||||||
use HasApiTokens, Notifiable;
|
use HasApiTokens;
|
||||||
|
use Notifiable;
|
||||||
|
|
||||||
protected $table = 'members';
|
protected $table = 'members';
|
||||||
/**
|
/**
|
||||||
@ -64,7 +65,7 @@ public function getLevelNameAttribute()
|
|||||||
|
|
||||||
public function getPromoCode()
|
public function getPromoCode()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Promocode::class, 'used_count', 'id');
|
return $this->hasMany(Promocode::class, 'giveto_mem_id', 'id');
|
||||||
}
|
}
|
||||||
protected function casts(): array
|
protected function casts(): array
|
||||||
{
|
{
|
||||||
|
|||||||
@ -8,19 +8,18 @@ class Promocode extends Model
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
protected $table = 'promocodes';
|
protected $table = 'promocodes';
|
||||||
protected $fillable = [
|
protected $guarded = [];
|
||||||
'code',
|
|
||||||
'discount',
|
|
||||||
'type',
|
|
||||||
'usage_limit',
|
|
||||||
'used_count',
|
|
||||||
'valid_from',
|
|
||||||
'valid_to',
|
|
||||||
'is_active',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function getMember()
|
public function getMember()
|
||||||
{
|
{
|
||||||
return $this->hasOne(Member::class, 'id', 'used_count');
|
return $this->hasOne(Member::class, 'id', 'used_count');
|
||||||
}
|
}
|
||||||
|
public function getFromLabelAttribute()
|
||||||
|
{
|
||||||
|
return match ($this->from) {
|
||||||
|
'cafeg' => '朗立臣',
|
||||||
|
'teamaster' => '飲力星球',
|
||||||
|
default => '未知來源',
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class () extends Migration {
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('promocodes', function (Blueprint $table) {
|
||||||
|
$table->enum('from', ['cafeg', 'teamaster', 'unknown'])->comment('來源')->after('id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('promocodes');
|
||||||
|
}
|
||||||
|
};
|
||||||
BIN
public/app-debug.apk
Normal file
BIN
public/app-debug.apk
Normal file
Binary file not shown.
@ -231,10 +231,17 @@
|
|||||||
</body>
|
</body>
|
||||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||||
|
|
||||||
@if (session('error'))
|
@if (session('error'))
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
console.log('go there');
|
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: '失敗'
|
title: '失敗'
|
||||||
, text: "{{ session('error') }}"
|
, text: "{{ session('error') }}"
|
||||||
@ -245,10 +252,3 @@
|
|||||||
|
|
||||||
</script>
|
</script>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
@endsection
|
@endsection
|
||||||
@section('content')
|
@section('content')
|
||||||
<style>
|
<style>
|
||||||
.table th{
|
.table th {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
/* 禁止文字換行 */
|
/* 禁止文字換行 */
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@ -13,7 +13,8 @@
|
|||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
/* 超出用省略號顯示 */
|
/* 超出用省略號顯示 */
|
||||||
}
|
}
|
||||||
.table td{
|
|
||||||
|
.table td {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -31,8 +32,6 @@
|
|||||||
table {
|
table {
|
||||||
position: static !important;
|
position: static !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
@ -138,7 +137,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@php
|
||||||
|
$pageTotal = 0;
|
||||||
|
@endphp
|
||||||
<!-- Users List Table -->
|
<!-- Users List Table -->
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header border-bottom">
|
<div class="card-header border-bottom">
|
||||||
@ -209,12 +210,16 @@ class="rounded-circle">
|
|||||||
{{ $item->getPromoCode[0]->code }}
|
{{ $item->getPromoCode[0]->code }}
|
||||||
</span>
|
</span>
|
||||||
@endif
|
@endif
|
||||||
|
@php
|
||||||
|
$pageTotal += count($item->getPromoCode) ;
|
||||||
|
@endphp
|
||||||
@if (count($item->getPromoCode) > 1)
|
@if (count($item->getPromoCode) > 1)
|
||||||
<a class="text-danger" style="font-size:20px" data-bs-toggle="collapse"
|
<a class="text-danger" style="font-size:20px" data-bs-toggle="collapse"
|
||||||
href="#multiCollapseExample-{{ $item->id }}" role="button"
|
href="#multiCollapseExample-{{ $item->id }}" role="button"
|
||||||
aria-expanded="false" aria-controls="multiCollapseExample1">
|
aria-expanded="false" aria-controls="multiCollapseExample1">
|
||||||
{{ $item->getPromoCode[0]->code }} ({{ count($item->getPromoCode) }}
|
{{ $item->getPromoCode[0]->code }} ({{ count($item->getPromoCode) }}
|
||||||
筆)
|
筆)
|
||||||
|
|
||||||
</a>
|
</a>
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
@ -273,13 +278,16 @@ class="d-grid d-sm-flex p-4 border justify-content-center table-responsive text-
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@php $i = 1 ; @endphp
|
@php
|
||||||
@foreach ($item->getPromoCode as $key => $val)
|
$i=1;
|
||||||
|
$promoCodes = $item->getPromoCode()->paginate(30); // 每頁30筆優惠碼
|
||||||
|
@endphp
|
||||||
|
@foreach ($promoCodes as $val)
|
||||||
@if ($i == 1)
|
@if ($i == 1)
|
||||||
<tr>
|
<tr>
|
||||||
@endif
|
@endif
|
||||||
<td>{{ $i }} {{ $val->code }}</td>
|
<td class="text-danger"> {{ $val->code }}</td>
|
||||||
<td>{{ $val->give_to }}</td>
|
<td class="text-info">{{ $val->give_to }}</td>
|
||||||
@if ($i == 5)
|
@if ($i == 5)
|
||||||
</tr>
|
</tr>
|
||||||
@php $i = 0 @endphp
|
@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
|
@php $i++; @endphp
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<th colspan="10">
|
||||||
|
@if($promoCodes->count()>29)
|
||||||
|
{{ $promoCodes->links() }}
|
||||||
|
@endif
|
||||||
|
</th>
|
||||||
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
{{-- <span class="text-danger " style="font-size:20px">
|
{{-- <span class="text-danger " style="font-size:20px">
|
||||||
@foreach ($item->getPromoCode as $key => $val)
|
@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>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</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>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -336,7 +361,6 @@ class="d-grid d-sm-flex p-4 border justify-content-center table-responsive text-
|
|||||||
});
|
});
|
||||||
|
|
||||||
function changeLevel(id, lv) {
|
function changeLevel(id, lv) {
|
||||||
|
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: "確定",
|
title: "確定",
|
||||||
text: "你即將修改此用戶權限!",
|
text: "你即將修改此用戶權限!",
|
||||||
@ -356,37 +380,26 @@ function changeLevel(id, lv) {
|
|||||||
headers: {
|
headers: {
|
||||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||||
},
|
},
|
||||||
|
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
if (response.status == 'success') {
|
if (response.status == 'success') {
|
||||||
console.log(lv);
|
let name = response.name;
|
||||||
// lv = response.level;
|
let view = '';
|
||||||
name = response.name;
|
|
||||||
var view ='';
|
|
||||||
if (lv == 0) {
|
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;
|
||||||
|
} else if (lv == 1) {
|
||||||
|
view = '<i class="ri-user-line ri-22px text-info me-2"></i>' + name;
|
||||||
|
} else if (lv == 2) {
|
||||||
|
view = '<i class="ri-user-line ri-22px text-sucess me-2"></i>' + name;
|
||||||
|
} else if (lv == 9) {
|
||||||
|
view = '<i class="ri-user-line ri-22px text-warning me-2"></i>' + name;
|
||||||
}
|
}
|
||||||
if (lv == 1) {
|
$("#user-" + id).html(view);
|
||||||
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;
|
|
||||||
}
|
|
||||||
if (lv == 9) {
|
|
||||||
view = '<i class = "ri-user-line ri-22px text-warning me-2" > </i>'+ name;
|
|
||||||
}
|
|
||||||
$("#user-"+id).html(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Swal.fire("成功", "修改成功", "success");
|
Swal.fire("成功", "修改成功", "success");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} else if (result.dismiss === Swal.DismissReason.cancel) {
|
} else if (result.dismiss === Swal.DismissReason.cancel) {
|
||||||
Swal.fire("取消", "使用者取消操作", "error");
|
Swal.fire("取消", "使用者取消操作", "error");
|
||||||
console.log("使用者取消操作");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,28 +49,57 @@
|
|||||||
|
|
||||||
<!-- Basic Layout -->
|
<!-- Basic Layout -->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xl">
|
<div class="col-xl">
|
||||||
<div class="card mb-12" style="margin-bottom: 20px;">
|
<div class="card mb-12" style="margin-bottom: 20px;">
|
||||||
|
<h5 class="card-header">Excel 匯入</h5>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form action="{{route('admin.promocode.create')}}" method="POST" enctype="multipart/form-data">
|
|
||||||
|
<!-- Tabs -->
|
||||||
|
<ul class="nav nav-tabs" id="importTabs" role="tablist">
|
||||||
|
<li class="nav-item" role="presentation">
|
||||||
|
<button class="nav-link active" id="cafeg-tab" data-bs-toggle="tab" data-bs-target="#cafeg-form"
|
||||||
|
type="button" role="tab" aria-controls="cafeg-form" aria-selected="true">朗立臣</button>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item" role="presentation">
|
||||||
|
<button class="nav-link" id="teamaster-tab" data-bs-toggle="tab" data-bs-target="#teamaster-form"
|
||||||
|
type="button" role="tab" aria-controls="teamaster-form" aria-selected="false">飲力星球</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<!-- Tab Content -->
|
||||||
|
<div class="tab-content mt-4" id="importTabsContent">
|
||||||
|
|
||||||
|
<!-- 朗立臣 (cafeg) -->
|
||||||
|
<div class="tab-pane fade show active" id="cafeg-form" role="tabpanel" aria-labelledby="cafeg-tab">
|
||||||
|
<form action="{{ route('admin.promocode.create') }}" method="POST" enctype="multipart/form-data">
|
||||||
@csrf
|
@csrf
|
||||||
|
|
||||||
<h5 class="card-header">輸入檔案</h5>
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<label for="formFile" class="form-label">檔案類型 excels</label>
|
<label for="formFile1" class="form-label">匯入 Excel(朗立臣)</label>
|
||||||
<input class="form-control" name="file" type="file" id="formFile">
|
<input class="form-control" name="file" type="file" id="formFile1">
|
||||||
|
<input type="hidden" name="from" value="cafeg">
|
||||||
</div>
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">送出</button>
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary">Send</button>
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 飲力星球 (teamaster) -->
|
||||||
|
<div class="tab-pane fade" id="teamaster-form" role="tabpanel" aria-labelledby="teamaster-tab">
|
||||||
|
<form action="{{ route('admin.promocode.create') }}" method="POST" enctype="multipart/form-data">
|
||||||
|
@csrf
|
||||||
|
<div class="mb-4">
|
||||||
|
<label for="formFile2" class="form-label">匯入 Excel(飲力星球)</label>
|
||||||
|
<input class="form-control" name="file" type="file" id="formFile2">
|
||||||
|
<input type="hidden" name="from" value="teamaster">
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-success">送出</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<!-- DataTable with Buttons -->
|
<!-- DataTable with Buttons -->
|
||||||
<div class="card">
|
<div class="card">
|
||||||
@ -78,7 +107,7 @@
|
|||||||
<table class="datatables-basic table table-bordered">
|
<table class="datatables-basic table table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th style="width: 20%; !important">來源</th>
|
||||||
<th style="width: 20%; !important"> 優惠碼</th>
|
<th style="width: 20%; !important"> 優惠碼</th>
|
||||||
<th style="width: 15%; !important">優惠類型</th>
|
<th style="width: 15%; !important">優惠類型</th>
|
||||||
<th style="width: 20%; !important">折扣比例</th>
|
<th style="width: 20%; !important">折扣比例</th>
|
||||||
@ -89,6 +118,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
@foreach($data as $item)
|
@foreach($data as $item)
|
||||||
<tr>
|
<tr>
|
||||||
|
<td>{{$item->getFromLabelAttribute()}}</td>
|
||||||
<td><strong class="text-danger blod">{{$item->code}}</strong></td>
|
<td><strong class="text-danger blod">{{$item->code}}</strong></td>
|
||||||
<td>{{$item->type}}</td>
|
<td>{{$item->type}}</td>
|
||||||
<td> {{ number_format($item->discount, 0) }}</td>
|
<td> {{ number_format($item->discount, 0) }}</td>
|
||||||
|
|||||||
@ -117,7 +117,7 @@
|
|||||||
<button class="btn btn-primary d-grid w-100" id="confirm">發送連結</button>
|
<button class="btn btn-primary d-grid w-100" id="confirm">發送連結</button>
|
||||||
</form>
|
</form>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<a href="{{ route('front.login.view') }}" class="d-flex align-items-center justify-content-center">
|
<a href="{{ route('login') }}" class="d-flex align-items-center justify-content-center">
|
||||||
<i class="ri-arrow-left-s-line scaleX-n1-rtl ri-20px me-1_5"></i>
|
<i class="ri-arrow-left-s-line scaleX-n1-rtl ri-20px me-1_5"></i>
|
||||||
回到登入
|
回到登入
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@ -157,7 +157,7 @@
|
|||||||
|
|
||||||
<p class="text-center">
|
<p class="text-center">
|
||||||
<span>已經有帳號?</span>
|
<span>已經有帳號?</span>
|
||||||
<a href="{{ route('front.login.view') }}" class="text-body">
|
<a href="{{ route('login') }}" class="text-body">
|
||||||
<span>由此登入</span>
|
<span>由此登入</span>
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
@ -388,6 +388,11 @@ function validateEmailField(field) {
|
|||||||
|
|
||||||
// 如果所有欄位均有效,執行表單提交
|
// 如果所有欄位均有效,執行表單提交
|
||||||
if (isFormValid && isPhoneValid) {
|
if (isFormValid && isPhoneValid) {
|
||||||
|
$.ajaxSetup({
|
||||||
|
headers: {
|
||||||
|
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||||
|
}
|
||||||
|
});
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{{ route('member.register.create') }}",
|
url: "{{ route('member.register.create') }}",
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
|
|||||||
@ -102,15 +102,17 @@ class="fw-medium">{{ Auth::guard('member')->user()->Level_Name }}</span>
|
|||||||
<ul class="nav nav-pills " role="tablist">
|
<ul class="nav nav-pills " role="tablist">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<button type="button"
|
<button type="button"
|
||||||
|
id="cafeg-tab"
|
||||||
class="nav-link d-flex flex-column gap-1 active" role="tab"
|
class="nav-link d-flex flex-column gap-1 active" role="tab"
|
||||||
data-bs-toggle="tab"
|
data-bs-toggle="tab"
|
||||||
data-bs-target="#navs-pills-within-card-active"
|
data-bs-target="#navs-pills-within-card-active"
|
||||||
aria-controls="navs-pills-within-card-active"
|
aria-controls="navs-pills-within-card-active"
|
||||||
aria-selected="true"><i class="tf-icons ri-home-smile-line"></i>
|
aria-selected="true"><i class="tf-icons ri-home-smile-line"></i>
|
||||||
|
|
||||||
國王&皇后</button>
|
國王&皇后</button>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<button type="button" class="nav-link d-flex flex-column gap-1"
|
<button id= "tea-tab" type="button" class="nav-link d-flex flex-column gap-1"
|
||||||
role="tab" data-bs-toggle="tab"
|
role="tab" data-bs-toggle="tab"
|
||||||
data-bs-target="#navs-pills-within-card-link"
|
data-bs-target="#navs-pills-within-card-link"
|
||||||
aria-controls="navs-pills-within-card-link"
|
aria-controls="navs-pills-within-card-link"
|
||||||
@ -157,10 +159,38 @@ class="nav-link d-flex flex-column gap-1 active" role="tab"
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane fade" id="navs-pills-within-card-link" role="tabpanel">
|
<div class="tab-pane fade" id="navs-pills-within-card-link"
|
||||||
|
role="tabpanel">
|
||||||
<h4 class="card-title">茶飲大師手搖機 飲品兌換卷</h4>
|
<h4 class="card-title">茶飲大師手搖機 飲品兌換卷</h4>
|
||||||
<p class="card-text">施工中 ....</p>
|
<div class="form-floating form-floating-outline">
|
||||||
{{-- <a href="javascript:void(0)" class="btn btn-secondary">Go somewhere</a> --}}
|
@if (Auth::guard('member')->user()->level != 9)
|
||||||
|
<input type="text" class="form-control text-danger"
|
||||||
|
style="font-size:24px; font-weight: bold;"
|
||||||
|
id="floatingInput4" aria-describedby="floatingInputHelp">
|
||||||
|
<label for="floatingInput">兌換碼</label>
|
||||||
|
{{-- <div id="floatingInputHelp" class="form-text">We'll never share your details with anyone else.</div> --}}
|
||||||
|
@else
|
||||||
|
{{-- 顯示給予誰 --}}
|
||||||
|
<div class="input-group" id ="tea-give-to">
|
||||||
|
<input type="text" class="form-control text-info"
|
||||||
|
style="font-size:24px; font-weight: bold;"
|
||||||
|
id="floatingInput5" aria-describedby="button-addon3"
|
||||||
|
placeholder="給予誰" required=true>
|
||||||
|
<button class="btn btn-outline-primary" type="button"
|
||||||
|
id="button-addon4">獲取兌換碼</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- 顯示兌換碼 --}}
|
||||||
|
<div class="input-group" id="promocode-show-teamaster">
|
||||||
|
<input type="text" class="form-control text-danger"
|
||||||
|
style="font-size:24px; font-weight: bold;"
|
||||||
|
id="floatingInput6" aria-describedby="button-addon7">
|
||||||
|
<button class="btn btn-outline-primary" type="button"
|
||||||
|
id="button-addon7">重新獲取</button>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -175,7 +205,8 @@ class="nav-link d-flex flex-column gap-1 active" role="tab"
|
|||||||
<div class="card mb-6">
|
<div class="card mb-6">
|
||||||
<div class="card-body" style="padding-top: 3%">
|
<div class="card-body" style="padding-top: 3%">
|
||||||
<small class="card-text text-uppercase text-muted small">QRCode</small>
|
<small class="card-text text-uppercase text-muted small">QRCode</small>
|
||||||
<div class="d-flex justify-content-center" id="qrcode" style="padding-top: 3%">
|
<div class="d-flex justify-content-center" id="qrcode"
|
||||||
|
style="padding-top: 3%">
|
||||||
</div>
|
</div>
|
||||||
<!-- Flexbox居中 -->
|
<!-- Flexbox居中 -->
|
||||||
</div>
|
</div>
|
||||||
@ -244,77 +275,131 @@ class='ri-bar-chart-2-line ri-24px text-body me-4'></i>消費紀錄</h5>
|
|||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
console.log("Document is ready");
|
||||||
var id = "{{ Auth::guard('member')->user()->id }}";
|
var id = "{{ Auth::guard('member')->user()->id }}";
|
||||||
$("#promocode").hide();
|
$("#promocode-show").hide();
|
||||||
// $("#promocode-show").hide();
|
$("#promocode-show-teamaster").hide();
|
||||||
|
$("#tea-give-to").hide();
|
||||||
|
// 建立 QR Code
|
||||||
var qrcode = new QRCode(document.getElementById("qrcode"), {
|
var qrcode = new QRCode(document.getElementById("qrcode"), {
|
||||||
text: id, // 要顯示的內容
|
text: id,
|
||||||
width: 250, // QR code 的寬度
|
width: 250,
|
||||||
height: 250 // QR code 的高度
|
height: 250
|
||||||
});
|
});
|
||||||
});
|
|
||||||
$("#submit-btn").on('click', function() {
|
|
||||||
var id = "{{ Auth::guard('member')->user()->id }}";
|
|
||||||
$("#promocode").show();
|
|
||||||
var give_to = "{{ $code->give_to }}";
|
|
||||||
var code ="{{ $code->code }}";
|
|
||||||
|
|
||||||
console.log('code:',code);
|
// 顯示資料按鈕
|
||||||
|
$("#submit-btn").on('click', function() {
|
||||||
|
$("#promocode").show();
|
||||||
|
console.log('submit button clicked');
|
||||||
|
var give_to = "{{ $code->give_to ?? '' }}";
|
||||||
|
var code = "{{ $code->code ?? '' }}";
|
||||||
|
var t_give_to = "{{ $teacode->give_to ?? '' }}";
|
||||||
|
var t_code = "{{ $teacode->code ?? '' }}";
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
$("#give-to").hide();
|
$("#give-to").hide();
|
||||||
$("#floatingInput2").val(code);
|
$("#floatingInput2").val(code);
|
||||||
$("#last-give-to").html("最後給予 : " + give_to);
|
$("#last-give-to").html("最後給予 : " + give_to);
|
||||||
} else {
|
} else {
|
||||||
$("#give-to").show();
|
$("#give-to").show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('id:', id);
|
if (t_code) {
|
||||||
|
$("#tea-give-to").hide();
|
||||||
|
$("#floatingInput6").val(t_code);
|
||||||
|
$("#last-give-to").html("最後給予 : " + give_to);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$("#tea-give-to").show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//tab 切換
|
||||||
|
$("#cafeg-tab").on('click', function() {
|
||||||
|
$("#promocode-show").show();
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
$("#tea-tab").on('click', function() {
|
||||||
|
$("#promocode-show-teamaster").show();
|
||||||
|
$("#promocode-show").hide();
|
||||||
|
$("#tea-give-to").hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// cafeg 請求
|
||||||
|
$("#button-addon3").on('click', function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
var give_to = $("#floatingInput3").val();
|
||||||
|
if (!give_to) return alert("請輸入給予誰的資訊");
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "{{ route('member.getpromocode') }}",
|
||||||
|
type: 'POST',
|
||||||
|
data: {
|
||||||
|
_token: '{{ csrf_token() }}',
|
||||||
|
id: id,
|
||||||
|
give_to: give_to,
|
||||||
|
from: 'cafeg',
|
||||||
|
},
|
||||||
|
success: function(res) {
|
||||||
|
$("#promocode-show").show();
|
||||||
|
$("#give-to").hide();
|
||||||
|
$("#floatingInput2").val(res.promocode);
|
||||||
|
},
|
||||||
|
error: function(xhr) {
|
||||||
|
console.log(xhr.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// teamaster 請求
|
||||||
|
$("#button-addon4").on('click', function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
var give_to = $("#floatingInput5").val();
|
||||||
|
if (!give_to) return alert("請輸入給予誰的資訊");
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "{{ route('member.getpromocode') }}",
|
||||||
|
type: 'POST',
|
||||||
|
data: {
|
||||||
|
_token: '{{ csrf_token() }}',
|
||||||
|
id: id,
|
||||||
|
give_to: give_to,
|
||||||
|
from: 'teamaster',
|
||||||
|
},
|
||||||
|
success: function(res) {
|
||||||
|
$("#promocode-show-teamaster").show();
|
||||||
|
$("#tea-give-to").hide();
|
||||||
|
$("#floatingInput6").val(res.promocode);
|
||||||
|
},
|
||||||
|
error: function(xhr) {
|
||||||
|
console.log(xhr.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//給予誰
|
||||||
$("#button-addon2").on('click', function() {
|
$("#button-addon2").on('click', function() {
|
||||||
var id = "{{ Auth::guard('member')->user()->id }}";
|
var id = "{{ Auth::guard('member')->user()->id }}";
|
||||||
$("#promocode").show();
|
$("#promocode").show();
|
||||||
$("#give-to").show();
|
$("#give-to").show();
|
||||||
|
$("#floatingInput3").val("");
|
||||||
$("#promocode-show").hide();
|
$("#promocode-show").hide();
|
||||||
console.log('id:', id);
|
console.log('id:', id);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
//給予誰
|
||||||
$("#button-addon3").on('click', function(event) {
|
$("#button-addon7").on('click', function() {
|
||||||
event.preventDefault(); // 阻止表单的默认提交行为
|
|
||||||
|
|
||||||
var id = "{{ Auth::guard('member')->user()->id }}";
|
var id = "{{ Auth::guard('member')->user()->id }}";
|
||||||
var give_to = $("#floatingInput3").val();
|
$("#promocode").show();
|
||||||
|
$("#tea-give-to").show();
|
||||||
// 检查输入框的值是否为空
|
$("#floatingInput5").val("");
|
||||||
if (!give_to) {
|
$("#promocode-show-teamaster").hide();
|
||||||
alert("請輸入給予誰的資訊");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 發送 AJAX 請求
|
|
||||||
$.ajax({
|
|
||||||
url: "{{ route('member.getpromocode') }}", // 設定你的路由 URL
|
|
||||||
type: 'POST',
|
|
||||||
data: {
|
|
||||||
_token: '{{ csrf_token() }}', // CSRF token
|
|
||||||
id: id,
|
|
||||||
give_to: give_to
|
|
||||||
},
|
|
||||||
success: function(response) {
|
|
||||||
$("#promocode-show").show();
|
|
||||||
$("#give-to").hide();
|
|
||||||
$("#floatingInput").val(response.promocode);
|
|
||||||
$("#floatingInput2").val(response.promocode);
|
|
||||||
console.log(response); // 顯示後端回應資料
|
|
||||||
},
|
|
||||||
error: function(xhr, status, error) {
|
|
||||||
console.log(xhr.responseText); // 顯示錯誤資訊
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
|
||||||
|
@endsection
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
use App\Http\Controllers\LoginController;
|
use App\Http\Controllers\LoginController;
|
||||||
use App\Http\Middleware\AdminRedirect;
|
use App\Http\Middleware\AdminRedirect;
|
||||||
use App\Http\Middleware\AdminAuth;
|
use App\Http\Middleware\AdminAuth;
|
||||||
|
use App\Http\Controllers\Admin\RegisterController;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
@ -13,14 +14,20 @@
|
|||||||
Route::get('/phpinfo', function () {
|
Route::get('/phpinfo', function () {
|
||||||
return phpinfo();
|
return phpinfo();
|
||||||
});
|
});
|
||||||
|
/** no middleware
|
||||||
|
* ajxa 丟這
|
||||||
|
*/
|
||||||
|
Route::get('register', [RegisterController::class, 'index'])->name('register');
|
||||||
|
Route::post('register/create', [RegisterController::class, 'registerCreate'])->name('register.create');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* has middleware admin 需登入
|
||||||
|
*/
|
||||||
Route::
|
Route::
|
||||||
namespace('App\Http\Controllers\Admin') // 設置命名空間
|
namespace('App\Http\Controllers\Admin') // 設置命名空間
|
||||||
->middleware([AdminRedirect::class, AdminAuth::class])
|
->middleware([AdminRedirect::class, AdminAuth::class])
|
||||||
->group(function () {
|
->group(function () {
|
||||||
Route::get('/', 'IndexController@index')->name('index');
|
Route::get('/', 'IndexController@index')->name('index');
|
||||||
Route::get('register', 'RegisterController@index')->name('register');
|
|
||||||
Route::post('register/create', 'RegisterController@registerCreate')->name('register.create');
|
|
||||||
Route::get('profile', 'IndexController@profile')->name('profile');
|
Route::get('profile', 'IndexController@profile')->name('profile');
|
||||||
Route::get('page-profile', 'IndexController@pageProfile')->name('page.profile');
|
Route::get('page-profile', 'IndexController@pageProfile')->name('page.profile');
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,6 @@
|
|||||||
use App\Http\Controllers\front\RegisterController;
|
use App\Http\Controllers\front\RegisterController;
|
||||||
use App\Http\Controllers\LoginController;
|
use App\Http\Controllers\LoginController;
|
||||||
use App\Http\Middleware\GuestRedirect;
|
use App\Http\Middleware\GuestRedirect;
|
||||||
use App\Http\Middleware\memberAuth;
|
|
||||||
use App\Http\Middleware\MemberRedirect;
|
use App\Http\Middleware\MemberRedirect;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
@ -48,9 +47,6 @@
|
|||||||
Route::get('google/callback', [LoginController::class, 'handleGoogleCallback'])->name('google.redirect');
|
Route::get('google/callback', [LoginController::class, 'handleGoogleCallback'])->name('google.redirect');
|
||||||
Route::patch('changelevel', [MemberController::class, 'changeLevel'])->name('member.changelevel');
|
Route::patch('changelevel', [MemberController::class, 'changeLevel'])->name('member.changelevel');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//前台route 登入後;
|
//前台route 登入後;
|
||||||
Route::prefix('member')
|
Route::prefix('member')
|
||||||
->middleware(['auth:member']) // 使用自定义守卫的中间件
|
->middleware(['auth:member']) // 使用自定义守卫的中间件
|
||||||
|
|||||||
0
storage/app/.gitignore
vendored
Normal file → Executable file
0
storage/app/.gitignore
vendored
Normal file → Executable file
0
storage/app/public/.gitignore
vendored
Normal file → Executable file
0
storage/app/public/.gitignore
vendored
Normal file → Executable file
0
storage/framework/.gitignore
vendored
Normal file → Executable file
0
storage/framework/.gitignore
vendored
Normal file → Executable file
0
storage/framework/cache/.gitignore
vendored
Normal file → Executable file
0
storage/framework/cache/.gitignore
vendored
Normal file → Executable file
0
storage/framework/cache/data/.gitignore
vendored
Normal file → Executable file
0
storage/framework/cache/data/.gitignore
vendored
Normal file → Executable file
0
storage/framework/sessions/.gitignore
vendored
Normal file → Executable file
0
storage/framework/sessions/.gitignore
vendored
Normal file → Executable file
0
storage/framework/testing/.gitignore
vendored
Normal file → Executable file
0
storage/framework/testing/.gitignore
vendored
Normal file → Executable file
0
storage/framework/views/.gitignore
vendored
Normal file → Executable file
0
storage/framework/views/.gitignore
vendored
Normal file → Executable file
0
storage/logs/.gitignore
vendored
Normal file → Executable file
0
storage/logs/.gitignore
vendored
Normal file → Executable file
Loading…
Reference in New Issue
Block a user