public function findOrFail($id, $columns = ['*'])
    {
        $result = $this->find($id, $columns);

        if (is_array($id)) {
            if (count($result) === count(array_unique($id))) {
                return $result;
            }
        } elseif (! is_null($result)) {
            return $result;
        }

        throw (new ModelNotFoundException)->setModel(get_class($this->related), $id);
    }
public function findOrFail($id, $columns = ['*'])
    {
        $result = $this->find($id, $columns);

        if (is_array($id)) {
            if (count($result) === count(array_unique($id))) {
                return $result;
            }
        } elseif (! is_null($result)) {
            return $result;
        }

        throw (new ModelNotFoundException)->setModel(get_class($this->related), $id);
    }
public function findOrFail ( $ id , $ columns = [ '*' ] ) { $ result = $ this -> find ( $ id , $ columns ) ; if ( is_array ( $ id ) ) { if ( count ( $ result ) === count ( array_unique ( $ id ) ) ) { return $ result ; } } elseif ( ! is_null ( $ result ) ) { return $ result ; } throw ( new ModelNotFoundException ) -> setModel ( get_class ( $ this -> related ) , $ id ) ; }
Find a related model by its primary key or throw an exception.

@param  mixed  $id
@param  array  $columns
@return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection

@throws \Illuminate\Database\Eloquent\ModelNotFoundException
Find a related model by its primary key or throw an exception .