You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for this amazing package.
I suggest to add custom Casting to convert the dates in get or set automaticlly. as you know the dates should be stored as gregorian in storage but displayed as hijri.
for example in your model add the HijriDate cast:
/** * The attributes that should be cast. * * @var array */protected$casts = [
'created_at' => HijriDate::class,
];
HijriDate:
classHijriDateimplementsCastsAttributes
{
/** * Cast the given value. * * @param \Illuminate\Database\Eloquent\Model $model * @param string $key * @param mixed $value * @param array $attributes * @return mixed */publicfunctionget($model, $key, $value, $attributes)
{
// Here convert gregorian to hijri;return$value;
}
/** * Prepare the given value for storage. * * @param \Illuminate\Database\Eloquent\Model $model * @param string $key * @param array $value * @param array $attributes * @return mixed */publicfunctionset($model, $key, $value, $attributes)
{
// Here convert hijri to gregorian;return$value;
}
}
and if you add some tests it will be great 👍
The text was updated successfully, but these errors were encountered:
سلام عليكم ورحمة الله وبركاته
Thanks for this amazing package.
I suggest to add custom
Casting
to convert the dates inget
orset
automaticlly. as you know the dates should be stored as gregorian in storage but displayed as hijri.for example in your model add the
HijriDate
cast:and if you add some tests it will be great 👍
The text was updated successfully, but these errors were encountered: