123456789101112131415161718192021222324252627 |
- <?php
- namespace App\Http\Resources;
- use Illuminate\Http\Resources\Json\JsonResource;
- class AnnouncementResource extends JsonResource
- {
- /**
- * Transform the resource into an array.
- *
- * @param \Illuminate\Http\Request $request
- * @return array
- */
- public function toArray($request)
- {
- $model = $this->resource;
- $area_name = $model->areas->name ?? '';
- if($model->area_id == 0){
- $area_name = '全部';
- }
- $data = [
- 'area_name' => $area_name,
- ];
- return array_merge(parent::toArray($request),$data);
- }
- }
|