SelectionController.php 1.4 KB
<?php

namespace App\Http\Container\ManageSection\Controllers;

use App\Models\Project;
use App\Models\SystemConfig;
use App\Models\SystemTag;
use App\Models\User;
use App\Support\Controller;
use Auth;
use Hikoon\LaravelApi\Facades\Response;
use Illuminate\Http\Request;

class SelectionController extends Controller
{
    public function user(): Response
    {
        $data = User::query()->where('audit_status', 1)->latest('id')->get(['id', 'nick_name', 'real_name']);
        return $this->successWithData($data);
    }

    /**
     * @return \Hikoon\LaravelApi\Facades\Response
     */
    public function project(Request $request): Response
    {
        $filter = $request->all();
        $data   = Project::filter($filter)
            ->whereRelation('managers', 'user_id', Auth::id())
            ->latest('weight')->get(['id', 'name', 'is_can_apply', 'is_can_demo_apply']);

        return $this->successWithData($data);
    }

    /**
     * @return \Hikoon\LaravelApi\Facades\Response
     */
    public function tag(): Response
    {
        $data = SystemTag::query()->latest('weight')->get(['id', 'name', 'type']);
        return $this->successWithData($data);
    }


    public function config(Request $request): Response
    {
        $data = SystemConfig::filter($request->all())->latest('weight')->get(['id', 'identifier', 'name', 'content', 'parent_id']);
        return $this->successWithData($data);
    }
}