增加策略列表接口,接口支持上传时指定策略

This commit is contained in:
Wisp X
2022-03-06 14:11:30 +08:00
parent 0d1fd3461a
commit 677a0afeee
4 changed files with 112 additions and 5 deletions
@@ -0,0 +1,20 @@
<?php
namespace App\Http\Controllers\Api\V1;
use App\Http\Controllers\Controller;
use App\Models\Group;
use App\Models\Strategy;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
class StrategyController extends Controller
{
public function index(): Response
{
/** @var Group $group */
$group = Auth::check() ? Auth::user()->group : Group::query()->where('is_guest', true)->first();
$strategies = $group->strategies()->get()->each(fn (Strategy $strategy) => $strategy->setVisible(['id', 'name']));
return $this->success('success', compact('strategies'));
}
}