OutTransaction.php 743B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace App\Models;
  3. use Carbon\Carbon;
  4. use Illuminate\Database\Eloquent\Casts\Attribute;
  5. use Illuminate\Database\Eloquent\Factories\HasFactory;
  6. use Illuminate\Database\Eloquent\Model;
  7. class OutTransaction extends Model
  8. {
  9. use HasFactory;
  10. protected $fillable = [
  11. 'plat_number',
  12. 'price',
  13. 'entry_transaction_id',
  14. 'type_vehicle_id',
  15. 'user_id',
  16. ];
  17. protected function createdAt(): Attribute
  18. {
  19. return Attribute::make(
  20. get:fn($value) => Carbon::parse($value)->translatedFormat('l d/m/Y')
  21. );
  22. }
  23. protected function platNumber(): Attribute
  24. {
  25. return Attribute::make(
  26. set:fn($value) => strtoupper($value)
  27. );
  28. }
  29. }