Files
Test-Eloquent-Relationships/app/Models/Team.php
T

21 lines
427 B
PHP
Raw Normal View History

2021-11-22 08:05:15 +02:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Team extends Model
{
use HasFactory;
2021-11-26 20:34:53 +01:00
protected $fillable = ['name', 'size', 'country_id'];
2021-11-22 08:05:15 +02:00
public function users()
{
// TASK: fix this by adding some extra code
2025-04-04 21:43:07 +09:00
return $this->belongsToMany(User::class,'team_user')->withPivot('position', 'created_at');
2021-11-22 08:05:15 +02:00
}
}