Vehicle.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. 'state',
  58. 'created',
  59. 'created_by',
  60. 'updated',
  61. 'updated_by',
  62. 'locked' ,
  63. 'locked_by',
  64. ];
  65. public function marca()
  66. {
  67. return $this->belongsTo(\App\Models\MarcaVeicolo::class, 'marca_id', 'id');
  68. }
  69. public function modello()
  70. {
  71. return $this->belongsTo(\App\Models\ModelloVeicolo::class, 'modello_id', 'id');
  72. }
  73. public function tipo()
  74. {
  75. return $this->belongsTo(\App\Models\TipoVeicolo::class, 'tipo_id', 'id');
  76. }
  77. public function carta_circolazione_rilasciata_da_di_value()
  78. {
  79. return $this->belongsTo(\App\Models\LocationTown::class, 'carta_circolazione_rilasciata_da_di');
  80. }
  81. public function carta_circolazione_rilasciata_da_di_foreign_localita_value()
  82. {
  83. return $this->belongsTo(\App\Models\LocationTown::class, 'carta_circolazione_rilasciata_da_di_foreign_localita', 'id');
  84. }
  85. public function getCartaCircolazioneRilasciataDaDiValueAttribute()
  86. {
  87. return $this->belongsTo(
  88. \App\Models\LocationTown::class,
  89. 'carta_circolazione_rilasciata_da_di'
  90. )->value('title');
  91. }
  92. }