mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
37 lines
783 B
PHP
37 lines
783 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Requests\Admin\CouponSave;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Coupon;
|
|
use App\Utils\Helper;
|
|
|
|
class CouponController extends Controller
|
|
{
|
|
public function fetch (Request $request) {
|
|
return response([
|
|
'data' => Coupon::all()
|
|
]);
|
|
}
|
|
|
|
public function save (CouponSave $request) {
|
|
$params = $request->only([
|
|
'name',
|
|
'type',
|
|
'value',
|
|
'expired_at',
|
|
'limit_use'
|
|
]);
|
|
|
|
$params['code'] = Helper::guid();
|
|
if (!Coupon::create($params)) {
|
|
abort(500, '创建失败');
|
|
}
|
|
|
|
return response([
|
|
'data' => true
|
|
]);
|
|
}
|
|
} |