getRouteKey(); } public function title() { if ($this->title != '') { return $this->title; } if ($this->name != '') { return $this->name; } return 'None'; } public function toArray() { return [ 'id' => $this->getRouteKey(), 'title' => $this->title(), 'user_id' => $this->user_id, 'advertisement_type' => $this->advertisement_type, 'category_id' => $this->category_id, 'subcategory_id' => $this->subcategory_id, 'type' => $this->type, 'title' => $this->title, 'slug' => $this->slug, 'images' => $this->images, 'conditions' => $this->conditions, 'price' => $this->price, 'negotiable' => $this->negotiable, 'brand' => $this->brand, 'additional_features' => $this->additional_features, 'model' => $this->model, 'description' => $this->description, 'location' => $this->location, 'seller_condition' => $this->seller_condition, 'seller_name' => $this->seller_name, 'seller_email' => $this->seller_email, 'seller_mobile' => $this->seller_mobile, 'seller_address' => $this->seller_address, 'upload_folder' => $this->upload_folder, 'latitude' => $this->latitude, 'longitude' => $this->longitude, 'status' => $this->status, 'created_at' => !is_null($this->created_at) ? $this->created_at->format('Y-m-d H:i:s') : null, 'updated_at' => !is_null($this->updated_at) ? $this->updated_at->format('Y-m-d H:i:s') : null, 'meta' => [ 'exists' => $this->exists(), 'link' => $this->itemLink(), 'upload_url' => $this->getUploadURL(''), ], ]; } }