mirror of
https://github.com/10h30/Test-Eloquent-Relationships.git
synced 2026-06-05 15:07:42 +09:00
21 lines
427 B
PHP
21 lines
427 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Team extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = ['name', 'size', 'country_id'];
|
|
|
|
public function users()
|
|
{
|
|
// TASK: fix this by adding some extra code
|
|
return $this->belongsToMany(User::class,'team_user')->withPivot('position', 'created_at');
|
|
}
|
|
|
|
}
|