mgoigfer / nova-spotify-track-field
A Spotify track field to use in your Laravel Nova apps.
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Language:JavaScript
Type:package
Requires
- php: >=7.1.0
- mgoigfer/laravel-spotify-wrapper: *
- mgoigfer/nova-spotify-auth-tool: *
This package is auto-updated.
Last update: 2024-10-27 14:05:56 UTC
README
This Nova package adds a Spotify track field. Under the hood it uses the mgoigfer/laravel-spotify-wrapper and mgoigfer/nova-spotify-auth-tool packages.
You can add tracks from the Spotify Web API to your database.
Installation
First, you must install mgoigfer/laravel-spotify-wrapper and mgoigfer/nova-spotify-auth-tool into your Laravel app.
Next, you can install this package via Composer:
composer require mgoigfer/nova-spotify-track-field
Use
Register the field in your resource's fields
method:
/** * Get the fields displayed by the resource. * * @param \Illuminate\Http\Request $request * @return array */ public function fields(Request $request) { return [ ... \Mgoigfer\SpotifyTrackField\SpotifyTrackField::make('Name') ->spotifyAccessToken() ->extraAttributes([ 'id' => 'spotify_id', 'artist_name' => 'artist', 'duration_ms' => 'duration_ms', 'popularity' => 'popularity', 'preview_url' => 'preview_url',', ]), ... ]; }
You must use the following methods:
spotifyAccessToken
: to request a Spotifyaccess token
from therefresh token
stored in the database (see mgoigfer/nova-spotify-auth-tool).extraAttributes
: a key-value array that indicates which track attributes you would like to store (keys), and the column name in your database where they may be stored (values).
List of track attributes:
id
: The Spotify ID for the track.name
: The name of the track.artist_id
: The Spotify ID for the artist.artist_name
: The name of the artistduration_ms
: The track length in milliseconds.popularity
: The popularity of the track. The value will be between 0 and 100, with 100 being the most popular.preview_url
: A link to a 30 second preview (MP3 format) of the track. Can benull
.first_letter
: The first letter of the track (e.g. inTail Lights
will beT
).
More info in the Spotify Web API.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.