TypeMember.php 752B

1234567891011121314151617181920212223242526272829303132333435
  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. 'description',
  14. 'price',
  15. ];
  16. protected function updatedAt(): Attribute
  17. {
  18. return Attribute::make(
  19. get:fn($value) => Carbon::parse($value)->translatedFormat('l d/m/Y')
  20. );
  21. }
  22. protected function price(): Attribute
  23. {
  24. return Attribute::make(
  25. get:fn($value) => (new CurrencyFormatService)->setRupiahFormat($value, true)
  26. );
  27. }
  28. }