repo stringlengths 7 63 | file_url stringlengths 81 284 | file_path stringlengths 5 200 | content stringlengths 0 32.8k | language stringclasses 1 value | license stringclasses 7 values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:02:33 2026-01-05 05:24:06 | truncated bool 2 classes |
|---|---|---|---|---|---|---|---|---|
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Values/Album/AlbumUpdateData.php | app/Values/Album/AlbumUpdateData.php | <?php
namespace App\Values\Album;
use Illuminate\Contracts\Support\Arrayable;
final class AlbumUpdateData implements Arrayable
{
private function __construct(public string $name, public ?int $year, public ?string $cover)
{
}
public static function make(string $name, ?int $year = null, ?string $cover = null): self
{
return new self(
name: $name,
year: $year,
cover: $cover,
);
}
/** @inheritdoc */
public function toArray(): array
{
return [
'name' => $this->name,
'year' => $this->year,
'cover' => $this->cover,
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Values/Album/AlbumInformation.php | app/Values/Album/AlbumInformation.php | <?php
namespace App\Values\Album;
use HTMLPurifier;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Support\Arr;
final class AlbumInformation implements Arrayable
{
public const JSON_STRUCTURE = [
'url',
'cover',
'wiki' => [
'summary',
'full',
],
'tracks' => [
'*' => [
'title',
'length',
'url',
],
],
];
private function __construct(public ?string $url, public ?string $cover, public array $wiki, public array $tracks)
{
$purifier = new HTMLPurifier();
$this->wiki['summary'] = $purifier->purify($this->wiki['summary']);
$this->wiki['full'] = $purifier->purify($this->wiki['full']);
}
public static function make(
?string $url = null,
?string $cover = null,
array $wiki = ['summary' => '', 'full' => ''],
array $tracks = []
): self {
return new self($url, $cover, $wiki, $tracks);
}
public static function fromWikipediaSummary(array $summary): self
{
return new self(
url: Arr::get($summary, 'content_urls.desktop.page'),
cover: Arr::get($summary, 'thumbnail.source'),
wiki: [
'summary' => Arr::get($summary, 'extract', ''),
'full' => Arr::get($summary, 'extract_html', ''),
],
tracks: [],
);
}
public function withMusicBrainzTracks(array $tracks): self
{
$self = clone $this;
$self->tracks = collect($tracks)->map(static function (array $track) {
return [
'title' => Arr::get($track, 'title'),
'length' => (int) Arr::get($track, 'length', 0) / 1000, // MusicBrainz length is in milliseconds
'url' => 'https://musicbrainz.org/recording/' . Arr::get($track, 'id'),
];
})->toArray();
return $self;
}
/** @inheritdoc */
public function toArray(): array
{
return [
'url' => $this->url,
'cover' => $this->cover,
'wiki' => $this->wiki,
'tracks' => $this->tracks,
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Values/Scanning/ScanResultCollection.php | app/Values/Scanning/ScanResultCollection.php | <?php
namespace App\Values\Scanning;
use Illuminate\Support\Collection;
final class ScanResultCollection extends Collection
{
public static function create(): self
{
return new self();
}
/** @return Collection<array-key, ScanResult> */
public function valid(): Collection
{
return $this->filter(static fn (ScanResult $result): bool => $result->isValid());
}
/** @return Collection<array-key, ScanResult> */
public function success(): Collection
{
return $this->filter(static fn (ScanResult $result): bool => $result->isSuccess());
}
/** @return Collection<array-key, ScanResult> */
public function skipped(): Collection
{
return $this->filter(static fn (ScanResult $result): bool => $result->isSkipped());
}
/** @return Collection<array-key, ScanResult> */
public function error(): Collection
{
return $this->filter(static fn (ScanResult $result): bool => $result->isError());
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Values/Scanning/ScanInformation.php | app/Values/Scanning/ScanInformation.php | <?php
namespace App\Values\Scanning;
use App\Models\Album;
use App\Models\Artist;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class ScanInformation implements Arrayable
{
private function __construct(
public ?string $title,
public ?string $albumName,
public ?string $artistName,
public ?string $albumArtistName,
public ?int $track,
public ?int $disc,
public ?int $year,
public ?string $genre,
public ?string $lyrics,
public ?float $length,
public ?array $cover,
public ?string $path,
public ?string $hash,
public ?int $mTime,
public ?string $mimeType,
public ?int $fileSize,
) {
}
public static function fromGetId3Info(array $info, string $path): self
{
// We prefer ID3v2 tags over ID3v1 tags.
$tags = array_merge(
Arr::get($info, 'tags.id3v1', []),
Arr::get($info, 'tags.id3v2', []),
Arr::get($info, 'comments', []),
Arr::get($info, 'tags.vorbiscomment', []),
);
$comments = Arr::get($info, 'comments', []);
$albumArtistName = self::getTag($tags, ['albumartist', 'album_artist', 'band']);
// If the song is explicitly marked as a compilation but there's no album artist name, use the umbrella
// "Various Artists" artist.
if (!$albumArtistName && self::getTag($tags, 'part_of_a_compilation')) {
$albumArtistName = Artist::VARIOUS_NAME;
}
$cover = [self::getTag($comments, 'cover', null)];
if ($cover[0] === null) {
$cover = self::getTag($comments, 'picture', []);
}
$lyrics = html_entity_decode(self::getTag($tags, [
'unsynchronised_lyric',
'unsychronised_lyric',
'unsyncedlyrics',
'lyrics',
]));
return new self(
title: html_entity_decode(self::getTag($tags, 'title', pathinfo($path, PATHINFO_FILENAME))),
albumName: html_entity_decode(self::getTag($tags, 'album', Album::UNKNOWN_NAME)),
artistName: html_entity_decode(self::getTag($tags, 'artist', Artist::UNKNOWN_NAME)),
albumArtistName: html_entity_decode($albumArtistName),
track: (int) self::getTag($tags, ['track', 'tracknumber', 'track_number']),
disc: (int) self::getTag($tags, ['discnumber', 'part_of_a_set'], 1),
year: (int) self::getTag($tags, 'year') ?: null,
genre: self::getTag($tags, 'genre'),
lyrics: $lyrics,
length: (float) Arr::get($info, 'playtime_seconds'),
cover: $cover,
path: $path,
hash: File::hash($path),
mTime: get_mtime($path),
mimeType: Str::lower(Arr::get($info, 'mime_type')) ?: 'audio/mpeg',
fileSize: File::size($path),
);
}
public static function make(
?string $title = null,
?string $albumName = null,
?string $artistName = null,
?string $albumArtistName = null,
?int $track = null,
?int $disc = null,
?int $year = null,
?string $genre = null,
?string $lyrics = null,
?float $length = null,
?array $cover = null,
?string $path = null,
?string $hash = null,
?int $mTime = null,
?string $mimeType = null,
?int $fileSize = null,
): self {
return new self(
title: $title,
albumName: $albumName,
artistName: $artistName,
albumArtistName: $albumArtistName,
track: $track,
disc: $disc,
year: $year,
genre: $genre,
lyrics: $lyrics,
length: $length,
cover: $cover,
path: $path,
hash: $hash,
mTime: $mTime,
mimeType: $mimeType,
fileSize: $fileSize,
);
}
private static function getTag(array $arr, string|array $keys, $default = ''): mixed
{
foreach (Arr::wrap($keys) as $name) {
$value = Arr::get($arr, $name . '.0');
if ($value) {
break;
}
}
return $value ?? $default;
}
/** @inheritdoc */
public function toArray(): array
{
return [
'title' => $this->title,
'album' => $this->albumName,
'artist' => $this->artistName,
'albumartist' => $this->albumArtistName,
'track' => $this->track,
'disc' => $this->disc,
'year' => $this->year,
'genre' => $this->genre,
'lyrics' => $this->lyrics,
'length' => $this->length,
'cover' => $this->cover,
'path' => $this->path,
'hash' => $this->hash,
'mtime' => $this->mTime,
'mime_type' => $this->mimeType,
'file_size' => $this->fileSize,
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Values/Scanning/ScanConfiguration.php | app/Values/Scanning/ScanConfiguration.php | <?php
namespace App\Values\Scanning;
use App\Models\User;
final class ScanConfiguration
{
/**
* @param User $owner The user who owns the song
* @param bool $makePublic Whether to make the song public
* @param array<string> $ignores The tags to ignore/exclude (only taken into account if the song already exists)
* @param bool $force Whether to force syncing, even if the file is unchanged
* @param bool $extractFolderStructure Whether to extract the folder structure from the file path.
* This should be set to true for the local storage driver, and false for cloud storage drivers.
*/
private function __construct(
public User $owner,
public bool $makePublic,
public array $ignores,
public bool $force,
public bool $extractFolderStructure,
) {
}
public static function make(
User $owner,
bool $makePublic = false,
array $ignores = [],
bool $force = false,
bool $extractFolderStructure = true
): self {
return new self($owner, $makePublic, $ignores, $force, $extractFolderStructure);
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Values/Scanning/ScanResult.php | app/Values/Scanning/ScanResult.php | <?php
namespace App\Values\Scanning;
use App\Enums\ScanResultType;
final class ScanResult
{
private function __construct(public string $path, public ScanResultType $type, public ?string $error = null)
{
}
public static function success(string $path): self
{
return new self($path, ScanResultType::SUCCESS);
}
public static function skipped(string $path): self
{
return new self($path, ScanResultType::SKIPPED);
}
public static function error(string $path, ?string $error = null): self
{
return new self($path, ScanResultType::ERROR, $error);
}
public function isSuccess(): bool
{
return $this->type === ScanResultType::SUCCESS;
}
public function isSkipped(): bool
{
return $this->type === ScanResultType::SKIPPED;
}
public function isError(): bool
{
return $this->type === ScanResultType::ERROR;
}
public function isValid(): bool
{
return $this->isSuccess() || $this->isSkipped();
}
public function __toString(): string
{
$name = $this->type->value . ': ' . $this->path;
return $this->isError() ? $name . ' - ' . $this->error : $name;
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Values/Radio/RadioStationUpdateData.php | app/Values/Radio/RadioStationUpdateData.php | <?php
namespace App\Values\Radio;
use Illuminate\Contracts\Support\Arrayable;
final readonly class RadioStationUpdateData implements Arrayable
{
public function __construct(
public string $name,
public string $url,
public string $description,
public ?string $logo,
public bool $isPublic,
) {
}
public static function make(
string $name,
string $url,
string $description,
?string $logo = null,
bool $isPublic = false,
): self {
return new self(
name: $name,
url: $url,
description: $description,
logo: $logo,
isPublic: $isPublic,
);
}
/** @inheritdoc */
public function toArray(): array
{
return [
'name' => $this->name,
'url' => $this->url,
'description' => $this->description,
'logo' => $this->logo,
'is_public' => $this->isPublic,
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Values/Radio/RadioStationCreateData.php | app/Values/Radio/RadioStationCreateData.php | <?php
namespace App\Values\Radio;
use Illuminate\Contracts\Support\Arrayable;
final readonly class RadioStationCreateData implements Arrayable
{
private function __construct(
public string $url,
public string $name,
public string $description,
public ?string $logo,
public bool $isPublic,
) {
}
public static function make(
string $url,
string $name,
string $description,
?string $logo = null,
bool $isPublic = false,
): self {
return new self(
url: $url,
name: $name,
description: $description,
logo: $logo,
isPublic: $isPublic,
);
}
/** @inheritdoc */
public function toArray(): array
{
return [
'url' => $this->url,
'name' => $this->name,
'logo' => $this->logo,
'description' => $this->description,
'is_public' => $this->isPublic,
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Values/SmartPlaylist/SmartPlaylistQueryModifier.php | app/Values/SmartPlaylist/SmartPlaylistQueryModifier.php | <?php
namespace App\Values\SmartPlaylist;
use App\Builders\SongBuilder;
use App\Enums\SmartPlaylistModel as Model;
use App\Enums\SmartPlaylistOperator as Operator;
use App\Values\SmartPlaylist\SmartPlaylistRule as Rule;
use Carbon\Carbon;
use Closure;
use Illuminate\Database\Eloquent\Builder;
final class SmartPlaylistQueryModifier
{
private static function resolveWhereMethod(Rule $rule, Operator $operator): string
{
return $rule->model->requiresRawQuery()
? 'whereRaw'
: $operator->toWhereMethod();
}
public static function applyRule(Rule $rule, SongBuilder $query): void
{
$operator = $rule->operator;
$value = $rule->value;
// If the rule is a date rule and the operator is "is" or "is not", we need to
// convert the date to a range of dates and use the "between" or "not between" operator instead,
// as we store dates as timestamps in the database.
// For instance, "IS 2023-10-01" should be converted to "IS BETWEEN 2023-10-01 AND 2023-10-02."
if ($rule->model->isDate() && in_array($operator, [Operator::IS, Operator::IS_NOT], true)) {
$operator = $operator === Operator::IS ? Operator::IS_BETWEEN : Operator::IS_NOT_BETWEEN;
$nextDay = Carbon::createFromFormat('Y-m-d', $value[0])->addDay()->format('Y-m-d');
$value = [$value[0], $nextDay];
}
if ($rule->model->getManyToManyRelation()) {
// for a many-to-many relation (like genres), we need to use a subquery with "whereHas" or "whereDoesntHave"
$whereHasClause = $rule->operator->isNegative() ? 'whereDoesntHave' : 'whereHas';
// Also, since the inclusion logic has already been handled by "whereHas" and "whereDoesntHave", the
// negative operators should be converted to their positive counterparts (isNot becomes is,
// notContain becomes contains, isNotBetween becomes isBetween).
// This way, for example, "genre is not 'Rock'" will be translated to
// "whereDoesntHave genre where genre is 'Rock'".
$operator = match ($operator) {
Operator::IS_NOT => Operator::IS,
Operator::NOT_CONTAIN => Operator::CONTAINS,
Operator::IS_NOT_BETWEEN => Operator::IS_BETWEEN,
default => $operator,
};
$query->{$whereHasClause}(
$rule->model->getManyToManyRelation(),
static function (Builder $subQuery) use ($rule, $operator, $value): void {
$subQuery->{self::resolveWhereMethod($rule, $operator)}(
...self::generateParameters($rule->model, $operator, $value)
);
}
);
} else {
$query->{self::resolveWhereMethod($rule, $operator)}(
...self::generateParameters($rule->model, $operator, $value)
);
}
}
/** @inheritdoc */
private static function generateParameters(Model $model, Operator $operator, array $value): array
{
$column = $model->toColumnName();
$parameters = $model->requiresRawQuery()
? self::generateRawParameters($column, $operator, $value)
: self::generateEloquentParameters($column, $operator, $value);
return $parameters instanceof Closure ? $parameters() : $parameters;
}
/** @inheritdoc */
private static function generateRawParameters(string $column, Operator $operator, array $value): array|Closure
{
// For raw parameters like those for play count, we need to use raw SQL clauses (whereRaw).
// whereRaw() expects a string for the statement and an array of parameters for binding.
return match ($operator) {
Operator::BEGINS_WITH => ["$column LIKE ?", ["{$value[0]}%"]],
Operator::CONTAINS => ["$column LIKE ?", ["%{$value[0]}%"]],
Operator::ENDS_WITH => ["$column LIKE ?", ["%{$value[0]}"]],
Operator::IN_LAST => static fn () => ["$column >= ?", [now()->subDays($value[0])]],
Operator::IS => ["$column = ?", [$value[0]]],
Operator::IS_BETWEEN => ["$column BETWEEN ? AND ?", $value],
Operator::IS_GREATER_THAN => ["$column > ?", [$value[0]]],
Operator::IS_LESS_THAN => ["$column < ?", [$value[0]]],
Operator::IS_NOT => ["$column <> ?", [$value[0]]],
Operator::IS_NOT_BETWEEN => ["$column NOT BETWEEN ? AND ?", $value],
Operator::NOT_CONTAIN => ["$column NOT LIKE ?", ["%{$value[0]}%"]],
Operator::NOT_IN_LAST => static fn () => ["$column < ?", [now()->subDays($value[0])]],
};
}
private static function generateEloquentParameters(string $column, Operator $operator, array $value): array|Closure
{
return match ($operator) {
Operator::BEGINS_WITH => [$column, 'LIKE', "$value[0]%"],
Operator::ENDS_WITH => [$column, 'LIKE', "%$value[0]"],
Operator::IS => [$column, '=', $value[0]],
Operator::IS_NOT => [$column, '<>', $value[0]],
Operator::CONTAINS => [$column, 'LIKE', "%$value[0]%"],
Operator::NOT_CONTAIN => [$column, 'NOT LIKE', "%$value[0]%"],
Operator::IS_LESS_THAN => [$column, '<', $value[0]],
Operator::IS_GREATER_THAN => [$column, '>', $value[0]],
Operator::IS_BETWEEN, Operator::IS_NOT_BETWEEN => [$column, $value],
Operator::NOT_IN_LAST => static fn () => [$column, '<', now()->subDays($value[0])],
Operator::IN_LAST => static fn () => [$column, '>=', now()->subDays($value[0])],
};
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Values/SmartPlaylist/SmartPlaylistRuleGroup.php | app/Values/SmartPlaylist/SmartPlaylistRuleGroup.php | <?php
namespace App\Values\SmartPlaylist;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Webmozart\Assert\Assert;
final class SmartPlaylistRuleGroup implements Arrayable
{
private function __construct(public string $id, public Collection $rules)
{
Assert::uuid($id);
}
public static function make(array $array): self
{
return new self(
id: Arr::get($array, 'id'),
rules: collect(Arr::get($array, 'rules', []))->transform(
static function (array|SmartPlaylistRule $rule): SmartPlaylistRule {
return $rule instanceof SmartPlaylistRule ? $rule : SmartPlaylistRule::make($rule);
}
),
);
}
/** @inheritdoc */
public function toArray(): array
{
return [
'id' => $this->id,
'rules' => $this->rules->toArray(),
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Values/SmartPlaylist/SmartPlaylistRule.php | app/Values/SmartPlaylist/SmartPlaylistRule.php | <?php
namespace App\Values\SmartPlaylist;
use App\Enums\SmartPlaylistModel;
use App\Enums\SmartPlaylistOperator;
use App\Helpers\Uuid;
use Illuminate\Contracts\Support\Arrayable;
use Webmozart\Assert\Assert;
final class SmartPlaylistRule implements Arrayable
{
public string $id;
public SmartPlaylistModel $model;
public SmartPlaylistOperator $operator;
public array $value;
private function __construct(array $config)
{
self::assertConfig($config);
$this->id = $config['id'] ?? Uuid::generate();
$this->value = $config['value'];
$this->model = SmartPlaylistModel::from($config['model']);
$this->operator = SmartPlaylistOperator::from($config['operator']);
}
/** @noinspection PhpExpressionResultUnusedInspection */
public static function assertConfig(array $config, bool $allowUserIdModel = true): void
{
if ($config['id'] ?? null) {
Assert::uuid($config['id']);
}
SmartPlaylistOperator::from($config['operator']);
if (!$allowUserIdModel) {
Assert::false($config['model'] === SmartPlaylistModel::USER_ID);
}
SmartPlaylistModel::from($config['model']);
Assert::isArray($config['value']);
Assert::countBetween($config['value'], 1, 2);
}
public static function make(array $config): self
{
return new self($config);
}
/** @inheritdoc */
public function toArray(): array
{
return [
'id' => $this->id,
'model' => $this->model->value,
'operator' => $this->operator->value,
'value' => $this->value,
];
}
public function equals(array|self $rule): bool
{
if (is_array($rule)) {
$rule = self::make($rule);
}
return $this->operator === $rule->operator
&& !array_diff($this->value, $rule->value)
&& $this->model === $rule->model;
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Values/SmartPlaylist/SmartPlaylistRuleGroupCollection.php | app/Values/SmartPlaylist/SmartPlaylistRuleGroupCollection.php | <?php
namespace App\Values\SmartPlaylist;
use Illuminate\Support\Collection;
final class SmartPlaylistRuleGroupCollection extends Collection
{
public static function create(array $array): self
{
return new self(
collect($array)->transform(static function (array|SmartPlaylistRuleGroup $group): SmartPlaylistRuleGroup {
return $group instanceof SmartPlaylistRuleGroup ? $group : SmartPlaylistRuleGroup::make($group);
})
);
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Values/SongStorageMetadata/SftpMetadata.php | app/Values/SongStorageMetadata/SftpMetadata.php | <?php
namespace App\Values\SongStorageMetadata;
final class SftpMetadata extends SongStorageMetadata
{
private function __construct(public string $path)
{
}
public static function make(string $key): self
{
return new self($key);
}
public function getPath(): string
{
return $this->path;
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Values/SongStorageMetadata/LocalMetadata.php | app/Values/SongStorageMetadata/LocalMetadata.php | <?php
namespace App\Values\SongStorageMetadata;
final class LocalMetadata extends SongStorageMetadata
{
private function __construct(public string $path)
{
}
public static function make(string $path): self
{
return new self($path);
}
public function getPath(): string
{
return $this->path;
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Values/SongStorageMetadata/SongStorageMetadata.php | app/Values/SongStorageMetadata/SongStorageMetadata.php | <?php
namespace App\Values\SongStorageMetadata;
abstract class SongStorageMetadata
{
abstract public function getPath(): string;
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Values/SongStorageMetadata/DropboxMetadata.php | app/Values/SongStorageMetadata/DropboxMetadata.php | <?php
namespace App\Values\SongStorageMetadata;
final class DropboxMetadata extends SongStorageMetadata
{
private function __construct(public string $path)
{
}
public static function make(string $key): self
{
return new self($key);
}
public function getPath(): string
{
return $this->path;
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Values/SongStorageMetadata/S3LambdaMetadata.php | app/Values/SongStorageMetadata/S3LambdaMetadata.php | <?php
namespace App\Values\SongStorageMetadata;
final class S3LambdaMetadata extends S3CompatibleMetadata
{
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Values/SongStorageMetadata/S3CompatibleMetadata.php | app/Values/SongStorageMetadata/S3CompatibleMetadata.php | <?php
namespace App\Values\SongStorageMetadata;
class S3CompatibleMetadata extends SongStorageMetadata
{
private function __construct(public string $bucket, public string $key)
{
}
public static function make(string $bucket, string $key): self
{
return new static($bucket, $key);
}
public function getPath(): string
{
return $this->key;
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Helpers/Uuid.php | app/Helpers/Uuid.php | <?php
namespace App\Helpers;
use Illuminate\Support\Str;
class Uuid extends TestableIdentifier
{
public const REGEX = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}';
protected static function newIdentifier(): string
{
return Str::uuid()->toString();
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Helpers/TestableIdentifier.php | app/Helpers/TestableIdentifier.php | <?php
namespace App\Helpers;
abstract class TestableIdentifier
{
protected static ?string $frozenValue = null;
abstract protected static function newIdentifier(): string;
public static function generate(): string
{
return static::$frozenValue ?: static::newIdentifier();
}
/**
* Freeze the identifier value for testing purposes.
*
* @param ?string $value A value to freeze, or null to generate a new one.
*/
public static function freeze(?string $value = null): string
{
static::$frozenValue = $value ?? static::newIdentifier();
return static::$frozenValue;
}
public static function unfreeze(): void
{
static::$frozenValue = null;
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Helpers/Ulid.php | app/Helpers/Ulid.php | <?php
namespace App\Helpers;
use Illuminate\Support\Str;
class Ulid extends TestableIdentifier
{
protected static function newIdentifier(): string
{
return Str::lower(Str::ulid());
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/Request.php | app/Http/Requests/Request.php | <?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
abstract class Request extends FormRequest
{
public function authorize(): bool
{
return true;
}
/** @inheritdoc */
public function rules(): array
{
return [];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/SongPlayRequest.php | app/Http/Requests/SongPlayRequest.php | <?php
namespace App\Http\Requests;
/**
* @property-read float|string $time
* @property-read string $api_token
*/
class SongPlayRequest extends Request
{
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/SpotifyCallbackRequest.php | app/Http/Requests/SpotifyCallbackRequest.php | <?php
namespace App\Http\Requests;
/**
* @property-read string $state
* @property-read string $code
*/
class SpotifyCallbackRequest extends Request
{
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/Download/DownloadSongsRequest.php | app/Http/Requests/Download/DownloadSongsRequest.php | <?php
namespace App\Http\Requests\Download;
/**
* @property array $songs
*/
class DownloadSongsRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'songs' => 'required|array',
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/Download/Request.php | app/Http/Requests/Download/Request.php | <?php
namespace App\Http\Requests\Download;
use App\Http\Requests\API\Request as BaseRequest;
abstract class Request extends BaseRequest
{
public function authorize(): bool
{
return config('koel.download.allow');
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/UserUpdateRequest.php | app/Http/Requests/API/UserUpdateRequest.php | <?php
namespace App\Http\Requests\API;
use App\Enums\Acl\Role;
use App\Models\User;
use App\Rules\AvailableRole;
use App\Rules\UserCanManageRole;
use App\Values\User\UserUpdateData;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\Password;
/**
* @property-read string $password
* @property-read string $name
* @property-read string $email
*/
class UserUpdateRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
/** @var User $target */
$target = $this->route('user');
return [
'name' => 'required',
'email' => 'required|email|unique:users,email,' . $target->id,
'password' => ['sometimes', Password::defaults()],
'role' => [
'required',
Rule::enum(Role::class),
new AvailableRole(),
new UserCanManageRole($this->user()),
],
];
}
public function toDto(): UserUpdateData
{
return UserUpdateData::make(
name: $this->name,
email: $this->email,
plainTextPassword: $this->password,
role: $this->enum('role', Role::class),
);
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/InteractWithMultipleSongsRequest.php | app/Http/Requests/API/InteractWithMultipleSongsRequest.php | <?php
namespace App\Http\Requests\API;
use App\Models\Song;
use Illuminate\Validation\Rule;
/**
* @property array<string> $songs
*/
class InteractWithMultipleSongsRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'songs' => ['required', 'array', Rule::exists(Song::class, 'id')],
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/SongUpdateRequest.php | app/Http/Requests/API/SongUpdateRequest.php | <?php
namespace App\Http\Requests\API;
use App\Models\Song;
use App\Values\Song\SongUpdateData;
use Illuminate\Validation\Rule;
/**
* @property-read array<string> $songs
* @property-read array<mixed> $data
*/
class SongUpdateRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'data' => 'required|array',
'songs' => ['required', 'array', Rule::exists(Song::class, 'id')->whereNull('podcast_id')],
];
}
public function toDto(): SongUpdateData
{
return SongUpdateData::make(
title: $this->input('data.title'),
artistName: $this->input('data.artist_name'),
albumName: $this->input('data.album_name'),
albumArtistName: $this->input('data.album_artist_name'),
track: (int) $this->input('data.track'),
disc: (int) $this->input('data.disc'),
genre: $this->input('data.genre'),
year: (int) $this->input('data.year'),
lyrics: $this->input('data.lyrics'),
);
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/ViewSongOnITunesRequest.php | app/Http/Requests/API/ViewSongOnITunesRequest.php | <?php
namespace App\Http\Requests\API;
/**
* @property string $q
* @property string $api_token
*/
class ViewSongOnITunesRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'q' => 'required',
'api_token' => 'required',
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/ForgotPasswordRequest.php | app/Http/Requests/API/ForgotPasswordRequest.php | <?php
namespace App\Http\Requests\API;
/**
* @property-read string $email
*/
class ForgotPasswordRequest extends Request
{
/** @return array<string, string> */
public function rules(): array
{
return [
'email' => 'required|email',
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/UpdatePlaybackStatusRequest.php | app/Http/Requests/API/UpdatePlaybackStatusRequest.php | <?php
namespace App\Http\Requests\API;
use App\Models\Song;
use Illuminate\Validation\Rules\Exists;
/**
* @property-read string $song
* @property-read int $position
*/
class UpdatePlaybackStatusRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'song' => ['required', 'string', new Exists(Song::class, 'id')],
'position' => 'required|integer',
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/AddSongsToPlaylistRequest.php | app/Http/Requests/API/AddSongsToPlaylistRequest.php | <?php
namespace App\Http\Requests\API;
use App\Rules\AllPlayablesAreAccessibleBy;
/**
* @property-read array<string> $songs
*/
class AddSongsToPlaylistRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'songs' => ['required', 'array', new AllPlayablesAreAccessibleBy($this->user())],
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/YouTubeSearchRequest.php | app/Http/Requests/API/YouTubeSearchRequest.php | <?php
namespace App\Http\Requests\API;
/**
* @property-read string|null $pageToken
*/
class YouTubeSearchRequest extends Request
{
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/DeleteSongsRequest.php | app/Http/Requests/API/DeleteSongsRequest.php | <?php
namespace App\Http\Requests\API;
use App\Models\Song;
use Illuminate\Validation\Rule;
/** @property-read array<string> $songs */
class DeleteSongsRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'songs' => ['required', 'array', Rule::exists(Song::class, 'id')->whereNull('podcast_id')],
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/RevokeUserInvitationRequest.php | app/Http/Requests/API/RevokeUserInvitationRequest.php | <?php
namespace App\Http\Requests\API;
/**
* @property-read string $email
*/
class RevokeUserInvitationRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return ['email' => 'required|email'];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/AcceptUserInvitationRequest.php | app/Http/Requests/API/AcceptUserInvitationRequest.php | <?php
namespace App\Http\Requests\API;
use Illuminate\Validation\Rules\Password;
/**
* @property-read string $token
* @property-read string $name
* @property-read string $password
*/
class AcceptUserInvitationRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'name' => 'required',
'token' => 'required',
'password' => ['required', Password::defaults()],
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Request.php | app/Http/Requests/API/Request.php | <?php
namespace App\Http\Requests\API;
use App\Http\Requests\Request as BaseRequest;
abstract class Request extends BaseRequest
{
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/FetchSongsForQueueRequest.php | app/Http/Requests/API/FetchSongsForQueueRequest.php | <?php
namespace App\Http\Requests\API;
use App\Builders\SongBuilder;
use Illuminate\Validation\Rule;
/**
* @property-read string|null $sort
* @property-read string $order
* @property-read int $limit
*/
class FetchSongsForQueueRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'order' => ['required', Rule::in('asc', 'desc', 'rand')],
'limit' => 'required|integer|min:1',
'sort' => [
'required_unless:order,rand',
Rule::in(array_keys(SongBuilder::SORT_COLUMNS_NORMALIZE_MAP)),
],
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/UserStoreRequest.php | app/Http/Requests/API/UserStoreRequest.php | <?php
namespace App\Http\Requests\API;
use App\Enums\Acl\Role;
use App\Rules\AvailableRole;
use App\Rules\UserCanManageRole;
use App\Values\User\UserCreateData;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\Password;
/**
* @property-read string $password
* @property-read string $name
* @property-read string $email
*/
class UserStoreRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'name' => 'required',
'email' => 'required|email|unique:users',
'password' => ['required', Password::defaults()],
'role' => [
'required',
Rule::enum(Role::class),
new AvailableRole(),
new UserCanManageRole($this->user()),
],
];
}
public function toDto(): UserCreateData
{
return UserCreateData::make(
name: $this->name,
email: $this->email,
plainTextPassword: $this->password,
role: $this->enum('role', Role::class),
);
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/UpdateUserPreferencesRequest.php | app/Http/Requests/API/UpdateUserPreferencesRequest.php | <?php
namespace App\Http\Requests\API;
use App\Rules\CustomizableUserPreference;
/**
* @property-read string $key
* @property-read string $value
*/
class UpdateUserPreferencesRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'key' => ['required', 'string', new CustomizableUserPreference()],
'value' => 'sometimes',
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/ToggleLikeSongRequest.php | app/Http/Requests/API/ToggleLikeSongRequest.php | <?php
namespace App\Http\Requests\API;
/** @property-read string $song */
class ToggleLikeSongRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'song' => 'required|exists:songs,id',
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/ResetPasswordRequest.php | app/Http/Requests/API/ResetPasswordRequest.php | <?php
namespace App\Http\Requests\API;
use Illuminate\Validation\Rules\Password;
/**
* @property-read string $token
* @property-read string $email
* @property-read string $password
*/
class ResetPasswordRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'token' => 'required',
'email' => 'required|email',
'password' => ['sometimes', Password::defaults()],
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/LastfmCallbackRequest.php | app/Http/Requests/API/LastfmCallbackRequest.php | <?php
namespace App\Http\Requests\API;
/**
* @property string $token Lastfm's access token
* @property string $api_token Koel's current user's token
*/
class LastfmCallbackRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'token' => 'required',
'api_token' => 'required',
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/SearchRequest.php | app/Http/Requests/API/SearchRequest.php | <?php
namespace App\Http\Requests\API;
/**
* @property-read string $q
*/
class SearchRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return ['q' => 'required'];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/ThemeStoreRequest.php | app/Http/Requests/API/ThemeStoreRequest.php | <?php
namespace App\Http\Requests\API;
use App\Rules\ValidImageData;
use App\Values\Theme\ThemeCreateData;
use HTMLPurifier;
class ThemeStoreRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'name' => 'required|string|max:191',
'fg_color' => 'string|sometimes|nullable',
'bg_color' => 'string|sometimes|nullable',
'font_family' => 'string|sometimes|nullable',
'font_size' => 'numeric|sometimes|nullable',
'bg_image' => ['string', 'sometimes', 'nullable', new ValidImageData()],
'highlight_color' => 'string|sometimes|nullable',
];
}
public function toDto(): ThemeCreateData
{
$purifier = new HTMLPurifier();
return ThemeCreateData::make(
name: $this->input('name'),
fgColor: $purifier->purify($this->string('fg_color')),
bgColor: $purifier->purify($this->string('bg_color')),
bgImage: $this->string('bg_image'),
highlightColor: $purifier->purify($this->string('highlight_color')),
fontFamily: $purifier->purify($this->string('font_family')),
fontSize: $this->float('font_size'),
);
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/GetUserInvitationRequest.php | app/Http/Requests/API/GetUserInvitationRequest.php | <?php
namespace App\Http\Requests\API;
/**
* @property-read string $token
*/
class GetUserInvitationRequest extends Request
{
/**
* @inheritdoc
*/
public function rules(): array
{
return [
'token' => 'required|string',
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/ActivateLicenseRequest.php | app/Http/Requests/API/ActivateLicenseRequest.php | <?php
namespace App\Http\Requests\API;
/**
* @property-read string $key
*/
class ActivateLicenseRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'key' => 'required|string',
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/MediaImageUpdateRequest.php | app/Http/Requests/API/MediaImageUpdateRequest.php | <?php
namespace App\Http\Requests\API;
use App\Rules\ValidImageData;
abstract class MediaImageUpdateRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
$this->getImageFieldName() => ['string', 'required', new ValidImageData()],
];
}
public function getFileContent(): string
{
return $this->{$this->getImageFieldName()};
}
abstract protected function getImageFieldName(): string;
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/UserLoginRequest.php | app/Http/Requests/API/UserLoginRequest.php | <?php
namespace App\Http\Requests\API;
/**
* @property string $email
* @property string $password
*/
class UserLoginRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'email' => 'required|email',
'password' => 'required',
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/ChangeSongsVisibilityRequest.php | app/Http/Requests/API/ChangeSongsVisibilityRequest.php | <?php
namespace App\Http\Requests\API;
use App\Facades\License;
use App\Models\Song;
use Illuminate\Validation\Rule;
/**
* @property-read array<string> $songs
*/
class ChangeSongsVisibilityRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'songs' => ['required', 'array', Rule::exists(Song::class, 'id')],
];
}
public function authorize(): bool
{
return License::isPlus();
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/UploadRequest.php | app/Http/Requests/API/UploadRequest.php | <?php
namespace App\Http\Requests\API;
use App\Http\Requests\Request;
use App\Rules\SupportedAudioFile;
use Illuminate\Http\UploadedFile;
/** @property UploadedFile $file */
class UploadRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'file' => ['required', 'file', new SupportedAudioFile()],
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/SongListRequest.php | app/Http/Requests/API/SongListRequest.php | <?php
namespace App\Http\Requests\API;
/**
* @property-read string $order
* @property-read string $sort
*/
class SongListRequest extends Request
{
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/ProfileUpdateRequest.php | app/Http/Requests/API/ProfileUpdateRequest.php | <?php
namespace App\Http\Requests\API;
use App\Values\User\UserUpdateData;
use Illuminate\Support\Str;
use Illuminate\Validation\Rules\Password;
/**
* @property-read string|null $current_password
* @property-read string|null $new_password
* @property-read string $name
* @property-read string $email
* @property-read string|null $avatar
*/
class ProfileUpdateRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'name' => 'required',
'email' => 'required|email|unique:users,email,' . auth()->user()->getAuthIdentifier(),
'current_password' => 'sometimes|required_with:new_password',
'new_password' => ['sometimes', Password::defaults()],
'avatar' => 'sometimes',
];
}
public function toDto(): UserUpdateData
{
return UserUpdateData::make(
name: $this->name,
email: $this->email,
plainTextPassword: $this->new_password,
avatar: Str::startsWith($this->avatar, 'data:') ? $this->avatar : null,
);
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/ScrobbleRequest.php | app/Http/Requests/API/ScrobbleRequest.php | <?php
namespace App\Http\Requests\API;
/**
* @property int $timestamp
*/
class ScrobbleRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return ['timestamp' => 'required|numeric'];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/UpdateQueueStateRequest.php | app/Http/Requests/API/UpdateQueueStateRequest.php | <?php
namespace App\Http\Requests\API;
use App\Rules\AllPlayablesAreAccessibleBy;
/**
* @property-read array<string> $songs
*/
class UpdateQueueStateRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'songs' => ['required', 'array', new AllPlayablesAreAccessibleBy($this->user())],
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/SetLastfmSessionKeyRequest.php | app/Http/Requests/API/SetLastfmSessionKeyRequest.php | <?php
namespace App\Http\Requests\API;
/**
* @property string $key
*/
class SetLastfmSessionKeyRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'key' => 'required',
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/InviteUserRequest.php | app/Http/Requests/API/InviteUserRequest.php | <?php
namespace App\Http\Requests\API;
use App\Enums\Acl\Role;
use App\Rules\AvailableRole;
use App\Rules\UserCanManageRole;
use Illuminate\Validation\Rule;
/**
* @property-read array<string> $emails
*/
class InviteUserRequest extends Request
{
/**
* @inheritdoc
*/
public function rules(): array
{
return [
'emails.*' => 'required|email|unique:users,email',
'role' => [
'required',
Rule::enum(Role::class),
new AvailableRole(),
new UserCanManageRole($this->user()),
],
];
}
/**
* @inheritdoc
*/
public function messages(): array
{
return [
'emails.*.unique' => 'The email :input is already registered.',
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Podcast/PodcastStoreRequest.php | app/Http/Requests/API/Podcast/PodcastStoreRequest.php | <?php
namespace App\Http\Requests\API\Podcast;
use App\Http\Requests\API\Request;
/**
* @property-read string $url
*/
class PodcastStoreRequest extends Request
{
/**
* @return array<string, mixed>
*/
public function rules(): array
{
return [
'url' => 'required|url',
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Artist/ArtistUpdateRequest.php | app/Http/Requests/API/Artist/ArtistUpdateRequest.php | <?php
namespace App\Http\Requests\API\Artist;
use App\Http\Requests\API\Request;
use App\Rules\ValidImageData;
use App\Values\Artist\ArtistUpdateData;
/**
* @property-read string $name
* @property-read ?string $image
*/
class ArtistUpdateRequest extends Request
{
/** @inheritDoc */
public function rules(): array
{
return [
'name' => 'string|required',
'image' => ['string', 'sometimes', 'nullable', new ValidImageData()],
];
}
public function toDto(): ArtistUpdateData
{
return ArtistUpdateData::make(
name: $this->name,
// null means no change to the image, when an empty string means to delete the image
image: $this->has('image') ? $this->string('image') : null,
);
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Artist/ArtistListRequest.php | app/Http/Requests/API/Artist/ArtistListRequest.php | <?php
namespace App\Http\Requests\API\Artist;
use App\Http\Requests\API\Request;
/**
* @property-read string $order
* @property-read string $sort
*/
class ArtistListRequest extends Request
{
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Artist/ArtistImageStoreRequest.php | app/Http/Requests/API/Artist/ArtistImageStoreRequest.php | <?php
namespace App\Http\Requests\API\Artist;
use App\Http\Requests\API\MediaImageUpdateRequest;
/** @property-read string $image */
class ArtistImageStoreRequest extends MediaImageUpdateRequest
{
protected function getImageFieldName(): string
{
return 'image';
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Genre/PaginateSongsByGenreRequest.php | app/Http/Requests/API/Genre/PaginateSongsByGenreRequest.php | <?php
namespace App\Http\Requests\API\Genre;
use App\Http\Requests\API\Request;
/**
* @property-read string $order
* @property-read string $sort
*/
class PaginateSongsByGenreRequest extends Request
{
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Genre/FetchSongsToQueueByGenreRequest.php | app/Http/Requests/API/Genre/FetchSongsToQueueByGenreRequest.php | <?php
namespace App\Http\Requests\API\Genre;
use App\Http\Requests\API\Request;
/**
* @property-read int $limit
*/
class FetchSongsToQueueByGenreRequest extends Request
{
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Playlist/PlaylistSongUpdateRequest.php | app/Http/Requests/API/Playlist/PlaylistSongUpdateRequest.php | <?php
namespace App\Http\Requests\API\Playlist;
use App\Http\Requests\API\Request;
use App\Models\Song;
use Illuminate\Validation\Rule;
/**
* @property array<string> $songs
*/
class PlaylistSongUpdateRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'songs' => 'present|array',
'songs.*' => [Rule::exists(Song::class, 'id')],
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Playlist/RemoveSongsFromPlaylistRequest.php | app/Http/Requests/API/Playlist/RemoveSongsFromPlaylistRequest.php | <?php
namespace App\Http\Requests\API\Playlist;
use App\Http\Requests\API\Request;
use App\Models\Song;
use Illuminate\Validation\Rule;
/**
* @property-read array<string> $songs
*/
class RemoveSongsFromPlaylistRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'songs' => ['required', 'array', Rule::exists(Song::class, 'id')],
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Playlist/PlaylistStoreRequest.php | app/Http/Requests/API/Playlist/PlaylistStoreRequest.php | <?php
namespace App\Http\Requests\API\Playlist;
use App\Http\Requests\API\Request;
use App\Models\PlaylistFolder;
use App\Rules\AllPlayablesAreAccessibleBy;
use App\Rules\ValidImageData;
use App\Rules\ValidSmartPlaylistRulePayload;
use App\Values\Playlist\PlaylistCreateData;
use App\Values\SmartPlaylist\SmartPlaylistRuleGroupCollection;
use Illuminate\Support\Arr;
use Illuminate\Validation\Rule;
/**
* @property array<string> $songs
* @property-read ?string $folder_id
* @property-read ?string $description
* @property-read array $rules
* @property-read string $name
* @property-read ?string $cover
*/
class PlaylistStoreRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'name' => 'required',
'songs' => ['array', new AllPlayablesAreAccessibleBy($this->user())],
'description' => 'string|sometimes|nullable', // backward compatibility for mobile apps
'rules' => ['array', 'nullable', new ValidSmartPlaylistRulePayload()],
'folder_id' => ['nullable', 'sometimes', Rule::exists(PlaylistFolder::class, 'id')],
'cover' => ['sometimes', 'nullable', new ValidImageData()],
];
}
public function toDto(): PlaylistCreateData
{
return PlaylistCreateData::make(
name: $this->name,
description: (string) $this->description,
folderId: $this->folder_id,
cover: $this->cover,
playableIds: Arr::wrap($this->songs),
ruleGroups: $this->rules ? SmartPlaylistRuleGroupCollection::create(Arr::wrap($this->rules)) : null,
);
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Playlist/PlaylistUpdateRequest.php | app/Http/Requests/API/Playlist/PlaylistUpdateRequest.php | <?php
namespace App\Http\Requests\API\Playlist;
use App\Http\Requests\API\Request;
use App\Models\PlaylistFolder;
use App\Rules\ValidImageData;
use App\Rules\ValidSmartPlaylistRulePayload;
use App\Values\Playlist\PlaylistUpdateData;
use App\Values\SmartPlaylist\SmartPlaylistRuleGroupCollection;
use Illuminate\Support\Arr;
use Illuminate\Validation\Rule;
/**
* @property-read string $name
* @property-read ?string $description
* @property-read ?string $folder_id
* @property-read array $rules
* @property-read ?string $cover
*/
class PlaylistUpdateRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'name' => 'required',
'description' => 'string|sometimes|nullable',
'rules' => ['array', 'nullable', new ValidSmartPlaylistRulePayload()],
'folder_id' => ['nullable', 'sometimes', Rule::exists(PlaylistFolder::class, 'id')],
'cover' => ['string', 'sometimes', 'nullable', new ValidImageData()],
];
}
public function toDto(): PlaylistUpdateData
{
return PlaylistUpdateData::make(
name: $this->name,
description: (string) $this->description,
folderId: $this->folder_id,
cover: $this->has('cover') ? $this->string('cover') : null,
ruleGroups: $this->rules ? SmartPlaylistRuleGroupCollection::create(Arr::wrap($this->rules)) : null,
);
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Playlist/MovePlaylistSongsRequest.php | app/Http/Requests/API/Playlist/MovePlaylistSongsRequest.php | <?php
namespace App\Http\Requests\API\Playlist;
use App\Enums\Placement;
use App\Http\Requests\API\Request;
use Illuminate\Validation\Rules\Enum;
/**
* @property-read array<string> $songs
* @property-read string $target
* @property-read string $placement
*/
class MovePlaylistSongsRequest extends Request
{
/** @return array<string, mixed> */
public function rules(): array
{
return [
// We don't validate against the playlist_song table here, because songs might have been removed
// from the playlist in the meantime.
// Instead, we only validate that the songs exist.
'songs' => 'required|array|exists:songs,id',
'target' => 'required|exists:playlist_song,song_id',
'placement' => ['required', new Enum(Placement::class)],
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Playlist/PlaylistCoverUpdateRequest.php | app/Http/Requests/API/Playlist/PlaylistCoverUpdateRequest.php | <?php
namespace App\Http\Requests\API\Playlist;
use App\Http\Requests\API\MediaImageUpdateRequest;
/** @property-read string $cover */
class PlaylistCoverUpdateRequest extends MediaImageUpdateRequest
{
protected function getImageFieldName(): string
{
return 'cover';
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/PlaylistFolder/PlaylistFolderUpdateRequest.php | app/Http/Requests/API/PlaylistFolder/PlaylistFolderUpdateRequest.php | <?php
namespace App\Http\Requests\API\PlaylistFolder;
use App\Http\Requests\API\Request;
/**
* @property-read string $name
*/
class PlaylistFolderUpdateRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'name' => 'required|string|max:191',
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/PlaylistFolder/PlaylistFolderStoreRequest.php | app/Http/Requests/API/PlaylistFolder/PlaylistFolderStoreRequest.php | <?php
namespace App\Http\Requests\API\PlaylistFolder;
use App\Http\Requests\API\Request;
/**
* @property-read string $name
*/
class PlaylistFolderStoreRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'name' => 'required|string|max:191',
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/PlaylistFolder/PlaylistFolderPlaylistDestroyRequest.php | app/Http/Requests/API/PlaylistFolder/PlaylistFolderPlaylistDestroyRequest.php | <?php
namespace App\Http\Requests\API\PlaylistFolder;
use App\Http\Requests\API\Request;
use App\Models\Playlist;
use App\Rules\AllPlaylistsAreAccessibleBy;
use Illuminate\Validation\Rule;
/**
* @property-read array<int>|int $playlists
*/
class PlaylistFolderPlaylistDestroyRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'playlists' => [
'required',
'array',
new AllPlaylistsAreAccessibleBy($this->user()),
Rule::exists(Playlist::class, 'id'),
],
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/PlaylistFolder/PlaylistFolderPlaylistStoreRequest.php | app/Http/Requests/API/PlaylistFolder/PlaylistFolderPlaylistStoreRequest.php | <?php
namespace App\Http\Requests\API\PlaylistFolder;
use App\Http\Requests\API\Request;
use App\Models\Playlist;
use App\Rules\AllPlaylistsAreAccessibleBy;
use Illuminate\Validation\Rule;
/**
* @property-read array<int>|int $playlists
*/
class PlaylistFolderPlaylistStoreRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'playlists' => [
'required',
'array',
new AllPlaylistsAreAccessibleBy($this->user()),
Rule::exists(Playlist::class, 'id'),
],
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Album/AlbumListRequest.php | app/Http/Requests/API/Album/AlbumListRequest.php | <?php
namespace App\Http\Requests\API\Album;
use App\Http\Requests\API\Request;
/**
* @property-read string $order
* @property-read string $sort
*/
class AlbumListRequest extends Request
{
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Album/AlbumUpdateRequest.php | app/Http/Requests/API/Album/AlbumUpdateRequest.php | <?php
namespace App\Http\Requests\API\Album;
use App\Http\Requests\API\Request;
use App\Rules\ValidImageData;
use App\Values\Album\AlbumUpdateData;
/**
* @property-read string $name
* @property-read ?int $year
* @property-read ?string $cover
*/
class AlbumUpdateRequest extends Request
{
/** @inheritDoc */
public function rules(): array
{
return [
'name' => 'string|required',
'year' => 'integer|nullable',
'cover' => ['string', 'sometimes', 'nullable', new ValidImageData()],
];
}
public function toDto(): AlbumUpdateData
{
return AlbumUpdateData::make(
name: $this->name,
year: $this->year ?: null,
cover: $this->has('cover') ? $this->string('cover') : null,
);
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Album/AlbumCoverStoreRequest.php | app/Http/Requests/API/Album/AlbumCoverStoreRequest.php | <?php
namespace App\Http\Requests\API\Album;
use App\Http\Requests\API\MediaImageUpdateRequest;
/** @property-read string $cover */
class AlbumCoverStoreRequest extends MediaImageUpdateRequest
{
protected function getImageFieldName(): string
{
return 'cover';
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Radio/RadioStationStoreRequest.php | app/Http/Requests/API/Radio/RadioStationStoreRequest.php | <?php
namespace App\Http\Requests\API\Radio;
use App\Http\Requests\API\Request;
use App\Rules\ValidImageData;
use App\Rules\ValidRadioStationUrl;
use App\Values\Radio\RadioStationCreateData;
use Illuminate\Validation\Rule;
/**
* @property-read string $name
* @property-read string $url
* @property-read ?string $logo
* @property-read ?string $description
* @property-read ?bool $is_public
*/
class RadioStationStoreRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'url' => [
'required',
'url',
Rule::unique('radio_stations')->where(function ($query) {
return $query->where('user_id', $this->user()->id);
}),
app(ValidRadioStationUrl::class),
],
'name' => ['required', 'string', 'max:191'],
'logo' => ['nullable', new ValidImageData()],
'description' => ['sometimes', 'nullable', 'string'],
'is_public' => ['boolean', 'nullable'],
];
}
public function toDto(): RadioStationCreateData
{
return RadioStationCreateData::make(
url: $this->url,
name: $this->name,
description: $this->string('description'),
logo: $this->logo,
isPublic: $this->is_public,
);
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Radio/RadioStationUpdateRequest.php | app/Http/Requests/API/Radio/RadioStationUpdateRequest.php | <?php
namespace App\Http\Requests\API\Radio;
use App\Http\Requests\API\Request;
use App\Rules\ValidImageData;
use App\Rules\ValidRadioStationUrl;
use App\Values\Radio\RadioStationUpdateData;
use Illuminate\Validation\Rule;
/**
* @property-read string $url
* @property-read string $name
* @property-read ?string $logo
* @property-read ?string $description
* @property-read ?bool $is_public
*/
class RadioStationUpdateRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'url' => [
'required',
'url',
Rule::unique('radio_stations')->where(function ($query) {
return $query->where('user_id', $this->user()->id);
})->ignore($this->route('station')->id), // @phpstan-ignore-line
app(ValidRadioStationUrl::class),
],
'name' => ['required', 'string', 'max:191'],
'logo' => ['nullable', 'sometimes', new ValidImageData()],
'description' => ['string', 'sometimes', 'nullable'],
'is_public' => ['boolean'],
];
}
public function toDto(): RadioStationUpdateData
{
return RadioStationUpdateData::make(
name: $this->name,
url: $this->url,
description: $this->string('description'),
logo: $this->has('logo') ? $this->string('logo') : null,
isPublic: $this->boolean('is_public')
);
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/ObjectStorage/Request.php | app/Http/Requests/API/ObjectStorage/Request.php | <?php
namespace App\Http\Requests\API\ObjectStorage;
use App\Http\Requests\API\Request as BaseRequest;
class Request extends BaseRequest
{
/** @inheritdoc */
public function rules(): array
{
return [
'bucket' => 'required',
'key' => 'required',
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/ObjectStorage/S3/PutSongRequest.php | app/Http/Requests/API/ObjectStorage/S3/PutSongRequest.php | <?php
namespace App\Http\Requests\API\ObjectStorage\S3;
use App\Http\Requests\API\ObjectStorage\S3\Request as BaseRequest;
/**
* @property string $bucket
* @property array<string> $tags
* @property string $key
*/
class PutSongRequest extends BaseRequest
{
/** @inheritdoc */
public function rules(): array
{
return [
'bucket' => 'required',
'key' => 'required',
'tags.duration' => 'required|numeric',
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/ObjectStorage/S3/Request.php | app/Http/Requests/API/ObjectStorage/S3/Request.php | <?php
namespace App\Http\Requests\API\ObjectStorage\S3;
use App\Http\Requests\API\ObjectStorage\Request as BaseRequest;
class Request extends BaseRequest
{
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/ObjectStorage/S3/RemoveSongRequest.php | app/Http/Requests/API/ObjectStorage/S3/RemoveSongRequest.php | <?php
namespace App\Http\Requests\API\ObjectStorage\S3;
use App\Http\Requests\API\ObjectStorage\S3\Request as BaseRequest;
/**
* @property string $bucket
* @property string $key
*/
class RemoveSongRequest extends BaseRequest
{
/** @inheritdoc */
public function rules(): array
{
return [
'bucket' => 'required',
'key' => 'required',
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Embed/EmbedOptionsEncryptRequest.php | app/Http/Requests/API/Embed/EmbedOptionsEncryptRequest.php | <?php
namespace App\Http\Requests\API\Embed;
use App\Http\Requests\API\Request;
/**
* @property-read string $theme
* @property-read string $layout
* @property-read bool $preview
*/
class EmbedOptionsEncryptRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
// we can't really validate the theme id, but we'll make sure it's not too long
'theme' => 'required|string|max:32',
'layout' => 'required|string|in:full,compact',
'preview' => 'sometimes|bool',
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Embed/ResolveEmbedRequest.php | app/Http/Requests/API/Embed/ResolveEmbedRequest.php | <?php
namespace App\Http\Requests\API\Embed;
use App\Enums\EmbeddableType;
use App\Http\Requests\Request;
use Illuminate\Validation\Rule;
/**
* @property-read string $embeddable_id
* @property-read string $embeddable_type
*/
class ResolveEmbedRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'embeddable_id' => ['required', 'string'],
'embeddable_type' => ['required', Rule::enum(EmbeddableType::class)],
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Favorites/ToggleFavoriteRequest.php | app/Http/Requests/API/Favorites/ToggleFavoriteRequest.php | <?php
namespace App\Http\Requests\API\Favorites;
use App\Http\Requests\API\Favorites\Concerns\ValidatesFavoriteableType;
use App\Http\Requests\API\Request;
/**
* @property-read string $type
* @property-read string $id
*/
class ToggleFavoriteRequest extends Request
{
use ValidatesFavoriteableType;
/** @inheritdoc */
public function rules(): array
{
return [
'type' => self::favoriteableTypeRule(),
'id' => ['required', 'string'],
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Favorites/StoreFavoritesRequest.php | app/Http/Requests/API/Favorites/StoreFavoritesRequest.php | <?php
namespace App\Http\Requests\API\Favorites;
use App\Http\Requests\API\Favorites\Concerns\ValidatesFavoriteableType;
use App\Http\Requests\API\Request;
/**
* @property-read string $type
* @property-read array<string> $ids
*/
class StoreFavoritesRequest extends Request
{
use ValidatesFavoriteableType;
/** @inheritdoc */
public function rules(): array
{
return [
'type' => self::favoriteableTypeRule(),
'ids' => ['required', 'array', 'min:1'],
'ids.*' => ['string'],
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Favorites/DestroyFavoritesRequest.php | app/Http/Requests/API/Favorites/DestroyFavoritesRequest.php | <?php
namespace App\Http\Requests\API\Favorites;
use App\Http\Requests\API\Favorites\Concerns\ValidatesFavoriteableType;
use App\Http\Requests\API\Request;
/**
* @property-read string $type
* @property-read array<string> $ids
*/
class DestroyFavoritesRequest extends Request
{
use ValidatesFavoriteableType;
/** @inheritdoc */
public function rules(): array
{
return [
'type' => self::favoriteableTypeRule(),
'ids' => ['required', 'array', 'min:1'],
'ids.*' => ['string'],
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Favorites/Concerns/ValidatesFavoriteableType.php | app/Http/Requests/API/Favorites/Concerns/ValidatesFavoriteableType.php | <?php
namespace App\Http\Requests\API\Favorites\Concerns;
use App\Enums\FavoriteableType;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\Enum;
trait ValidatesFavoriteableType
{
/** @return array<string|Enum> */
private static function favoriteableTypeRule(): array
{
return [
'string',
'required',
Rule::enum(FavoriteableType::class),
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Interaction/Request.php | app/Http/Requests/API/Interaction/Request.php | <?php
namespace App\Http\Requests\API\Interaction;
use App\Http\Requests\API\Request as BaseRequest;
abstract class Request extends BaseRequest
{
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Interaction/IncreasePlayCountRequest.php | app/Http/Requests/API/Interaction/IncreasePlayCountRequest.php | <?php
namespace App\Http\Requests\API\Interaction;
use App\Http\Requests\API\Request;
use Illuminate\Validation\Rule;
/**
* @property-read string $song The song's ID
*/
class IncreasePlayCountRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'song' => ['required', Rule::exists('songs', 'id')],
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/PlaylistCollaboration/PlaylistCollaboratorDestroyRequest.php | app/Http/Requests/API/PlaylistCollaboration/PlaylistCollaboratorDestroyRequest.php | <?php
namespace App\Http\Requests\API\PlaylistCollaboration;
use App\Http\Requests\API\Request;
/**
* @property-read string $collaborator The public ID of the user to remove as a collaborator.
*/
class PlaylistCollaboratorDestroyRequest extends Request
{
/**
* @return array<string, mixed>
*/
public function rules(): array
{
return [
'collaborator' => 'required|exists:users,public_id',
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Settings/UpdateBrandingRequest.php | app/Http/Requests/API/Settings/UpdateBrandingRequest.php | <?php
namespace App\Http\Requests\API\Settings;
use App\Http\Requests\API\Request;
use App\Rules\ValidImageData;
use Closure;
use Illuminate\Support\Facades\URL;
/**
* @property-read string $name
* @property-read ?string $logo
* @property-read ?string $cover
*/
class UpdateBrandingRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
$validImageDataOrUrl = static function (string $attribute, mixed $value, Closure $fail): void {
if (URL::isValidUrl($value)) {
return;
}
(new ValidImageData())->validate($attribute, $value, $fail);
};
return [
'name' => 'required|string',
'logo' => ['sometimes', 'nullable', $validImageDataOrUrl],
'cover' => ['sometimes', 'nullable', $validImageDataOrUrl],
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Requests/API/Settings/UpdateMediaPathRequest.php | app/Http/Requests/API/Settings/UpdateMediaPathRequest.php | <?php
namespace App\Http\Requests\API\Settings;
use App\Http\Requests\API\Request;
use App\Rules\MediaPath;
/**
* @property-read string $path
*/
class UpdateMediaPathRequest extends Request
{
/** @inheritdoc */
public function rules(): array
{
return [
'path' => ['string', new MediaPath()],
];
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Controllers/IndexController.php | app/Http/Controllers/IndexController.php | <?php
namespace App\Http\Controllers;
use App\Attributes\DisabledInDemo;
use App\Facades\License;
use App\Services\AuthenticationService;
use App\Services\ProxyAuthService;
use Illuminate\Http\Request;
#[DisabledInDemo]
class IndexController extends Controller
{
public function __invoke(
Request $request,
ProxyAuthService $proxyAuthService,
AuthenticationService $auth,
) {
$data = ['token' => null];
if (License::isPlus() && config('koel.proxy_auth.enabled')) {
$data['token'] = optional(
$proxyAuthService->tryGetProxyAuthenticatedUserFromRequest($request),
static fn ($user) => $auth->logUserIn($user)->toArray()
);
}
return view('index', $data);
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Controllers/StreamEmbedController.php | app/Http/Controllers/StreamEmbedController.php | <?php
namespace App\Http\Controllers;
use App\Models\Embed;
use App\Models\Song;
use App\Services\Streamer\Streamer;
class StreamEmbedController extends Controller
{
public function __invoke(Embed $embed, Song $song)
{
return (new Streamer(song: $song))->stream();
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Controllers/Controller.php | app/Http/Controllers/Controller.php | <?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
abstract class Controller
{
use AuthorizesRequests;
use DispatchesJobs;
use ValidatesRequests;
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Controllers/PlayController.php | app/Http/Controllers/PlayController.php | <?php
namespace App\Http\Controllers;
use App\Http\Requests\SongPlayRequest;
use App\Models\Song;
use App\Models\User;
use App\Services\Streamer\Streamer;
use App\Values\RequestedStreamingConfig;
use Illuminate\Contracts\Auth\Authenticatable;
class PlayController extends Controller
{
/**
* @param User $user
* @param ?bool $transcode Whether to **force** transcoding (on mobile devices).
*/
public function __invoke(Authenticatable $user, SongPlayRequest $request, Song $song, ?bool $transcode = null)
{
$this->authorize('access', $song);
// If force transcoding is enabled, use the user's transcoding quality preference.
// Otherwise, set this value to null. If the file does indeed need transcoding,
// the Streamer will use the config value from .env.
$transcodeBitRate = $transcode
? (int) filter_var($user->preferences->transcodeQuality, FILTER_SANITIZE_NUMBER_INT)
: null;
return (new Streamer(
song: $song,
config: RequestedStreamingConfig::make(
transcode: (bool) $transcode,
bitRate: $transcodeBitRate,
startTime: (float) $request->time
)
))->stream();
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Controllers/ViewSongOnITunesController.php | app/Http/Controllers/ViewSongOnITunesController.php | <?php
namespace App\Http\Controllers;
use App\Http\Requests\API\ViewSongOnITunesRequest;
use App\Models\Album;
use App\Services\ITunesService;
use App\Services\TokenManager;
use Illuminate\Http\Response;
class ViewSongOnITunesController extends Controller
{
public function __invoke(
ViewSongOnITunesRequest $request,
ITunesService $iTunesService,
TokenManager $tokenManager,
Album $album
) {
abort_unless(
(bool) $tokenManager->getUserFromPlainTextToken($request->api_token),
Response::HTTP_UNAUTHORIZED
);
$url = $iTunesService->getTrackUrl($request->q, $album);
abort_unless((bool) $url, Response::HTTP_NOT_FOUND, "Koel can't find such a song on iTunes Store.");
return redirect($url);
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
koel/koel | https://github.com/koel/koel/blob/add9401a4b9a904bb1b9f679bc674ad1570ff20e/app/Http/Controllers/AuthorizeDropboxController.php | app/Http/Controllers/AuthorizeDropboxController.php | <?php
namespace App\Http\Controllers;
use App\Attributes\RequiresPlus;
use Illuminate\Http\Request;
#[RequiresPlus]
class AuthorizeDropboxController extends Controller
{
public function __invoke(Request $request)
{
$appKey = $request->route('key');
return redirect()->away(
"https://www.dropbox.com/oauth2/authorize?client_id=$appKey&response_type=code&token_access_type=offline",
);
}
}
| php | MIT | add9401a4b9a904bb1b9f679bc674ad1570ff20e | 2026-01-04T15:02:34.446708Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.