42 lines
905 B
PHP
42 lines
905 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Equipo extends Model
|
|
{
|
|
use SoftDeletes;
|
|
protected $table = 'equipos';
|
|
protected $primaryKey = 'id_equipo';
|
|
public $timestamps = true;
|
|
|
|
protected $fillable = [
|
|
'id_club',
|
|
'categoria',
|
|
'division',
|
|
];
|
|
|
|
protected $casts = [
|
|
'id_equipo' => 'integer',
|
|
'id_club' => 'integer',
|
|
];
|
|
|
|
public function club()
|
|
{
|
|
return $this->belongsTo(Club::class, 'id_club', 'id_club');
|
|
}
|
|
|
|
public function jugadores()
|
|
{
|
|
return $this->belongsToMany(Jugador::class, 'jugador_equipo', 'id_equipo', 'id_jugador')
|
|
->withPivot('fecha_alta');
|
|
}
|
|
|
|
public function torneos()
|
|
{
|
|
return $this->belongsToMany(Torneo::class, 'torneo_equipo', 'id_equipo', 'id_torneo');
|
|
}
|
|
}
|