1
0
forked from poc/pds

Enhance get_testing_data response with additional fields as requested_date and null safety

This commit is contained in:
dhanabalan
2025-11-25 16:11:19 +05:30
parent ecac9fe0e9
commit d7b6e8c111

View File

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Models\Plant; use App\Models\Plant;
use App\Models\User; use App\Models\User;
//use Carbon\Carbon;
use Hash; use Hash;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@@ -83,10 +84,11 @@ class UserController extends Controller
//$user = User::where('email', $email)->first(); //$user = User::where('email', $email)->first();
if (Hash::check($header_pass, $existUser->password)) { if (Hash::check($header_pass, $existUser->password)) {
return response()->json([ return response()->json([
'created_at' => $existUser->created_at->format('Y-m-d H:i:s'), 'created_at' => $existUser->created_at->format('Y-m-d H:i:s') ?? "",
'updated_at' => $existUser->updated_at->format('Y-m-d H:i:s'), 'updated_at' => $existUser->updated_at->format('Y-m-d H:i:s') ?? "",
'plant' => (String)$existPlant, 'requested_at' => now()->format('Y-m-d H:i:s') ?? "", //Carbon::now(config('app.timezone'))->format('Y-m-d H:i:s') ?? "",
'email' => $existUser->email, 'plant' => (String)$existPlant ?? "",
'email' => $existUser->email ?? "",
'roles' => $existUser->roles()->pluck('name')->toArray() 'roles' => $existUser->roles()->pluck('name')->toArray()
], 200); ], 200);
} else { } else {