Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lepikhinb/laravel-fluent
https://github.com/lepikhinb/laravel-fluent
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/lepikhinb/laravel-fluent
- Owner: lepikhinb
- License: mit
- Created: 2021-08-23T18:28:46.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-07-03T23:17:46.000Z (over 1 year ago)
- Last Synced: 2024-11-06T06:05:24.134Z (7 days ago)
- Language: PHP
- Size: 40 KB
- Stars: 551
- Watchers: 11
- Forks: 25
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
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