feat.例行push
This commit is contained in:
parent
75cc5c95e7
commit
2b8c5be3d1
@ -23,23 +23,25 @@ public function index()
|
||||
*/
|
||||
public function create(Request $request)
|
||||
{
|
||||
|
||||
$user_id = Auth::guard('member')->user()->id;
|
||||
$count = Promocode::where('used_count', $user_id)->count();
|
||||
$give_to = $request->input('give_to');
|
||||
$from = $request->input('from');
|
||||
$row = Promocode::where('used_count', 0)
|
||||
->where('from', $from)
|
||||
->where(
|
||||
'valid_from',
|
||||
'<=',
|
||||
now()
|
||||
)->where('valid_to', '>=', now())
|
||||
->first();
|
||||
|
||||
|
||||
|
||||
if (!$row) {
|
||||
return response()->json(['status' => 'error', 'msg' => '目前無可用的優惠碼']);
|
||||
}
|
||||
|
||||
$row->used_count = $user_id;
|
||||
$row->give_to = $give_to;
|
||||
$row->save();
|
||||
return response()->json(['status' => 'success', 'msg' => '已成功取得', 'promocode' => $row->code, 'give_to' => $row->give_to]);
|
||||
|
||||
}
|
||||
/**
|
||||
* Summary of morePromocode
|
||||
|
||||
@ -10,7 +10,8 @@
|
||||
|
||||
class Member extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, Notifiable;
|
||||
use HasApiTokens;
|
||||
use Notifiable;
|
||||
|
||||
protected $table = 'members';
|
||||
/**
|
||||
@ -64,7 +65,7 @@ public function getLevelNameAttribute()
|
||||
|
||||
public function getPromoCode()
|
||||
{
|
||||
return $this->hasMany(Promocode::class, 'used_count', 'id');
|
||||
return $this->hasMany(Promocode::class, 'giveto_mem_id', 'id');
|
||||
}
|
||||
protected function casts(): array
|
||||
{
|
||||
|
||||
@ -278,7 +278,7 @@ class='ri-bar-chart-2-line ri-24px text-body me-4'></i>消費紀錄</h5>
|
||||
$(document).ready(function() {
|
||||
console.log("Document is ready");
|
||||
var id = "{{ Auth::guard('member')->user()->id }}";
|
||||
$("#promocode").hide();
|
||||
$("#promocode-show").hide();
|
||||
$("#promocode-show-teamaster").hide();
|
||||
$("#tea-give-to").hide();
|
||||
// 建立 QR Code
|
||||
|
||||
Loading…
Reference in New Issue
Block a user