function requireMorphInstance($type, $id, $message = null) { $instance = getMorphInstance($type, $id); if (!$instance) { throw new App\Core\Exceptions\InvalidDataException($message); } return $instance; }
public function validateMorph($name) { $morph_type = $this->input($name . '_type'); $morph_id = $this->input($name . '_id'); if (!$morph_id or !$morph_type) { throw new InvalidDataException(); } $instance = getMorphInstance($morph_type, $morph_id); if (is_null($instance)) { throw new InvalidDataException(); } return $instance; }