feat: add read-only Social Accounts API

Add GET /api/accounts (list with optional ?network= and ?type= filters) and
GET /api/accounts/{socialAccount} (show) endpoints. Include plain-text password
field for AI agent consumption.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Doar Mihai
2026-07-18 15:25:56 +03:00
co-authored by Claude Sonnet 5
parent 20c33f1c23
commit 5c24b6fbe0
4 changed files with 104 additions and 0 deletions
@@ -0,0 +1,31 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Resources\SocialAccountResource;
use App\Models\SocialAccount;
use Illuminate\Http\Request;
class SocialAccountController extends Controller
{
public function index(Request $request)
{
$query = SocialAccount::query();
if ($request->filled('network')) {
$query->where('network', $request->string('network'));
}
if ($request->filled('type')) {
$query->where('type', $request->string('type'));
}
return SocialAccountResource::collection($query->orderBy('username')->get());
}
public function show(SocialAccount $socialAccount)
{
return new SocialAccountResource($socialAccount);
}
}
@@ -0,0 +1,23 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class SocialAccountResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'network' => $this->network,
'username' => $this->username,
'email' => $this->email,
'password' => $this->password,
'type' => $this->type,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}