Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Snowflake casts to Eloquent Model example in docs #188

Conversation

joshhanley
Copy link
Collaborator

When using Snowflakes on models (especially with Livewire), it's good practice to add the snowflake casts to the model as per the bits documentation https://github.com/glhd/bits?tab=readme-ov-file#usage-with-eloquent-models

This PR updates the Snowflake Eloquent Model example to include the Snowflake casts.

use Glhd\Bits\Database\HasSnowflakes;
use Glhd\Bits\Snowflake;

class JobApplication extends Model
{
    use HasSnowflakes; // Add this to your model

    // Any attribute can be cast to a `Snowflake` (or `Sonyflake`)
    protected $casts = [
        'id' => Snowflake::class,
    ];
}

@DanielCoulbourne DanielCoulbourne merged commit 149272a into hirethunk:main Oct 30, 2024
41 checks passed
@joshhanley joshhanley deleted the josh/add-snowflake-casts-to-model-example branch October 31, 2024 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants