Vehicle.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. use HasFactory;
  21. public $timestamps = false;
  22. protected $table = 'fcf_reports_vehicles';
  23. protected $fillable = [
  24. 'tipo_id',
  25. 'marca_id',
  26. 'marca_altro',
  27. 'modello_id',
  28. 'modello_altro',
  29. 'colore',
  30. 'obbligo_targa',
  31. 'targa',
  32. 'carta_circolazione',
  33. 'carta_circolazione_rilasciata_da' ,
  34. 'carta_circolazione_rilasciata_da_altro',
  35. 'foreign_country' ,
  36. 'carta_circolazione_rilasciata_da_di_foreign_country' ,
  37. 'carta_circolazione_rilasciata_da_di_foreign_localita',
  38. 'carta_circolazione_rilasciata_da_di' ,
  39. 'carta_circolazione_rilasciata_il',
  40. 'data_ultima_revisione' ,
  41. 'cilindrata' ,
  42. 'peso_complessivo',
  43. 'destinazione_uso',
  44. 'state',
  45. 'created',
  46. 'created_by',
  47. 'updated',
  48. 'updated_by',
  49. 'locked' ,
  50. 'locked_by',
  51. ];
  52. public function marca()
  53. {
  54. return $this->belongsTo(\App\Models\MarcaVeicolo::class, 'marca_id', 'id');
  55. }
  56. public function modello()
  57. {
  58. return $this->belongsTo(\App\Models\ModelloVeicolo::class, 'modello_id', 'id');
  59. }
  60. public function tipo()
  61. {
  62. return $this->belongsTo(\App\Models\TipoVeicolo::class, 'tipo_id', 'id');
  63. }
  64. public function carta_circolazione_rilasciata_da_di_value()
  65. {
  66. return $this->belongsTo(\App\Models\LocationTown::class, 'carta_circolazione_rilasciata_da_di');
  67. }
  68. public function carta_circolazione_rilasciata_da_di_foreign_localita_value()
  69. {
  70. return $this->belongsTo(\App\Models\LocationTown::class, 'carta_circolazione_rilasciata_da_di_foreign_localita', 'id');
  71. }
  72. public function getCartaCircolazioneRilasciataDaDiValueAttribute()
  73. {
  74. return $this->belongsTo(
  75. \App\Models\LocationTown::class,
  76. 'carta_circolazione_rilasciata_da_di'
  77. )->value('title');
  78. }
  79. }