TypeMember.php 729B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Models;
  3. use App\Services\CurrencyFormatService;
  4. use Carbon\Carbon;
  5. use Illuminate\Database\Eloquent\Casts\Attribute;
  6. use Illuminate\Database\Eloquent\Factories\HasFactory;
  7. use Illuminate\Database\Eloquent\Model;
  8. class TypeMember extends Model
  9. {
  10. use HasFactory;
  11. protected $fillable = [
  12. 'type',
  13. 'price',
  14. ];
  15. protected function updatedAt(): Attribute
  16. {
  17. return Attribute::make(
  18. get:fn($value) => Carbon::parse($value)->translatedFormat('l d/m/Y')
  19. );
  20. }
  21. protected function price(): Attribute
  22. {
  23. return Attribute::make(
  24. get:fn($value) => (new CurrencyFormatService)->setRupiahFormat($value, true)
  25. );
  26. }
  27. }