Menu

## StudentHomework extends Model
in package
uses SoftDeletes, Common

StudentHomework.php : 35

Class StudentHomework

Model for managing student homework submissions.

##### Tags

mixin

### Table of Contents

#### Properties

$attachment : array<string|int, mixed>|null
$attachment_path : array<string|int, mixed>
$checked_by : int|null
$checked_on : DateTime|null
$comments : string|null
$created_at : DateTime
$deleted_at : DateTime
$homework : Homework
$homework_id : int
$id : int
$status : int
$student : User
$submitted_on : DateTime
$teacher : User|null
$updated_at : DateTime
$user_id : int
$casts : array<string|int, mixed>
  The attributes that should be cast to native types.
$dates : array<string|int, mixed>
  The attributes that should be mutated to dates.
$fillable : array<string|int, mixed>
  The attributes that are mass assignable.
$table : string
  The table associated with the model.

#### Methods

eventImagePath() : string|null
  Resolve default event image path by category.
fileUpload() : string
  Write raw file contents to storage.
getAttachmentPathAttribute() : array<string|int, mixed>
  Get the full file paths for all attachments.
getFilePath() : string
  Get the public URL for a stored file.
getFilePathforDownload() : string
  Get file contents for download optionally from a specific disk.
getRequestIP() : string
  Retrieve the client IP address considering proxies.
homework() : BelongsTo
  Get the homework assignment for this submission.
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.
student() : BelongsTo
  Get the student who submitted this homework.
teacher() : BelongsTo
  Get the teacher who checked this homework submission.
unlinkFilePath() : bool
  Delete a file from the S3 disk.
uploadFile() : string
  Upload a file to storage and return its path.

### Properties

#### $attachment

StudentHomework.php : 0
`public array<string|int, mixed>|null $attachment`

#### $attachment_path

StudentHomework.php : 0
`public array<string|int, mixed> $attachment_path`

#### $checked_by

StudentHomework.php : 0
`public int|null $checked_by`

#### $checked_on

StudentHomework.php : 0
`public DateTime|null $checked_on`

#### $comments

StudentHomework.php : 0
`public string|null $comments`

#### $created_at

StudentHomework.php : 0
`public DateTime $created_at`

#### $deleted_at

StudentHomework.php : 0
`public DateTime $deleted_at`

#### $homework read-only

StudentHomework.php : 0
`public Homework $homework`

#### $homework_id

StudentHomework.php : 0
`public int $homework_id`

#### $id

StudentHomework.php : 0
`public int $id`

#### $status

StudentHomework.php : 0
`public int $status`

#### $student read-only

StudentHomework.php : 0
`public User $student`

#### $submitted_on

StudentHomework.php : 0
`public DateTime $submitted_on`

#### $teacher read-only

StudentHomework.php : 0
`public User|null $teacher`

#### $updated_at

StudentHomework.php : 0
`public DateTime $updated_at`

#### $user_id

StudentHomework.php : 0
`public int $user_id`

#### $casts

StudentHomework.php : 70

The attributes that should be cast to native types.

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

#### $dates

StudentHomework.php : 63

The attributes that should be mutated to dates.

`protected array<string|int, mixed> $dates = ['submitted_on', 'checked_on', 'deleted_at']`

#### $fillable

StudentHomework.php : 54

The attributes that are mass assignable.

`protected array<string|int, mixed> $fillable = ['homework_id', 'user_id', 'attachment', 'submitted_on', 'checked_by', 'checked_on', 'status', 'comments']`

#### $table

StudentHomework.php : 46

The table associated with the model.

`protected string $table = 'student_homework'`

### Methods

#### 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()

StudentHomework.php : 107

Get the full file paths for all attachments.

`public getAttachmentPathAttribute() : array<string|int, mixed>`

##### Return values

array<string|int, mixed>

#### 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

#### getRequestIP()

Common.php : 93

Retrieve the client IP address considering proxies.

`public getRequestIP() : string`

##### Return values

string —

IP address

#### homework()

StudentHomework.php : 77

Get the homework assignment for this submission.

`public homework() : BelongsTo`

##### Return values

BelongsTo

#### 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

#### student()

StudentHomework.php : 87

Get the student who submitted this homework.

`public student() : BelongsTo`

##### Return values

BelongsTo

#### teacher()

StudentHomework.php : 97

Get the teacher who checked this homework submission.

`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

#### 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

## Search results