Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lepikhinb/laravel-fluent


https://github.com/lepikhinb/laravel-fluent

Last synced: 5 days ago
JSON representation

Awesome Lists containing this project

README

        

# Laravel Fluent

The package provides an expressive "fluent" way to define model attributes. It automatically builds casts at the runtime and adds a native autocompletion to the models' properties.

## Introduction
With `laravel-fluent`, you can define Model attributes as you would do with any other class. The values will be transformed to the corresponding types depending on the native types of the properties.

Before:
```php
'collection',
'price' => 'float',
'available' => 'integer',
];
}
```

After:
```php
hasMany(Feature::class);
}

public function category(): BelongsTo
{
return $this->belongsTo(Category::class);
}
}
```

Relations method declaration is still required for proper autocompletion. However, the package can automatically resolve relations from attributes.

```php