Laravel Fluent The package provides an expressive "fluent" way to define model attributes. It automatically builds casts at the runtime and…
Laravel Fluent The package provides an expressive "fluent" way to define model attributes. It automatically builds casts at the runtime and…
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.
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:
'collection',
'price' => 'float',
'available' => 'integer',
];
}After:
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
class Product extends Model
{
use Fluent;
#[HasMany(Feature::class)]
public Collection $features;
#[BelongsTo]
public Category $category;
}composer testThe MIT License (MIT). Please see License File for more information.
No open issues yet, or sync has not completed.