Bånder

PlaylistController extends Controller
in package

Attributes
#[Middleware]
['force.json']
#[Prefix]
'/playlists'

Table of Contents

Methods

addCollaborator()  : JsonResponse
Add a collaborator to a playlist
addSong()  : mixed
Add a song to a playlist
clone()  : PlaylistResource
Clone an existing playlist
createSmartPlaylist()  : mixed
Create a smart playlist
destroy()  : mixed
Delete a playlist
favorite()  : mixed
Record a playlist favorite
index()  : AnonymousResourceCollection<string|int, JsonPaginator<string|int, PlaylistResource>>
Get a paginated collection of playlists
recordPlay()  : mixed
Record a playlist play
recordView()  : JsonResponse
Record a playlist view
removeCollaborator()  : JsonResponse
Remove a collaborator from a playlist
removeSong()  : mixed
Remove a song from a playlist
reorderSongs()  : mixed
Reorder songs in a playlist
share()  : mixed
Record a playlist share
show()  : mixed
Get a specific playlist with detailed information
statistics()  : PlaylistStatistic
Get playlist statistics
store()  : mixed
Create a new playlist
syncSmartPlaylist()  : JsonResponse
Update smart playlist rules
update()  : PlaylistResource
Update an existing playlist
updateSmartRules()  : PlaylistResource
Synchronize smart playlist
denyWithStatus()  : mixed
gateCheckExecuteJob()  : mixed
gateCheckViewDashboard()  : mixed
noContent()  : mixed

Methods

addCollaborator()

Add a collaborator to a playlist

public addCollaborator(Request $request, Playlist $playlist) : JsonResponse

Adds a user as a collaborator to the playlist with the specified role. Collaborators can have 'editor' or 'contributor' permissions.

Parameters
$request : Request
$playlist : Playlist
Attributes
#[Post]
'{playlist}/collaborators'
'api.playlist.collaborators.store'
['auth:sanctum', 'ability:' . TokenAbility::ACCESS_API->value]
Return values
JsonResponse

addSong()

Add a song to a playlist

public addSong(Playlist $playlist, Song $song) : mixed

Adds a song to the specified playlist at the next available position. Prevents duplicate songs from being added to the same playlist.

Parameters
$playlist : Playlist

The playlist to add the song to

$song : Song

The song to add

Tags
throws
AuthorizationException

When a user cannot update a playlist

throws
ModelNotFoundException

When a playlist or song is not found

response

array{message: string}

Attributes
#[Post]
'{playlist}/songs/{song}'
'api.playlist.add-song'
['auth:sanctum', 'ability:' . TokenAbility::ACCESS_API->value]

clone()

Clone an existing playlist

public clone(Playlist $playlist) : PlaylistResource

Creates a copy of the playlist with all songs and their positions. The cloned playlist is owned by the current user and is private by default.

Parameters
$playlist : Playlist
Attributes
#[Post]
'{playlist}/clone'
'api.playlist.clone'
['auth:sanctum', 'ability:' . TokenAbility::ACCESS_API->value]
Return values
PlaylistResource

createSmartPlaylist()

Create a smart playlist

public createSmartPlaylist(CreateSmartPlaylistRequest $request) : mixed

Creates a new smart playlist that automatically populates with songs matching the specified rules and criteria.

Parameters
$request : CreateSmartPlaylistRequest

Request containing playlist data and rules

Tags
throws
Throwable

When smart playlist creation fails

response

PlaylistResource

status

201

Attributes
#[Post]
'/smart'
'api.playlist.smart-create'
['auth:sanctum', 'ability:' . TokenAbility::ACCESS_API->value]

destroy()

Delete a playlist

public destroy(Playlist $playlist) : mixed

Permanently removes a playlist and all its associated data including song associations, statistics, and collaborator relationships.

Parameters
$playlist : Playlist

The playlist to delete

Tags
throws
AuthorizationException

When user cannot delete playlist

throws
ModelNotFoundException

When playlist is not found

status

