<?php

use App\Exceptions\Form\CutImage;
use App\Exceptions\Form\MultipleCutImage;
use App\Exceptions\Form\TradImage;
use Dcat\Admin\Admin;
use App\Exceptions\Form\TradFile;
use Dcat\Admin\Form\Field\MultipleImage;
use Dcat\Admin\Grid;
use Dcat\Admin\Form;
use Dcat\Admin\Grid\Filter;
use Dcat\Admin\Show;
use Dcat\Admin\Layout\Content;
use Illuminate\Support\ServiceProvider;
use Dcat\Admin\Form\Field\Editor;

/**
 * Dcat-admin - admin builder based on Laravel.
 * @author jqh <https://github.com/jqhph>
 *
 * Bootstraper for Admin.
 *
 * Here you can remove builtin form field:
 *
 * extend custom field:
 * Dcat\Admin\Form::extend('php', PHPEditor::class);
 * Dcat\Admin\Grid\Column::extend('php', PHPEditor::class);
 * Dcat\Admin\Grid\Filter::extend('php', PHPEditor::class);
 *
 * Or require js and css assets:
 * Admin::css('/packages/prettydocs/css/styles.css');
 * Admin::js('/packages/prettydocs/js/main.js');
 *
 */

// 设置后台布局
$newContent = new Content();
$newContent->view('admin.layouts.content');
app()->singleton(Content::class, function () use ($newContent) {
    return $newContent;
});


// 覆盖默认配置
#config(['admin' => user_admin_config()]);
#config(['app.locale' => config('admin.lang') ?: config('app.locale')]);


// 获取当前登录用户
$user = Admin::guard()->check() ? Admin::user() : null;

// 设置应用程序的本地化
config(['app.locale' => Cookie::get('lang') ?: config('app.locale')]);
//编辑器配置
Editor::resolving(function (Editor $editor) {
    // 设置默认配置
    $editor->options([
        'plugins'=>["advlist","autolink","link","image","media","lists","preview","code","help","fullscreen","table","autoresize","codesample"],
        'toolbar'=>["undo redo | preview fullscreen | formatselect  | fontsizeselect bold italic underline strikethrough forecolor backcolor | link image media blockquote removeformat codesample","alignleft aligncenter alignright  alignjustify| indent outdent bullist numlist table subscript superscript | code"],
    ]);
});

//裁剪图片表单扩展
Form::extend('multipleCutImage', MultipleCutImage::class);
Form::extend('cutImage', CutImage::class);
Form::extend('tradFile', TradFile::class);
Form::extend('tradImage', TradImage::class);
