laravel
laravel copied to clipboard
docs: there is no Hash::make method
Hi,
I'm fallowing the documentation about attribute hydration and found out that either there is a bug (the method does not exist) or the documentation is wrong.
In docs there is this code example:
Hash::make('coordinates')->fillUsing(
static function ($model, $column, $value, array $validatedData) {
$model->fill([
"{$column}_longitude" = $value['long'],
"{$column}_latitude" = $value['lat'],
]);
}
);
In documentation it is not specified what namespace the class Hash is in and the only class I found with that name was LaravelJsonApi\Core\Json\Hash. It didn't work, the method make is undefined.
Somehow, while writing this issue, I found the class LaravelJsonApi\Eloquent\Fields\ArrayHash and tried that instead - it worked.
Please fix the documentation, replace Hash::make with ArrayHash::make (if I'm right about this).
Hey! What's the bug you're getting? The code snippet you've shared doesn't use a Hash class, so I'm not sure what the problem is and where it's originating from?
@lindyhopchris As I wrote, the snippet is from documentation page. :wink: So, if it really should use ArrayHash instead of Hash , the documentation page is wrong and the snippet in it needs to be updated with the correct class.
Ah ok, sorry I read it in a rush between other work. I can see the problem now - yes it is meant to be ArrayHash but I'll re-check the docs when I get a chance and fix it. Thanks for raising!