CKeditor + word counter + Image Input + Taggable VUE3 Better Xss Sanitizer Handle Video Youtube + Image Upload + Inline Image from url Better Image Input component with reset, easizer resize Full Responsive BO
47 lines
1.5 KiB
PHP
47 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Casts;
|
|
|
|
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
//phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceAfterLastUsed
|
|
//phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed
|
|
class NiceDate implements CastsAttributes
|
|
{
|
|
/**
|
|
* Return a nice human readable carbon date.
|
|
*
|
|
* @param Model $model
|
|
* @param string $key
|
|
* @param mixed $value
|
|
* @param array $attributes
|
|
* @return string
|
|
* @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
|
|
* @phpcs:disable Squiz.Commenting.FunctionComment.ScalarTypeHintMissing
|
|
*/
|
|
public function get($model, $key, $value, $attributes)
|
|
{
|
|
$value = Carbon::parse($value);
|
|
return $value->isToday() ?
|
|
trans('Aujourd\'hui à :time', [
|
|
'time' => $value->isoFormat('HH:mm')
|
|
]) : $value->isoFormat('YYYY/MM/DD HH:mm');
|
|
}
|
|
|
|
/**
|
|
* Parse a date string to a date time date.
|
|
*
|
|
* @param Model $model
|
|
* @param string $key
|
|
* @param mixed $value
|
|
* @param array $attributes
|
|
* @return string
|
|
* @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
|
|
* @phpcs:disable Squiz.Commenting.FunctionComment.ScalarTypeHintMissing
|
|
*/
|
|
public function set($model, $key, $value, $attributes)
|
|
{
|
|
return Carbon::parse($value)->isoFormat('YYYY/MM/DD HH:mm');
|
|
}
|
|
}
|