12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace App\Repositories\Transformers\Dianli;
- use App\Repositories\Enums\ModelStatusEnum;
- use App\Repositories\Models\Exam\PaperResult;
- use Carbon\Carbon;
- use League\Fractal\TransformerAbstract;
- use App\Repositories\Models\Dianli\Task;
- /**
- * Class TaskTransformer.
- *
- * @package namespace App\Repositories\Transformers\Dianli;
- */
- class TaskTransformer extends TransformerAbstract
- {
- /**
- * Transform the Task entity.
- *
- * @param \App\Repositories\Models\Dianli\Task $model
- *
- * @return array
- */
- public function transform(Task $model)
- {
- return [
- 'id' => (int)$model->id,
- 'name' => $model->name,
- 'type' => $model->type,
- 'start_date' => $model->start_date,
- 'end_date' => $model->end_date,
- 'weeks' => $model->weeks,
- 'assign_admin_ids' => $model->assign_admin_ids,
- 'assign_admin' => $model->assign_admin,
- 'admin' => $model->admin,
- 'paper_id' => $model->paper_id,
- 'allot_nums' => PaperResult::query()->where('paper_id', $model->paper_id)->where('status', ModelStatusEnum::OK)->count(),
- 'paper' => $model->paper,
- 'status' => $model->status,
- 'created_at' => $model->created_at->format(Carbon::DEFAULT_TO_STRING_FORMAT),
- 'updated_at' => $model->updated_at->format(Carbon::DEFAULT_TO_STRING_FORMAT)
- ];
- }
- }
|