Menu

## Post extends Model
in package
implements HasMedia uses InteractsWithMedia, SoftDeletes, Common

Post.php : 47

Class Post

Model for managing posts and wall updates.

##### Tags

mixin

### Table of Contents

#### Interfaces

HasMedia

#### Properties

$academic_year_id : int
$academicYear : AcademicYear
$attachment_file : array<string|int, mixed>
$attachment_path : string
$created_at : DateTime
$deleted_at : DateTime
$description : string
$entity_id : int
$entity_name : string
$id : int
$is_posted : int
$post_created_at : DateTime
$postComment : Collection|array<string|int, PostComment>
$postComments : string
$postDetail : PostDetail
$posted_at : DateTime
$school : School
$school_id : int
$standardLink : StandardLink
$status : int
$tag : Collection|array<string|int, Tag>
$updated_at : DateTime
$visibility : string
$visible_for : 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

academicYear() : BelongsTo
  Get the academic year for this post.
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 attachment file paths for this post.
getFilePath() : string
  Get the public URL for a stored file.
getFilePathforDownload() : string
  Get file contents for download optionally from a specific disk.
getPostCommentsAttribute() : array<string|int, mixed>
  Get formatted post comments with additional details.
getRequestIP() : string
  Retrieve the client IP address considering proxies.
is_admin() : bool
  Determine if a user ID belongs to an admin role (usergroup_id == 3).
postComment() : HasMany
  Get all comments on this post.
postDetail() : HasOne
  Get the post details for this post.
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 for this post.
standardLink() : BelongsTo
  Get the standard link for visibility of this post.
tag() : BelongsToMany
  Get the tags associated with this post.
unlinkFilePath() : bool
  Delete a file from the S3 disk.
uploadFile() : string
  Upload a file to storage and return its path.

### Properties

#### $academic_year_id

Post.php : 0
`public int $academic_year_id`

#### $academicYear read-only

Post.php : 0
`public AcademicYear $academicYear`

#### $attachment_file

Post.php : 0
`public array<string|int, mixed> $attachment_file`

#### $attachment_path

Post.php : 0
`public string $attachment_path`

#### $created_at

Post.php : 0
`public DateTime $created_at`

#### $deleted_at

Post.php : 0
`public DateTime $deleted_at`

#### $description

Post.php : 0
`public string $description`

#### $entity_id

Post.php : 0
`public int $entity_id`

#### $entity_name

Post.php : 0
`public string $entity_name`

#### $id

Post.php : 0
`public int $id`

#### $is_posted

Post.php : 0
`public int $is_posted`

#### $post_created_at

Post.php : 0
`public DateTime $post_created_at`

#### $postComment read-only

Post.php : 0
`public Collection|array<string|int, PostComment> $postComment`

#### $postComments

Post.php : 0
`public string $postComments`

#### $postDetail read-only

Post.php : 0
`public PostDetail $postDetail`

#### $posted_at

Post.php : 0
`public DateTime $posted_at`

#### $school read-only

Post.php : 0
`public School $school`

#### $school_id

Post.php : 0
`public int $school_id`

#### $standardLink read-only

Post.php : 0
`public StandardLink $standardLink`

#### $status

Post.php : 0
`public int $status`

#### $tag read-only

Post.php : 0
`public Collection|array<string|int, Tag> $tag`

#### $updated_at

Post.php : 0
`public DateTime $updated_at`

#### $visibility

Post.php : 0
`public string $visibility`

#### $visible_for

Post.php : 0
`public int $visible_for`

#### $casts

Post.php : 77

The attributes that should be cast to native types.

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

#### $dates

Post.php : 84

The attributes that should be mutated to dates.

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

#### $fillable

Post.php : 68

The attributes that are mass assignable.

`protected array<string|int, mixed> $fillable = ['school_id', 'academic_year_id', 'entity_id', 'entity_name', 'description', 'attachment_file', 'visibility', 'visible_for', 'post_created_at', 'is_posted', 'posted_at', 'status']`

#### $table

Post.php : 60

The table associated with the model.

`protected string $table = 'posts'`

### Methods

#### academicYear()

Post.php : 101

Get the academic year for this post.

`public academicYear() : 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()

Post.php : 141

Get the attachment file paths for this post.

`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

#### getPostCommentsAttribute()

Post.php : 158

Get formatted post comments with additional details.

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

##### Return values

array<string|int, mixed>

#### getRequestIP()

Common.php : 93

Retrieve the client IP address considering proxies.

`public getRequestIP() : string`

##### Return values

string —

IP address

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

#### postComment()

Post.php : 131

Get all comments on this post.

`public postComment() : HasMany`

##### Return values

HasMany

#### postDetail()

Post.php : 121

Get the post details for this post.

`public postDetail() : HasOne`

##### Return values

HasOne

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

Post.php : 91

Get the school for this post.

`public school() : BelongsTo`

##### Return values

BelongsTo

#### standardLink()

Post.php : 111

Get the standard link for visibility of this post.

`public standardLink() : BelongsTo`

##### Return values

BelongsTo

#### tag()

Post.php : 193

Get the tags associated with this post.

`public tag() : BelongsToMany`

##### Return values

BelongsToMany

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