204

Attributes
#[Delete]
'{playlist}'
'api.playlist.destroy'
['auth:sanctum', 'ability:' . TokenAbility::ACCESS_API->value]

favorite()

Record a playlist favorite

public favorite(Playlist $playlist) : mixed

Increments the favorite counter when users mark the playlist as favorite. Used for tracking user engagement and playlist quality metrics.

Parameters
$playlist : Playlist

The playlist that was favorited

Tags
throws
AuthorizationException

When user cannot view playlist

response

array{message: string}

Attributes
#[Post]
'{playlist}/statistics/record/favorite'
'api.playlist.statistics.record-favorite'
['auth:sanctum', 'ability:' . TokenAbility::ACCESS_API->value]

index()

Get a paginated collection of playlists

public index(Request $request) : AnonymousResourceCollection<string|int, JsonPaginator<string|int, PlaylistResource>>

Returns playlists owned by the authenticated user and public playlists that are visible to all users. Results are paginated for performance.

Parameters
$request : Request
Attributes
#[Get]
''
'api.playlist.index'
['auth:sanctum', 'ability:' . TokenAbility::ACCESS_API->value]
Return values
AnonymousResourceCollection<string|int, JsonPaginator<string|int, PlaylistResource>>

recordPlay()

Record a playlist play

public recordPlay(Playlist $playlist) : mixed

Increments the play counter when the playlist is played. Used for tracking playlist engagement and popularity metrics.

Parameters
$playlist : Playlist

The playlist that was played

Tags
throws
AuthorizationException

When a user cannot view a playlist

response

array{message: string}

Attributes
#[Post]
'{playlist}/statistics/record/play'
'api.playlist.statistics.record-play'
['auth:sanctum', 'ability:' . TokenAbility::ACCESS_API->value]

recordView()

Record a playlist view

public recordView(Playlist $playlist) : JsonResponse
Parameters
$playlist : Playlist
Attributes
#[Post]
'{playlist}/statistics/record/view'
'api.playlist.statistics.record-view'
['auth:sanctum', 'ability:' . TokenAbility::ACCESS_API->value]
Return values
JsonResponse

removeCollaborator()

Remove a collaborator from a playlist

public removeCollaborator(Playlist $playlist, User $user) : JsonResponse

Removes a user's collaborator access from the playlist. Only playlist owners can remove collaborators.

Parameters
$playlist : Playlist
$user : User
Attributes
#[Delete]
'{playlist}/collaborators/{user}'
'api.playlist.collaborators.destroy'
['auth:sanctum', 'ability:' . TokenAbility::ACCESS_API->value]
Return values
JsonResponse

removeSong()

Remove a song from a playlist

public removeSong(Playlist $playlist, Song $song) : mixed

Removes a song from the playlist and automatically reorders remaining songs to maintain consecutive positioning.

Parameters
$playlist : Playlist

The playlist to remove the song from

$song : Song

The song to remove

Tags
throws
AuthorizationException

When a user cannot update a playlist

throws
ModelNotFoundException

When a playlist or song is not found

response

array{message: string}

Attributes
#[Delete]
'{playlist}/songs/{song}'
'api.playlist.remove-song'
['auth:sanctum', 'ability:' . TokenAbility::ACCESS_API->value]

reorderSongs()

Reorder songs in a playlist

public reorderSongs(Request $request, Playlist $playlist) : mixed

Updates the position of songs in the playlist based on the provided ordered array of song IDs. All song IDs must exist in the playlist.

Parameters
$request : Request

Request containing ordered song IDs

$playlist : Playlist

The playlist to reorder

Tags
throws
AuthorizationException

When user cannot update playlist

throws
ValidationException

When song IDs are invalid

response

array{message: string}

Attributes
#[Post]
'{playlist}/reorder'
'api.playlist.reorder'
['auth:sanctum', 'ability:' . TokenAbility::ACCESS_API->value]

share()

Record a playlist share

public share(Playlist $playlist) : mixed

