Closed JamesFreeman closed 2 years ago
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! 👏🏼
Good solution! Thanks, I'll tag it right now
Quick bug fix for the following issue: https://github.com/spatie/laravel-view-models/pull/39#issuecomment-1011069714