mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-15 21:41:03 +08:00
normalize-logging
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Http\Resources\UserResource;
|
||||
use App\Repositories\ExamRepository;
|
||||
use App\Repositories\UserRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ExamController extends Controller
|
||||
{
|
||||
@@ -110,4 +111,13 @@ class ExamController extends Controller
|
||||
return $this->success($resource);
|
||||
}
|
||||
|
||||
public function progress(Request $request)
|
||||
{
|
||||
$result = $this->repository->getUserExamProgress(Auth::id());
|
||||
$resource = new ExamUserResource($result);
|
||||
return $resource;
|
||||
// dd($resource->response()->getData(true));
|
||||
return $this->success($resource);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ExamUserResource extends JsonResource
|
||||
{
|
||||
public $preserveKeys = true;
|
||||
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
@@ -21,10 +23,14 @@ class ExamUserResource extends JsonResource
|
||||
'id' => $this->id,
|
||||
'status' => $this->status,
|
||||
'status_text' => $this->statusText,
|
||||
'created_at' => $this->created_at->format('Y-m-d H:i:s'),
|
||||
'created_at' => formatDatetime($this->created_at),
|
||||
'progress' => $this->when($this->progress, $this->progress),
|
||||
'begin' => formatDatetime($this->begin),
|
||||
'end' => formatDatetime($this->end),
|
||||
'user' => new UserResource($this->whenLoaded('user')),
|
||||
'exam' => new ExamResource($this->whenLoaded('exam')),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class UserResource extends JsonResource
|
||||
'email' => $this->email,
|
||||
'username' => $this->username,
|
||||
'status' => $this->status,
|
||||
'added' => $this->added,
|
||||
'added' => formatDatetime($this->added),
|
||||
'class' => $this->class,
|
||||
'class_text' => $this->class_text,
|
||||
'avatar' => $this->avatar,
|
||||
|
||||
Reference in New Issue
Block a user