Skip to main content

Overview

The Series model represents TV series in the application. It uses Laravel Scout for full-text search and integrates with Spatie Laravel Data for type-safe DTOs. Model Path: app/Models/Series.php
Table: series
Primary Key: series_id (non-incrementing)

Database Schema

series_id
integer
required
Primary key for the series
num
integer
required
Unique series number
name
string
required
Name of the series
cover
string
URL to the series cover image
plot
text
Series plot/description
cast
text
Cast members of the series
director
string
Director of the series
genre
string
Genre classification
releaseDate
string
Release date of the series
last_modified
datetime
Last modification timestamp (immutable)
rating
string
Rating value
rating_5based
decimal
Rating on a 5-point scale (precision: 3,1)
backdrop_path
array
JSON array of backdrop image paths
youtube_trailer
string
YouTube trailer URL or ID
episode_run_time
string
Episode runtime information
category_id
string
Category identifier
created_at
timestamp
Record creation timestamp
updated_at
timestamp
Record last update timestamp

Fillable Attributes

All fields are mass assignable via the fillable array:
[
    'name',
    'series_id',
    'cover',
    'plot',
    'cast',
    'director',
    'genre',
    'releaseDate',
    'last_modified',
    'rating',
    'rating_5based',
    'backdrop_path',
    'youtube_trailer',
    'episode_run_time',
    'category_id',
]

Type Casts

The model casts the following attributes:
  • series_idinteger
  • rating_5baseddecimal:1
  • backdrop_pathAsArrayObject
  • last_modifiedimmutable_datetime

Relationships

Watchlists

Polymorphic one-to-many relationship with the Watchlist model.
public function watchlists(): MorphMany
Returns all watchlist entries for this series. Usage:
$series = Series::find(1);
$watchlists = $series->watchlists;
The Series model uses Laravel Scout for full-text search. The following fields are indexed:
  • name
  • plot
  • cast
  • director
  • genre
Example:
$results = Series::search('Breaking Bad')->get();

Data Transfer Object

The model integrates with SeriesData DTO class via the WithData trait:
protected $dataClass = SeriesData::class;
This enables type-safe data transfer and validation.

Build docs developers (and LLMs) love