'integer', ]; /** @var \App\Models\SimBriefXML Store a cached version of the XML object */ private $xml_instance; /** * Return a SimpleXML object of the $ofp_xml * * @return \App\Models\SimBriefXML|null */ public function getXmlAttribute(): ?SimBriefXML { if (empty($this->attributes['ofp_xml'])) { return null; } if (!$this->xml_instance) { $this->xml_instance = simplexml_load_string( $this->attributes['ofp_xml'], SimBriefXML::class ); } return $this->xml_instance; } /** * Returns a list of images */ public function getImagesAttribute(): Collection { return $this->xml->getImages(); } /** * Return all of the flight plans */ public function getFilesAttribute(): Collection { return $this->xml->getFlightPlans(); } /* * Relationships */ public function aircraft() { return $this->belongsTo(Aircraft::class, 'aircraft_id'); } public function flight() { return $this->belongsTo(Flight::class, 'flight_id'); } public function pirep() { return $this->belongsTo(Pirep::class, 'pirep_id'); } public function user() { return $this->belongsTo(User::class, 'user_id'); } }