Menu

## Homework extends Model
in package
uses SoftDeletes, HasFactory, Common

Homework.php : 49

Class Homework

Model for managing homework assignments.

##### Tags

mixin

### Table of Contents

#### Properties

$academic_year_id : int
$academicYear : AcademicYear
$attachment : string|null
$attachment_path : string
$attachment_type : string
$created_at : DateTime
$created_by : int|null
$createdBy : User
$date : DateTime
$deleted_at : DateTime
$description : string
$finished_count : int
$homeworkApproval : HomeworkApproval
$id : int
$pending_count : int
$school : School
$school_id : int
$section_id : int
$standardLink : StandardLink
$standardLink_id : int
$studentHomework : StudentHomework
$subject : Subject
$subject_id : int
$teacher : User
$teacher_id : int|null
$updated_at : DateTime
$updated_by : int|null
$updatedBy : User
$viewers : Collection
$casts : array<string|int, mixed>
  The attributes that should be mutated to dates.
$fillable : array<string|int, mixed>
  The attributes that are mass assignable.
$table : mixed

#### Methods

academicYear() : BelongsTo
  Get the academic year associated with the homework.
createdBy() : BelongsTo
  Get the user who created the homework.
eventImagePath() : string|null
  Resolve default event image path by category.
fileUpload() : string
  Write raw file contents to storage.
getAttachmentPathAttribute() : string
  Get the attachment file path.
getAttachmentTypeAttribute() : string
  Get the attachment file type (image, audio, video, pdf, or empty).
getFilePath() : string
  Get the public URL for a stored file.
getFilePathforDownload() : string
  Get file contents for download optionally from a specific disk.
getFinishedCountAttribute() : int
  Get the count of finished student homework submissions.
getPendingCountAttribute() : int
  Get the count of pending student homework submissions.
getRequestIP() : string
  Retrieve the client IP address considering proxies.
homeworkApproval() : HasOne
  Get the homework approval associated with this homework.
is_admin() : bool
  Determine if a user ID belongs to an admin role (usergroup_id == 3).
putContents() : string
  Save plain contents to storage with public visibility.
putContentsByFilename() : string
  Save a file with a specific filename to storage.
romanToInteger() : int|null
  Convert a Roman numeral string to an integer.
school() : BelongsTo
  Get the school associated with the homework.
standardLink() : BelongsTo
  Get the standard link associated with the homework.
studentHomework() : HasOne
  Get the student homework associated with this homework.
subject() : BelongsTo
  Get the subject associated with the homework.
teacher() : BelongsTo
  Get the teacher associated with the homework.
unlinkFilePath() : bool
  Delete a file from the S3 disk.
updatedBy() : BelongsTo
  Get the user who last updated the homework.
uploadFile() : string
  Upload a file to storage and return its path.
viewers() : MorphMany
  Get the student history records for this homework.

### Properties

#### $academic_year_id

Homework.php : 0
`public int $academic_year_id`

#### $academicYear read-only

Homework.php : 0
`public AcademicYear $academicYear`

#### $attachment

Homework.php : 0
`public string|null $attachment`

#### $attachment_path

Homework.php : 0
`public string $attachment_path`

#### $attachment_type

Homework.php : 0
`public string $attachment_type`

#### $created_at

Homework.php : 0
`public DateTime $created_at`

#### $created_by

Homework.php : 0
`public int|null $created_by`

#### $createdBy read-only

Homework.php : 0
`public User $createdBy`

#### $date

Homework.php : 0
`public DateTime $date`

#### $deleted_at

Homework.php : 0
`public DateTime $deleted_at`

#### $description

Homework.php : 0
`public string $description`

#### $finished_count

Homework.php : 0
`public int $finished_count`

#### $homeworkApproval read-only

Homework.php : 0
`public HomeworkApproval $homeworkApproval`

#### $id

Homework.php : 0
`public int $id`

#### $pending_count

Homework.php : 0
`public int $pending_count`

#### $school read-only

Homework.php : 0
`public School $school`

#### $school_id

Homework.php : 0
`public int $school_id`

#### $section_id

Homework.php : 0
`public int $section_id`

#### $standardLink read-only

Homework.php : 0
`public StandardLink $standardLink`

#### $standardLink_id

Homework.php : 0
`public int $standardLink_id`

#### $studentHomework read-only

Homework.php : 0
`public StudentHomework $studentHomework`

#### $subject read-only

Homework.php : 0
`public Subject $subject`

#### $subject_id

Homework.php : 0
`public int $subject_id`

#### $teacher read-only

Homework.php : 0
`public User $teacher`

#### $teacher_id

Homework.php : 0
`public int|null $teacher_id`

#### $updated_at

Homework.php : 0
`public DateTime $updated_at`

#### $updated_by

Homework.php : 0
`public int|null $updated_by`

#### $updatedBy read-only

Homework.php : 0
`public User $updatedBy`

#### $viewers read-only

Homework.php : 0
`public Collection $viewers`

#### $casts

Homework.php : 73

The attributes that should be mutated to dates.

`protected array<string|int, mixed> $casts = ['date' => 'datetime', 'deleted_at' => 'datetime']`

#### $fillable

Homework.php : 62

The attributes that are mass assignable.

