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>
32 lines
783 B
PHP
32 lines
783 B
PHP
<?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);
|
|
}
|
|
}
|