generated from glhd/laravel-package-template
-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem? Please describe.
Yes, I am using inside a laravel application, and cant do relationships, fails at line 1287
$value = (int) ($value instanceof BackedEnum ? $value->value : $value);
File: laravel/framework/src/Illuminate/Database/Query/Builder.php
Describe the solution you'd like
Be able to cast snowflake to int
Describe alternatives you've considered
It works if i stop casting account_id to snowflake, but I dont think thats ideal
Additional context
Code example:
// account model
class Account extends Model
{
use HasFactory;
use SoftDeletes;
use HasSnowflakes;
protected $fillable = [
'wallet_id',
'bank_id',
'name',
'balance',
];
protected $casts = [
'id' => Snowflake::class,
'wallet_id' => Snowflake::class,
];
...
// card model
class Card extends Model
{
use HasFactory;
use SoftDeletes;
use HasSnowflakes;
protected $fillable = [
'account_id',
'brand_id',
'name',
'limit',
'digits',
'digital',
'credit',
'international',
];
protected $casts = [
'id' => Snowflake::class,
'account_id' => Snowflake::class,
'digital' => 'boolean',
'credit' => 'boolean',
'international' => 'boolean',
];
....
// controller
$cards = Card::query()
->ofWallet(auth('web')->user()->currentWallet)
->with([
'account' => function ($query) {
$query->with([
'bank',
]);
},
'brand',
])
->get();
...Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request