laravel-json-api / eloquent

Serialize Eloquent models to JSON API resources
MIT License
12 stars 15 forks source link

Make all fields extend Attribute class #4

Closed martianatwork closed 3 years ago

martianatwork commented 3 years ago

I really don't know a lot about the code base but while checking i saw that All fields don't have same methods. This makes life hard while developing packages or extending the fields.

it will be great if they have common methods such as column, name, fill, serializeUsing, etc.

lindyhopchris commented 3 years ago

Not all fields are attributes, so it wouldn't make sense for them to all implement the Attribute interface!

This is no different from Eloquent models. You do $model->fill($attributes) to fill column values, but you do $post->author()->associate($user) or $post->tags()->saveMany($tags) to modify relationships.

Attributes and relationships are fully documented, so it's clear what methods are available on each.