- Add Vue debug mode - Show club.messages in reverse order + fix nice date formatter to using server timezone when json cast + fix get last message date for left column
41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Casts;
|
|
|
|
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class NiceDate implements CastsAttributes
|
|
{
|
|
/**
|
|
* Accessor
|
|
*
|
|
* @param mixed $model
|
|
* @param mixed $key
|
|
* @param mixed $value
|
|
* @param mixed $attributes
|
|
* @return mixed
|
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed
|
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceAfterLastUsed
|
|
*/
|
|
public function get($model, $key, $value, $attributes)
|
|
{
|
|
$value = Carbon::parse($value);
|
|
return $value->isToday() ?
|
|
trans('Aujourd\'hui à :time', ['time' => $value->format('H:i')]) : $value->format('Y/m/d H:i');
|
|
}
|
|
|
|
/**
|
|
* Mutator
|
|
*
|
|
* @param mixed $model
|
|
* @param mixed $key
|
|
* @param mixed $value
|
|
* @param mixed $attributes
|
|
* @return mixed
|
|
*/
|
|
public function set($model, $key, $value, $attributes)
|
|
{
|
|
return Carbon::parse($value)->format('Y-m-d H:i:s');
|
|
}
|
|
}
|