mirror of
https://gh.wpcy.net/https://github.com/fairpm/aspirecloud.git
synced 2026-06-20 02:22:28 +08:00
45 lines
976 B
PHP
45 lines
976 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Services\Packages;
|
|
|
|
use App\Models\Package;
|
|
|
|
class PackageInformationService
|
|
{
|
|
/**
|
|
* @param string $did
|
|
* @return Package|null
|
|
*/
|
|
public function findByDID(string $did): Package|null
|
|
{
|
|
return Package::query()->where('did', $did)->first();
|
|
}
|
|
|
|
/**
|
|
* @param string $type
|
|
* @param string $slug
|
|
* @return Package|null
|
|
*/
|
|
public function find(string $type, string $slug): Package|null
|
|
{
|
|
return Package::query()
|
|
->where('type', $type)
|
|
->where('slug', $slug)
|
|
->first();
|
|
}
|
|
|
|
/**
|
|
* @param string $did
|
|
* @return string
|
|
*/
|
|
public function getPackageMetadataUrl(string $did): string
|
|
{
|
|
return route('package.fairMetadata', ['did' => $did], true);
|
|
}
|
|
|
|
public function findBySlug(string $slug): Package|null
|
|
{
|
|
return Package::query()->where('slug', $slug)->first();
|
|
}
|
|
}
|