Issue using repository methods??? Twill 3
Can someone please provide any support for the following error:
Declaration of App\Repositories\PostRepository::afterSave($object, $fields) must be compatible with A17\Twill\Repositories\ModuleRepository::afterSave(A17\Twill\Models\Contracts\TwillModelContract $model, array $fields): void
I have been looking to set up a repeater as per the twill guidance docs with the following in my PostRepository (however I'm running into some errors):
public function afterSave($object, $fields)
{
$this->updateRepeater($object, $fields, 'credit', 'Credit');
parent::afterSave($object, $fields);
}
public function getFormFields($object)
{
$fields = parent::getFormFields($object);
$fields = $this->getFormFieldsForRepeater($object, $fields, 'credit', 'Credit');
return $fields;
}
Within my twill.config I have set up the repeater:
'repeaters' => [
'credit' => [
'title' => 'Credit',
'trigger' => 'Add credit',
'component' => 'a17-block-credit'
]
],
So am unsure where this error is coming from, any direction would by greatly appreciated.
Best,
Dan
2 Replies
When overloading methods from parent, make sure that they are indentical in types too.
@Dan make sure to read the error message, it is pretty clear and something you'll see quite often nowadays as php libraries introduce more strict typing.