@extends('layouts.app') @section('title', 'Materials Management') @section('page-title', 'Materials Management') @section('header-buttons') @auth @if(auth()->user()->teacher) Upload Material @endif @endauth @endsection @section('content') @auth @if(auth()->user()->teacher) @php // Calculate statistics $myMaterialsCount = \App\Models\Material::where('uploaded_by_teacher_id', auth()->user()->teacher->id)->count(); $publishedCount = \App\Models\Material::where('uploaded_by_teacher_id', auth()->user()->teacher->id)->where('published', true)->count(); $unpublishedCount = $myMaterialsCount - $publishedCount; $totalFileSize = \App\Models\Material::where('uploaded_by_teacher_id', auth()->user()->teacher->id)->sum('file_size'); function formatBytes($bytes, $precision = 2) { $units = ['B', 'KB', 'MB', 'GB', 'TB']; $bytes = max($bytes, 0); $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); $pow = min($pow, count($units) - 1); $bytes /= pow(1024, $pow); return round($bytes, $precision) . ' ' . $units[$pow]; } @endphp

{{ $myMaterialsCount }}

Total Materials

{{ $publishedCount }}

Published

{{ $unpublishedCount }}

Unpublished

{{ formatBytes($totalFileSize) }}

Storage Used

@endif @endauth
@auth @if(auth()->user()->teacher) My Study Materials @elseif(auth()->user()->student) Available Study Materials @else All Study Materials @endif @endauth
@auth @if(auth()->user()->teacher)
@else
@endif @endauth
@auth @if(auth()->user()->teacher && $materials->isEmpty() && !request()->hasAny(['class_id', 'published', 'search']))

No Materials Uploaded Yet

Start sharing study materials with your students by uploading your first file.

Upload Your First Material
@else @if($materials->isNotEmpty())
Showing {{ $materials->firstItem() }} - {{ $materials->lastItem() }} of {{ $materials->total() }} materials @if(request()->hasAny(['class_id', 'published', 'search'])) Clear Filters @endif
@if(auth()->user()->teacher) Upload New Material @endif
@endif
@forelse($materials as $material) @empty @endforelse
Material Title Class Details Uploaded By File Information Status Upload Date Actions
@if($material->isPdf()) @elseif($material->isImage()) @elseif($material->isVideo()) @else @endif
{{ Str::limit($material->title, 50) }} @auth @if(auth()->user()->teacher && $material->uploaded_by_teacher_id == auth()->user()->teacher->id) My Upload @endif @endauth
Batch: {{ $material->class->batch->name }} Subject: {{ $material->class->subject->title }}
{{ $material->teacher->user->username }} Teacher
{{ $material->file_extension }}
{{ $material->file_size_formatted }}
{{ $material->published ? 'Published' : 'Draft' }} {{ $material->created_at->format('M d, Y') }}
@auth @if(auth()->user()->teacher && $material->uploaded_by_teacher_id == auth()->user()->teacher->id)
@csrf @method('DELETE')
@endif @endauth
No materials found
@if(request()->hasAny(['class_id', 'published', 'search']))

Try adjusting your filters or search terms

Clear Filters @elseif(auth()->user()->teacher)

Ready to upload your first study material?

Upload Material @endif
@if($materials->hasPages())
Showing {{ $materials->firstItem() }} to {{ $materials->lastItem() }} of {{ $materials->total() }} results
{{ $materials->links() }}
@endif @endif @endauth
@endsection @section('styles') @endsection @section('scripts') @endsection