OutTransaction.php 859B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Models;
  3. use App\Models\Mutation;
  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 OutTransaction extends Model
  9. {
  10. use HasFactory;
  11. protected $fillable = [
  12. 'plat_number',
  13. 'price',
  14. 'entry_transaction_id',
  15. 'type_vehicle_id',
  16. 'user_id',
  17. ];
  18. protected function createdAt(): Attribute
  19. {
  20. return Attribute::make(
  21. get:fn($value) => Carbon::parse($value)->translatedFormat('l d/m/Y')
  22. );
  23. }
  24. protected function platNumber(): Attribute
  25. {
  26. return Attribute::make(
  27. set:fn($value) => strtoupper($value)
  28. );
  29. }
  30. public function mutation()
  31. {
  32. return $this->hasOne(Mutation::class);
  33. }
  34. }