You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
635 B
29 lines
635 B
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\CouponTemplate;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Http\Request;
|
|
|
|
class CouponTemplateController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$today = Carbon::today()->toDateString();
|
|
|
|
// 只查询未过期的
|
|
// 标记已经领取过的
|
|
$templates = CouponTemplate::query()
|
|
->withCount(['coupons' => function ($b) {
|
|
|
|
$b->where('user_id', auth()->id());
|
|
}])
|
|
->where('end_date', '>=', $today)
|
|
->get();
|
|
|
|
|
|
return view('coupons.templates', compact('templates'));
|
|
}
|
|
}
|