<?php

namespace App\Admin\Controllers;

use App\Services\MemberSocialAccountService;
use Slowlyo\OwlAdmin\Controllers\AdminController;

/**
 * 社交账号管理
 *
 * @property MemberSocialAccountService $service
 */
class MemberSocialAccountController extends AdminController
{
	protected string $serviceName = MemberSocialAccountService::class;

	public function list()
	{
		$crud = $this->baseCRUD()
			->filterTogglable(false)
			->headerToolbar([
				$this->createButton('dialog'),
				...$this->baseHeaderToolBar()
			])
			->columns([
				amis()->TableColumn('id', 'ID')->sortable(),
				amis()->TableColumn('user_id', '用户编号'),
				amis()->TableColumn('platform', '社交平台'),
				amis()->TableColumn('social_id', '社交账号'),
				amis()->TableColumn('nickname', '昵称'),
				amis()->TableColumn('avatar', '头像'),
				amis()->TableColumn('created_at', admin_trans('admin.created_at'))->type('datetime')->sortable(),
				amis()->TableColumn('updated_at', admin_trans('admin.updated_at'))->type('datetime')->sortable(),
				$this->rowActions('dialog')
			]);

		return $this->baseList($crud);
	}

	public function form($isEdit = false)
	{
		return $this->baseForm()->body([
			amis()->TextControl('user_id', '用户编号'),
			amis()->TextControl('platform', '社交平台'),
			amis()->TextControl('social_id', '社交账号'),
			amis()->TextControl('nickname', '昵称'),
			amis()->TextControl('avatar', '头像'),
		]);
	}

	public function detail()
	{
		return $this->baseDetail()->body([
			amis()->TextControl('id', 'ID')->static(),
			amis()->TextControl('user_id', '用户编号')->static(),
			amis()->TextControl('platform', '社交平台')->static(),
			amis()->TextControl('social_id', '社交账号')->static(),
			amis()->TextControl('nickname', '昵称')->static(),
			amis()->TextControl('avatar', '头像')->static(),
			amis()->TextControl('created_at', admin_trans('admin.created_at'))->static(),
			amis()->TextControl('updated_at', admin_trans('admin.updated_at'))->static(),
		]);
	}
}