PurchaseDetail.php 714B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace App\Models;
  3. use App\Services\HelperService;
  4. use Illuminate\Database\Eloquent\Casts\Attribute;
  5. use Illuminate\Database\Eloquent\Factories\HasFactory;
  6. use Illuminate\Database\Eloquent\Model;
  7. class PurchaseDetail extends Model
  8. {
  9. use HasFactory;
  10. protected $fillable = [
  11. 'price',
  12. 'ppn',
  13. 'qty',
  14. 'purchase_number',
  15. 'product_number'
  16. ];
  17. protected function price(): Attribute
  18. {
  19. return Attribute::make(
  20. get:fn($value) => HelperService::setRupiahFormat($value, true)
  21. );
  22. }
  23. protected function ppn(): Attribute
  24. {
  25. return Attribute::make(
  26. get:fn($value) => $value . '%'
  27. );
  28. }
  29. }