Media Model
The Codezone\MediaZone\Models\Media Eloquent model is the core of the package. It stores all uploaded file metadata and crop data.
Table columns
Column | Type | Description |
|---|---|---|
| bigint | Primary key |
| string | Laravel filesystem disk name |
| string | Folder path within the disk |
| string |
|
| string | Original filename without extension |
| string | URL-safe unique slug |
| string | Full path on disk |
| string | Filename with extension |
| integer | Image width in pixels |
| integer | Image height in pixels |
| bigint | File size in bytes |
| string | MIME type category (e.g. |
| string | File extension |
| string | Alt text |
| string | Title |
| text | Long description |
| text | Caption |
| json | Raw EXIF metadata |
| json | Saved crop data keyed by crop key |
| string | Public URL (generated on save) |
Key accessors
thumbnail_url — returns a Glide-transformed thumbnail URL suitable for use in <img> tags or CSS background-image.
size_for_humans — formats size as a human-readable string (e.g. 1.4 MB).
pretty_name — the filename without extension, with underscores and hyphens replaced by spaces.
toMediaArray()
Returns a normalised array representation of the media item, used by the picker and form field when serialising selected media:
To add application-specific keys (e.g. pivot columns), override pivotMediaArray() in your custom model:
See Pivot Columns for the full pattern.
Scopes
scopeSearch($query, $term) — searches name, title, and alt columns.
URL generation
generateUrl() is called automatically by MediaObserver on save. It constructs the public URL from the disk, path, and configured Glide route. For cloud disks listed in config('media.cloud_disks'), the original storage URL is used directly — Glide is bypassed.