Exemplo n.º 1
0
function requireMorphInstance($type, $id, $message = null)
{
    $instance = getMorphInstance($type, $id);
    if (!$instance) {
        throw new App\Core\Exceptions\InvalidDataException($message);
    }
    return $instance;
}
Exemplo n.º 2
0
 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;
 }