Laravel package to Convert laravel date to our Amazing 💝 Hjri date {ummul qura and vice versa} . to look like [ الخميس ، ٢٢ ربيع الآخر ، ١٤٤١ - ٠٧:٤٩ مساءً]
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:
class HijriDate implements CastsAttributes
{
/**
* Cast the given value.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param mixed $value
* @param array $attributes
* @return mixed
*/
public function get($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
*/
public function set($model, $key, $value, $attributes)
{
// Here convert hijri to gregorian;
return $value;
}
}
سلام عليكم ورحمة الله وبركاته
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:HijriDate:
and if you add some tests it will be great :+1: