Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace XhunterModels;
- use IlluminateDatabaseEloquentModel;
- class Registro extends Model
- {
- protected $table = 'registro_emergencia';
- protected $fillable = [
- 'personal_id',
- 'emergencias_id',
- 'sub_estaciones',
- 'emergencia',
- 'descripción_emergencia',
- 'dirección',
- 'num_escoltas',
- 'personas_atendidas',
- 'hora_salida',
- 'hora_retorno',
- 'fecha_reporte'
- ];
- public function personal()
- {
- return $this->belongsTo(Personal::class);
- }
- public function vehiculos()
- {
- return $this->belongsToMany(Vehiculo::class);
- }
- public function emergencias()
- {
- return $this->belongsTo(Emergencia::class);
- }
- #region Accesores
- public function getNamePersonalAttribute()
- {
- return "{$this->personal->nombre_completo}";
- }
- public function getNameVehiculoAttribute()
- {
- return "{$this->vehiculos->vehiculo_unidad}";
- }
- public function getNameEmergenciaAttribute()
- {
- return "{$this->emergencias->tipo_emergencia}";
- }
- #endregion }
- <?php
- namespace XhunterModels;
- use IlluminateDatabaseEloquentModel;
- class Vehiculo extends Model
- {
- protected $fillable = [
- 'imagen',
- 'vehiculo_unidad',
- 'num_serie',
- 'inventario',
- 'no_motor',
- 'marca',
- 'modelo',
- 'placas',
- 'estatus_vehiculo'
- ];
- public function registro()
- {
- return $this->belongsToMany(Registro::class);
- }}
- <?php
- use IlluminateSupportFacadesSchema;
- use IlluminateDatabaseSchemaBlueprint;
- use IlluminateDatabaseMigrationsMigration;
- class CreateReportesUnidades extends Migration
- {
- public function up()
- {
- Schema::create('reportes_unidades', function (Blueprint $table) {
- $table->increments('id');
- $table->integer('registro_id')->unsigned();
- $table->foreign('registro_id')->references('id')->on('registro_emergencia');
- $table->integer('vehiculos_id')->unsigned();
- $table->foreign('vehiculos_id')->references('id')->on('vehiculos');
- $table->timestamps();
- });
- }
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::dropIfExists('reportes_unidades');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement