Vehicle.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. class Vehicle extends Model
  6. {
  7. const COMUNE = 1;
  8. const MOTORIZZAZIONE_CIVILE = 2;
  9. const ALTRO = 3;
  10. const MARCA_ALTRO = 67;
  11. const DESTINAZIONE_USO_PRIVATO = 1;
  12. const DESTINAZIONE_USO_LOCAZIONE_SENZA_CONDUCENTE = 2;
  13. const DESTINAZIONE_USO_TAXI = 3;
  14. const DESTINAZIONE_USO_SERVIZO_PUBBLICO_DI_LINEA = 4;
  15. const DESTINAZIONE_USO_TRASPORTO_MERCI = 5;
  16. const DESTINAZIONE_USO_CONTO_PROPRIO = 6;
  17. const DESTINAZIONE_USO_CONTO_TERZI = 7;
  18. const DESTINAZIONE_USO_PUBBLICO = 8;
  19. const DESTINAZIONE_USO_SOCCORSO_POLIZIA = 9;
  20. const AUTOVETTURA = 1;
  21. const CICLO_MOTORE = 3;
  22. const QUADRICICLO = 4;
  23. const MOTOCICLO = 5;
  24. const VELOCIPEDE = 6;
  25. const AUTOBUS = 7;
  26. const TRATTORE_SEMIRIMORCHIO = 8;
  27. const AUTOTURISMO = 10;
  28. const RIMORCHIO = 14;
  29. const AUTOCARRO = 16;
  30. const AUTOVETTURA_CON_RIMORCHIO = 17;
  31. const AUTOSNODATO_O_AUTOARTICOLATO = 18;
  32. const MOTOCARRO_O_MOTOFURGONE = 19;
  33. const AUTOTRENO_CON_RIMORCHIO = 20;
  34. use HasFactory;
  35. public $timestamps = false;
  36. protected $table = 'fcf_reports_vehicles';
  37. protected $fillable = [
  38. 'tipo_id',
  39. 'marca_id',
  40. 'marca_altro',
  41. 'modello_id',
  42. 'modello_altro',
  43. 'colore',
  44. 'targa',
  45. 'carta_circolazione',
  46. 'carta_circolazione_rilasciata_da' ,
  47. 'carta_circolazione_rilasciata_da_altro',
  48. 'foreign_country' ,
  49. 'carta_circolazione_rilasciata_da_di_foreign_country' ,
  50. 'carta_circolazione_rilasciata_da_di_foreign_localita',
  51. 'carta_circolazione_rilasciata_da_di' ,
  52. 'carta_circolazione_rilasciata_il',
  53. 'data_ultima_revisione' ,
  54. 'cilindrata' ,
  55. 'peso_complessivo',
  56. 'destinazione_uso',
  57. 'destinazione_uso_api',
  58. 'marca_modello_api',
  59. 'state',
  60. 'created',
  61. 'created_by',
  62. 'updated',
  63. 'updated_by',
  64. 'locked' ,
  65. 'locked_by',
  66. 'kw',
  67. 'numero_telaio',
  68. 'massa_complessiva'
  69. ];
  70. public function marca()
  71. {
  72. return $this->belongsTo(\App\Models\MarcaVeicolo::class, 'marca_id', 'id');
  73. }
  74. public function modello()
  75. {
  76. return $this->belongsTo(\App\Models\ModelloVeicolo::class, 'modello_id', 'id');
  77. }
  78. public function tipo()
  79. {
  80. return $this->belongsTo(\App\Models\TipoVeicolo::class, 'tipo_id', 'id');
  81. }
  82. public function carta_circolazione_rilasciata_da_di_value()
  83. {
  84. return $this->belongsTo(\App\Models\LocationTown::class, 'carta_circolazione_rilasciata_da_di');
  85. }
  86. public function carta_circolazione_rilasciata_da_di_foreign_localita_value()
  87. {
  88. return $this->belongsTo(\App\Models\LocationTown::class, 'carta_circolazione_rilasciata_da_di_foreign_localita', 'id');
  89. }
  90. public function getCartaCircolazioneRilasciataDaDiValueAttribute()
  91. {
  92. return $this->belongsTo(
  93. \App\Models\LocationTown::class,
  94. 'carta_circolazione_rilasciata_da_di'
  95. )->value('title');
  96. }
  97. }