- Updated the PermissionCatalog to remove unnecessary permissions for assignment submissions. - Modified RolePermissionSeeder to align with the updated permissions. - Enhanced useServerTable hook to support resetKeys for Inertia's reset visit option. - Removed obsolete columns.tsx file related to assignment columns. - Revamped assignment index page to utilize InfiniteScroll and improved UI components. - Introduced new assignment status management with enums and updated database schema. - Created GradeSubmissionRequest for validation of submission grading. - Implemented score editing functionality in submission index with real-time updates. - Added accordion component for better UI organization in assignment descriptions.
60 lines
1.6 KiB
PHP
60 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\AssignmentStatus;
|
|
use Illuminate\Database\Eloquent\Attributes\Appends;
|
|
use Illuminate\Database\Eloquent\Attributes\Guarded;
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Spatie\MediaLibrary\HasMedia;
|
|
use Spatie\MediaLibrary\InteractsWithMedia;
|
|
|
|
#[Guarded(['id'])]
|
|
#[Appends(['attachment_url', 'attachment_name'])]
|
|
class Assignment extends Model implements HasMedia
|
|
{
|
|
use HasFactory, InteractsWithMedia, SoftDeletes;
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'deadline' => 'datetime',
|
|
'status' => AssignmentStatus::class,
|
|
];
|
|
}
|
|
|
|
public function registerMediaCollections(): void
|
|
{
|
|
$this->addMediaCollection('assignment_attachment')->singleFile();
|
|
}
|
|
|
|
public function courseClass(): BelongsTo
|
|
{
|
|
return $this->belongsTo(CourseClass::class);
|
|
}
|
|
|
|
public function submissions(): HasMany
|
|
{
|
|
return $this->hasMany(Submission::class);
|
|
}
|
|
|
|
protected function attachmentUrl(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: fn () => $this->getFirstMediaUrl('assignment_attachment') ?: null,
|
|
);
|
|
}
|
|
|
|
protected function attachmentName(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: fn () => $this->getFirstMedia('assignment_attachment')?->file_name,
|
|
);
|
|
}
|
|
}
|