123456789101112131415161718192021222324252627 |
- <?php
- namespace App\Transformers;
- use App\Models\NoticeRule;
- use Illuminate\Support\Carbon;
- use League\Fractal\TransformerAbstract;
- class NoticeRuleListTransformer extends TransformerAbstract
- {
- public function transform(NoticeRule $noticeRule)
- {
- $noticeStatus = $noticeRule['notice_status'];
- if($noticeStatus == 0 && $noticeRule['send_time'] && $noticeRule['send_time'] <= Carbon::now()->toDateTimeString()){
- $noticeStatus = 1;
- }
- return [
- 'id' => $noticeRule['id'],
- 'title' => $noticeRule['title'],
- 'cover' => $noticeRule['cover'],
- 'updated_at' => Carbon::parse($noticeRule['updated_at'])->toDateTimeString(),
- 'send_count' => $noticeRule['send_count'],
- 'notice_user_type' => $noticeRule['notice_user_type'],
- 'notice_status' => $noticeStatus,
- ];
- }
- }
|