Manage redirects, missing URLs, repositories and settings through the API
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
35
app/Http/Resources/MissingUrlResource.php
Normal file
35
app/Http/Resources/MissingUrlResource.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\MissingUrl;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @mixin MissingUrl
|
||||
*/
|
||||
class MissingUrlResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'path' => $this->path,
|
||||
'locale' => $this->locale,
|
||||
'referrer' => $this->referrer,
|
||||
// Our own page links here: more urgent than someone else's stale link.
|
||||
'internal_referrer' => $this->resource->isInternalReferrer(),
|
||||
'status' => $this->status->value,
|
||||
'hits' => (int) $this->hits,
|
||||
'first_seen_at' => $this->first_seen_at?->toIso8601String(),
|
||||
'last_seen_at' => $this->last_seen_at?->toIso8601String(),
|
||||
'resolved_at' => $this->resolved_at?->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
35
app/Http/Resources/RedirectResource.php
Normal file
35
app/Http/Resources/RedirectResource.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\Redirect;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @mixin Redirect
|
||||
*/
|
||||
class RedirectResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'from' => $this->from,
|
||||
'to' => $this->to,
|
||||
'status' => $this->status,
|
||||
'locale' => $this->locale,
|
||||
'is_enabled' => (bool) $this->is_enabled,
|
||||
'automatic' => $this->resource->wasAutomatic(),
|
||||
'hits' => (int) $this->hits,
|
||||
'last_used_at' => $this->last_used_at?->toIso8601String(),
|
||||
'created_at' => $this->created_at?->toIso8601String(),
|
||||
'updated_at' => $this->updated_at?->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
51
app/Http/Resources/RepositoryResource.php
Normal file
51
app/Http/Resources/RepositoryResource.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\Repository;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @mixin Repository
|
||||
*/
|
||||
class RepositoryResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'provider' => $this->provider->value,
|
||||
'full_name' => $this->full_name,
|
||||
'project_id' => $this->project_id,
|
||||
'is_primary' => (bool) $this->is_primary,
|
||||
'show_publicly' => (bool) $this->show_publicly,
|
||||
|
||||
// What the provider last reported.
|
||||
'html_url' => $this->html_url,
|
||||
'description' => $this->description,
|
||||
'homepage' => $this->homepage,
|
||||
'default_branch' => $this->default_branch,
|
||||
'primary_language' => $this->primary_language,
|
||||
'license' => $this->license,
|
||||
'topics' => $this->topics ?? [],
|
||||
'stars' => (int) $this->stars,
|
||||
'forks' => (int) $this->forks,
|
||||
'open_issues_count' => (int) $this->open_issues_count,
|
||||
'is_archived' => (bool) $this->is_archived,
|
||||
'pushed_at' => $this->pushed_at?->toIso8601String(),
|
||||
|
||||
'last_synced_at' => $this->last_synced_at?->toIso8601String(),
|
||||
'sync_error' => $this->sync_error,
|
||||
'sync_failures' => (int) $this->sync_failures,
|
||||
|
||||
'created_at' => $this->created_at?->toIso8601String(),
|
||||
'updated_at' => $this->updated_at?->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
27
app/Http/Resources/SettingResource.php
Normal file
27
app/Http/Resources/SettingResource.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @mixin Setting
|
||||
*/
|
||||
class SettingResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'key' => $this->key,
|
||||
'value' => $this->value,
|
||||
'updated_at' => $this->updated_at?->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user