class Resort extends Model
{
protected $hidden = [
'owner_id', 'created_at', 'updated_at'
];
public function getInformation() {
return $this->hasOne(ResortInformation::class);
}
public function getPictures() {
return $this->hasMany(ResortGallery::class);
}
}
and this controller
class ResortController extends Controller
{
use App\Resort;
public function getResortDetails($id) {
$resort = Resort::find($id);
$resort->information = $resort->getInformation;
$resort->images = $resort->getPictures;
return response()->json(
$resort
);
}
}
How do I append my getInformation and getPictures data into the $resort object?
everytime I use $resort->getInformation or $resort->getPictures, the json is duplicating it
API that returns JSON
I have this Resort model
and this controller
How do I append my getInformation and getPictures data into the $resort object?
everytime I use $resort->getInformation or $resort->getPictures, the json is duplicating it
the example is like this
this is the exact response the behavior is adding "get_information" and "get_pictures" even though I have not stated it to show