Agrego archivos iniciales
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class Evento extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $table = 'eventos';
|
||||
protected $primaryKey = 'id_evento';
|
||||
public $timestamps = true;
|
||||
public $incrementing = false;
|
||||
|
||||
public const FASE_REGULAR = 0;
|
||||
public const FASE_CUARTOS = 1;
|
||||
public const FASE_SEMIS = 2;
|
||||
public const FASE_FINAL = 3;
|
||||
|
||||
protected $fillable = [
|
||||
'id_evento',
|
||||
'nombre_evento',
|
||||
'fecha_evento',
|
||||
'hora_inicio',
|
||||
'hora_fin',
|
||||
'sede',
|
||||
'id_equipo_local',
|
||||
'id_equipo_visitante',
|
||||
'marcador_local',
|
||||
'marcador_visitante',
|
||||
'id_torneo',
|
||||
'precio',
|
||||
'limite_qr_jugador',
|
||||
'fase',
|
||||
'numero_partido_bracket',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'id_evento' => 'string',
|
||||
'id_torneo' => 'integer',
|
||||
'id_equipo_local' => 'integer',
|
||||
'id_equipo_visitante' => 'integer',
|
||||
'marcador_local' => 'integer',
|
||||
'marcador_visitante' => 'integer',
|
||||
'precio' => 'decimal:2',
|
||||
'fase' => 'integer',
|
||||
'numero_partido_bracket' => 'integer',
|
||||
];
|
||||
|
||||
public function getFechaEventoAttribute($value)
|
||||
{
|
||||
return $value ? Carbon::parse($value) : null;
|
||||
}
|
||||
|
||||
public function getHoraInicioAttribute($value)
|
||||
{
|
||||
return $value ? Carbon::parse($value) : null;
|
||||
}
|
||||
|
||||
public function getHoraFinAttribute($value)
|
||||
{
|
||||
return $value ? Carbon::parse($value) : null;
|
||||
}
|
||||
|
||||
public function torneo()
|
||||
{
|
||||
return $this->belongsTo(Torneo::class, 'id_torneo');
|
||||
}
|
||||
|
||||
public function equipoLocal()
|
||||
{
|
||||
return $this->belongsTo(Equipo::class, 'id_equipo_local', 'id_equipo');
|
||||
}
|
||||
|
||||
public function equipoVisitante()
|
||||
{
|
||||
return $this->belongsTo(Equipo::class, 'id_equipo_visitante', 'id_equipo');
|
||||
}
|
||||
|
||||
public function pagos()
|
||||
{
|
||||
return $this->hasMany(PagoMp::class, 'event_id', 'id_evento');
|
||||
}
|
||||
|
||||
public function qrCodes()
|
||||
{
|
||||
return $this->hasMany(QrCode::class, 'id_evento', 'id_evento');
|
||||
}
|
||||
|
||||
public function jugadoresPuntos()
|
||||
{
|
||||
return $this->hasMany(EventoJugador::class, 'id_evento', 'id_evento');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user