mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
no message
This commit is contained in:
1 parent
3ef1279614
commit
d1a4af660c
3 files changed
+37
No files matched your search
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
|
class UserController extends Controller
|
||||||
|
{
|
||||||
|
public function update($id, Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
$validator = Validator::make($request->all(), [
|
||||||
|
'data.work_start' => 'required',
|
||||||
|
'data.work_end' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if($validator->fails()){
|
||||||
|
return response()->json($validator->errors(), 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = User::find($id);
|
||||||
|
|
||||||
|
$user->update($request->all()['data']);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'User updated successfully',
|
||||||
|
'user' => $user
|
||||||
|
], 201);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -21,6 +21,8 @@ class User extends Authenticatable
|
|||||||
'name',
|
'name',
|
||||||
'email',
|
'email',
|
||||||
'password',
|
'password',
|
||||||
|
'work_start',
|
||||||
|
'work_end',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
|
|||||||
@@ -100,6 +100,8 @@ Route::middleware(['auth:sanctum'])->group(function () {
|
|||||||
Route::post('/v1/blockers', BlockerController::class . '@store');
|
Route::post('/v1/blockers', BlockerController::class . '@store');
|
||||||
Route::put('/v1/blockers/{id}', BlockerController::class . '@update');
|
Route::put('/v1/blockers/{id}', BlockerController::class . '@update');
|
||||||
Route::delete('/v1/blockers/{id}', BlockerController::class . '@delete');
|
Route::delete('/v1/blockers/{id}', BlockerController::class . '@delete');
|
||||||
|
|
||||||
|
Route::put('/v1/users/{id}', UserController::class . '@update');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::post('/v1/tokens/create', function (Request $request) {
|
Route::post('/v1/tokens/create', function (Request $request) {
|
||||||
|
|||||||
Reference in new issue
Block a user