mirror of
https://github.com/v2board/v2board.git
synced 2025-01-30 18:19:12 +08:00
update
This commit is contained in:
parent
ae3b9b7c30
commit
87ae0403e7
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\UserUpdate;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
@ -120,4 +121,23 @@ class UserController extends Controller
|
||||
'data' => true
|
||||
]);
|
||||
}
|
||||
|
||||
public function update (UserUpdate $request) {
|
||||
$updateData = $request->only([
|
||||
'remind_expire',
|
||||
'remind_traffic'
|
||||
]);
|
||||
|
||||
$user = User::find($request->session()->get('id'));
|
||||
if (!$user) {
|
||||
abort(500, '该用户不存在');
|
||||
}
|
||||
if (!$user->update($updateData)) {
|
||||
abort(500, '保存失败');
|
||||
}
|
||||
|
||||
return response([
|
||||
'data' => true
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
29
app/Http/Requests/UserUpdate.php
Normal file
29
app/Http/Requests/UserUpdate.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UserUpdate extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'remind_expire' => 'in:0,1',
|
||||
'remind_traffic' => 'in:0,1'
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'show.in' => '过期提醒格式不正确',
|
||||
'renew.in' => '流量提醒格式不正确'
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user