Increments the share counter when the playlist is shared. Used for tracking viral and social engagement metrics.

Parameters
$playlist : Playlist

The playlist that was shared

Tags
throws
AuthorizationException

When user cannot view playlist

response

array{message: string}

Attributes
#[Post]
'{playlist}/statistics/record/share'
'api.playlist.statistics.record-share'
['auth:sanctum', 'ability:' . TokenAbility::ACCESS_API->value]

show()

Get a specific playlist with detailed information

public show(PlaylistShowRequest $request, Playlist $playlist) : mixed

Retrieves a single playlist with comprehensive information including songs, artists, album data, and cover art. Authorization is enforced.

Parameters
$request : PlaylistShowRequest

Request for playlist access

$playlist : Playlist

The playlist to retrieve

Tags
throws
AuthorizationException

When a user cannot view a playlist

throws
ModelNotFoundException

When a playlist is not found

response

PlaylistResource

Attributes
#[Get]
'{playlist}'
'api.playlist.show'
['auth:sanctum', 'ability:' . TokenAbility::ACCESS_API->value]

statistics()

Get playlist statistics

public statistics(Playlist $playlist) : PlaylistStatistic

Retrieves comprehensive statistics for the playlist including view count, play count, shares, and favorites.

Parameters
$playlist : Playlist
Attributes
#[Get]
'{playlist}/statistics'
'api.playlist.statistics'
['auth:sanctum', 'ability:' . TokenAbility::ACCESS_API->value]
Return values
PlaylistStatistic

store()

Create a new playlist

public store(CreatePlaylistRequest $request) : mixed

Creates a new playlist owned by the authenticated user with the provided name, description, and visibility settings.

Parameters
$request : CreatePlaylistRequest

Request containing validated playlist data

Tags
throws
Throwable

When playlist creation fails

response

PlaylistResource

status

201

Attributes
#[Post]
''
'api.playlist.store'
['auth:sanctum', 'ability:' . TokenAbility::ACCESS_API->value]

syncSmartPlaylist()

Update smart playlist rules

public syncSmartPlaylist(Playlist $playlist) : JsonResponse

Updates the rules for a smart playlist and re-syncs the song list to match the new criteria.

Parameters
$playlist : Playlist
Attributes
#[Post]
'{playlist}/smart/sync'
'api.playlist.smart-sync'
['auth:sanctum', 'ability:' . TokenAbility::ACCESS_API->value]
Return values
JsonResponse

update()

Update an existing playlist

public update(UpdatePlaylistRequest $request, Playlist $playlist) : PlaylistResource

Updates playlist metadata including name, description, and visibility settings. Only playlist owners and authorized collaborators can update playlists.

Parameters
$request : UpdatePlaylistRequest

Request containing validated update data

$playlist : Playlist

The playlist to update

Tags
throws
AuthorizationException

When a user cannot update a playlist

throws
ModelNotFoundException

When a playlist is not found

response

PlaylistResource

Attributes
#[Put]
'{playlist}'
'api.playlist.update'
['auth:sanctum', 'ability:' . TokenAbility::ACCESS_API->value]
Return values
PlaylistResource

updateSmartRules()

Synchronize smart playlist

public updateSmartRules(UpdateSmartPlaylistRulesRequest $request, Playlist $playlist) : PlaylistResource

Manually triggers a sync of the smart playlist to refresh the song list based on the current rules and available songs in the library.

Parameters
$request : UpdateSmartPlaylistRulesRequest
$playlist : Playlist
Attributes
#[Put]
'{playlist}/smart'
'api.playlist.smart-update'
['auth:sanctum', 'ability:' . TokenAbility::ACCESS_API->value]
Return values
PlaylistResource

denyWithStatus()

protected denyWithStatus(string $message, int $status) : mixed
Parameters
$message : string
$status : int

gateCheckExecuteJob()

protected gateCheckExecuteJob() : mixed

gateCheckViewDashboard()

protected gateCheckViewDashboard() : mixed

        
On this page

Search results