feat: initial project setup with Laravel 12 and Filament v4
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Casts;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Morilog\Jalali\Jalalian;
|
||||
|
||||
class JalaliDatetime implements CastsAttributes
|
||||
{
|
||||
public function __construct(
|
||||
private string $format = 'Y/m/d H:i'
|
||||
) {}
|
||||
|
||||
public function get(Model $model, string $key, mixed $value, array $attributes): ?string
|
||||
{
|
||||
if (is_null($value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return Jalalian::fromCarbon(Carbon::parse($value))->format($this->format);
|
||||
} catch (\Throwable $e) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function set(Model $model, string $key, mixed $value, array $attributes): mixed
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user