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.
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'created_at' => HijriDate::class,
];
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;
}
}