✨
Virtue
View on GitHub
  • ✨Virtue
  • 🚀GETTING STARTED
    • Installation
    • Changelog
  • 🛠️MODEL ATTRIBUTES
    • Configuration
    • Cast
    • Database
    • Dispatches Events
    • Fillable
    • Hidden
    • Primary Key
    • Relationships
  • 💻COMMAND ATTRIBUTES
    • Configuration
    • Defining Arguments
    • Defining Options
Powered by GitBook
On this page

Was this helpful?

  1. MODEL ATTRIBUTES

Cast

The Cast attribute allows you to cast your Model's properties to a specific type in the same way that the $casts property does.

use Illuminate\Database\Eloquent\Model;
use WendellAdriel\Virtue\Models\Attributes\Cast;
use WendellAdriel\Virtue\Models\Concerns\Virtue;

#[Cast(field: 'price', type: 'float')]
#[Cast(field: 'expires_at', type: 'immutable_datetime')]
final class Product extends Model
{
    use Virtue;
}
PreviousConfigurationNextDatabase

Last updated 1 year ago

Was this helpful?

🛠️