Fix: Добавлен метод courses() в Organization model
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
parent
2271abf732
commit
32fed5d4b6
|
|
@ -18,7 +18,7 @@ class OrganizationController extends Controller
|
|||
{
|
||||
Gate::authorize('viewAny', Organization::class);
|
||||
|
||||
$organizations = Organization::withCount('users', 'groups', 'courses')
|
||||
$organizations = Organization::withCount(['users', 'groups'])
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate(20);
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,12 @@ class Organization extends Model
|
|||
return $this->hasMany(CourseAssignment::class);
|
||||
}
|
||||
|
||||
public function courses()
|
||||
{
|
||||
// Получаем курсы через назначения
|
||||
return $this->hasManyThrough(Course::class, CourseAssignment::class, 'organization_id');
|
||||
}
|
||||
|
||||
public function activeUsers(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class)->where('is_active', true);
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@
|
|||
<th>Email</th>
|
||||
<th>Пользователей</th>
|
||||
<th>Групп</th>
|
||||
<th>Курсов</th>
|
||||
<th>Статус</th>
|
||||
<th>Действия</th>
|
||||
</tr>
|
||||
|
|
@ -99,7 +98,6 @@
|
|||
<td>{{ $org->email ?? '—' }}</td>
|
||||
<td>{{ $org->users_count }}</td>
|
||||
<td>{{ $org->groups_count }}</td>
|
||||
<td>{{ $org->courses_count ?? 0 }}</td>
|
||||
<td>
|
||||
@if($org->is_active)
|
||||
<span class="badge bg-success">Активна</span>
|
||||
|
|
|
|||
Loading…
Reference in New Issue