`protected array<string|int, mixed> $fillable = ['school_id', 'academic_year_id', 'standardLink_id', 'section_id', 'subject_id', 'description', 'attachment', 'date', 'created_by', 'updated_by', 'teacher_id']`

#### $table

Homework.php : 55
`protected mixed $table = 'homeworks'`

### Methods

#### academicYear()

Homework.php : 93

Get the academic year associated with the homework.

`public academicYear() : BelongsTo`

##### Return values

BelongsTo

#### createdBy()

Homework.php : 123

Get the user who created the homework.

`public createdBy() : BelongsTo`

##### Return values

BelongsTo

#### eventImagePath()

Common.php : 118

Resolve default event image path by category.

`public eventImagePath(string $category, string $image) : string|null`

##### Parameters

$category : string

  Event category slug

$image : string

  Unused parameter kept for compatibility

##### Return values

string|null —

Public URL for the event image or null on failure

#### fileUpload()

Common.php : 71

Write raw file contents to storage.

`public fileUpload(string $folder, string $file) : string`

##### Parameters

$folder : string

  Target path (including filename)

$file : string

  Raw file contents

##### Return values

string —

Storage path of the written file

#### getAttachmentPathAttribute()

Homework.php : 153

Get the attachment file path.

`public getAttachmentPathAttribute() : string`

##### Return values

string

#### getAttachmentTypeAttribute()

Homework.php : 222

Get the attachment file type (image, audio, video, pdf, or empty).

`public getAttachmentTypeAttribute() : string`

##### Return values

string

#### getFilePath()

Common.php : 24

Get the public URL for a stored file.

`public getFilePath(string $file) : string`

##### Parameters

$file : string

  Storage path

##### Return values

string —

Publicly accessible URL or empty string on failure

#### getFilePathforDownload()

Common.php : 253

Get file contents for download optionally from a specific disk.

`public getFilePathforDownload([string $disk = '' ], string $file) : string`

##### Parameters

$disk : string = ''

  Storage disk name

$file : string

  File path

##### Return values

string —

File contents

#### getFinishedCountAttribute()

Homework.php : 193

Get the count of finished student homework submissions.

`public getFinishedCountAttribute() : int`

##### Return values

int

#### getPendingCountAttribute()

Homework.php : 207

Get the count of pending student homework submissions.

`public getPendingCountAttribute() : int`

##### Return values

int

#### getRequestIP()

Common.php : 93

Retrieve the client IP address considering proxies.

`public getRequestIP() : string`

##### Return values

string —

IP address

#### homeworkApproval()

Homework.php : 173

Get the homework approval associated with this homework.

`public homeworkApproval() : HasOne`

##### Return values

HasOne

#### is_admin()

Common.php : 304

Determine if a user ID belongs to an admin role (usergroup_id == 3).

`public static is_admin(int|string $userid) : bool`

##### Parameters

$userid : int|string

  User identifier

##### Return values

bool —

True if user is admin, false otherwise

#### putContents()

Common.php : 157

Save plain contents to storage with public visibility.

`public putContents(string $folder, string $contents) : string`

##### Parameters

$folder : string

  Destination path

$contents : string

  File contents

##### Return values

string —

Storage path of the saved file

#### putContentsByFilename()

Common.php : 182

Save a file with a specific filename to storage.

`public putContentsByFilename(string $folder, UploadedFile $contents, string $filename) : string`

##### Parameters

$folder : string

  Destination folder

$contents : UploadedFile

  File instance

$filename : string

  Target filename

##### Return values

string —

Storage path of the saved file

#### romanToInteger()

Common.php : 205

Convert a Roman numeral string to an integer.

`public romanToInteger(string $roman) : int|null`

##### Parameters

$roman : string

  Roman numeral value

##### Return values

int|null —

Converted integer or null on failure

#### school()

Homework.php : 83

Get the school associated with the homework.

`public school() : BelongsTo`

##### Return values

BelongsTo

#### standardLink()

Homework.php : 103

Get the standard link associated with the homework.

`public standardLink() : BelongsTo`

##### Return values

BelongsTo

#### studentHomework()

Homework.php : 163

Get the student homework associated with this homework.

`public studentHomework() : HasOne`

##### Return values

HasOne

#### subject()

Homework.php : 113

Get the subject associated with the homework.

`public subject() : BelongsTo`

##### Return values

BelongsTo

#### teacher()

Homework.php : 133

Get the teacher associated with the homework.

`public teacher() : BelongsTo`

##### Return values

BelongsTo

#### unlinkFilePath()

Common.php : 282

Delete a file from the S3 disk.

`public unlinkFilePath(string $file) : bool`

##### Parameters

$file : string

  File path on S3

##### Return values

bool —

True after attempting deletion

#### updatedBy()

Homework.php : 143

Get the user who last updated the homework.

`public updatedBy() : BelongsTo`

##### Return values

BelongsTo

#### uploadFile()

Common.php : 47

Upload a file to storage and return its path.

`public uploadFile(string $folder, UploadedFile $file) : string`

##### Parameters

$folder : string

  Target folder path

$file : UploadedFile

  File to upload

##### Return values

string —

Storage path for the uploaded file

#### viewers()

Homework.php : 183

Get the student history records for this homework.

`public viewers() : MorphMany`

##### Return values

MorphMany

## Search results