123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace App\Http\Resources;
- use App\Models\Advertisement;
- use Illuminate\Http\Resources\Json\JsonResource;
- class AdvertisementResource 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 = '全部';
- }
- $showChildren = false;
- if($model->advertisement_position_slug == config('systemConfig.sort.advertisement_position.config.footer.slug') && $model->pid == 0){
- $showChildren = true;
- }
- $data = [
- 'area_name' => $area_name,
- 'show_children' => $showChildren
- ];
- return array_merge(parent::toArray($request),$data);
- }
- }
|