Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Data Property duplication #41

Merged
merged 4 commits into from
Jan 13, 2022

Conversation

JamesFreeman
Copy link
Contributor

Quick bug fix for the following issue: #39 (comment)

@asurcodes
Copy link

asurcodes commented Jan 12, 2022

This issue can be solved by creating a temporary variable and then ignoring it but it feels hacky, I totally support this chage:

<?php

namespace App\Api\ViewModels;

use Spatie\ViewModels\ViewModel;

class BaseViewModel extends ViewModel
{
    protected $ignore = ['content'];

    public $content;

    public function message(): string
    {
        return __('models.base.message');
    }

    public function data(): array
    {
        return $this->content->toArray();
    }
}

Thanks for the blazing fast response to my comment BTW! 👏🏼

@brendt brendt merged commit ce61390 into spatie:main Jan 13, 2022
@brendt
Copy link
Contributor

brendt commented Jan 13, 2022

Good solution! Thanks, I'll tag it right now

@brendt
Copy link
Contributor

brendt commented Jan 13, 2022

@JamesFreeman JamesFreeman deleted the feature/fix-naming-issue branch January 13, 2022 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants