protected function fieldsFromModel($id, array $fields)
    {
        $post = Post::findOrFail($id);
        $fieldNames = array_keys(array_except($fields, ['tags']));
        $fields = ['id' => $id];
        foreach ($fieldNames as $field) {
            $fields[$field] = $post->{$field};
        }
        $fields['tags'] = $post->tags()->pluck('tag')->all();

        return $fields;
    }
protected function fieldsFromModel($id, array $fields)
    {
        $post = Post::findOrFail($id);
        $fieldNames = array_keys(array_except($fields, ['tags']));
        $fields = ['id' => $id];
        foreach ($fieldNames as $field) {
            $fields[$field] = $post->{$field};
        }
        $fields['tags'] = $post->tags()->pluck('tag')->all();

        return $fields;
    }
protected function fieldsFromModel ( $ id , array $ fields ) { $ post = Post :: findOrFail ( $ id ) ; $ fieldNames = array_keys ( array_except ( $ fields , [ 'tags' ] ) ) ; $ fields = [ 'id' => $ id ] ; foreach ( $ fieldNames as $ field ) { $ fields [ $ field ] = $ post -> { $ field } ; } $ fields [ 'tags' ] = $ post -> tags ( ) -> pluck ( 'tag' ) -> all ( ) ; return $ fields ; }
Return the field values from the model.

@param int $id
@param array $fields
@return array
Return the field values from the model .