SHARE
TWEET

Untitled

a guest Jul 17th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. namespace XhunterModels;
  3. use IlluminateDatabaseEloquentModel;
  4. class Registro extends Model
  5. {
  6. protected $table = 'registro_emergencia';
  7.  
  8. protected $fillable = [
  9.     'personal_id',
  10.     'emergencias_id',
  11.     'sub_estaciones',
  12.     'emergencia',
  13.     'descripci├│n_emergencia',
  14.     'direcci├│n',
  15.     'num_escoltas',
  16.     'personas_atendidas',
  17.     'hora_salida',
  18.     'hora_retorno',
  19.     'fecha_reporte'
  20. ];
  21.  
  22. public function personal()
  23. {
  24.     return $this->belongsTo(Personal::class);
  25. }
  26.  
  27. public function vehiculos()
  28. {
  29.     return $this->belongsToMany(Vehiculo::class);
  30. }
  31.  
  32. public function emergencias()
  33. {
  34.     return $this->belongsTo(Emergencia::class);
  35. }
  36.  
  37. #region Accesores
  38. public function getNamePersonalAttribute()
  39. {
  40.     return "{$this->personal->nombre_completo}";
  41. }
  42.  
  43. public function getNameVehiculoAttribute()
  44. {
  45.     return "{$this->vehiculos->vehiculo_unidad}";
  46. }
  47.  
  48. public function getNameEmergenciaAttribute()
  49. {
  50.     return "{$this->emergencias->tipo_emergencia}";
  51. }
  52. #endregion }
  53.      
  54. <?php
  55. namespace XhunterModels;
  56. use IlluminateDatabaseEloquentModel;
  57. class Vehiculo extends Model
  58. {
  59. protected $fillable = [
  60.     'imagen',
  61.     'vehiculo_unidad',
  62.     'num_serie',
  63.     'inventario',
  64.     'no_motor',
  65.     'marca',
  66.     'modelo',
  67.     'placas',
  68.     'estatus_vehiculo'
  69. ];
  70.  
  71. public function registro()
  72. {
  73.     return $this->belongsToMany(Registro::class);
  74. }}
  75.      
  76. <?php
  77. use IlluminateSupportFacadesSchema;
  78. use IlluminateDatabaseSchemaBlueprint;
  79. use IlluminateDatabaseMigrationsMigration;
  80. class CreateReportesUnidades extends Migration
  81. {
  82. public function up()
  83. {
  84.     Schema::create('reportes_unidades', function (Blueprint $table) {
  85.         $table->increments('id');
  86.         $table->integer('registro_id')->unsigned();
  87.   $table->foreign('registro_id')->references('id')->on('registro_emergencia');
  88.         $table->integer('vehiculos_id')->unsigned();
  89.         $table->foreign('vehiculos_id')->references('id')->on('vehiculos');
  90.         $table->timestamps();
  91.     });
  92. }
  93.  
  94. /**
  95.  * Reverse the migrations.
  96.  *
  97.  * @return void
  98.  */
  99. public function down()
  100. {
  101.     Schema::dropIfExists('reportes_unidades');
  102. }
  103. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top